ClickHouse/dbms/Common/TaskStatsInfoGetter.h

32 lines
624 B
C++
Raw Normal View History

#pragma once
2018-08-21 23:56:55 +00:00
2018-08-22 00:05:06 +00:00
#include <sys/types.h>
#include <Core/Types.h>
2018-08-22 00:05:06 +00:00
#include <boost/noncopyable.hpp>
struct taskstats;
namespace DB
{
2018-08-17 18:57:07 +00:00
/// Get taskstat info from OS kernel via Netlink protocol.
2018-08-22 00:05:06 +00:00
class TaskStatsInfoGetter : private boost::noncopyable
{
public:
2018-08-22 00:24:55 +00:00
TaskStatsInfoGetter();
~TaskStatsInfoGetter();
2020-03-08 21:18:53 +00:00
void getStat(::taskstats & out_stats, pid_t tid);
2018-08-22 00:24:55 +00:00
/// Whether the current process has permissions (sudo or cap_net_admin capabilties) to get taskstats info
2018-08-21 21:05:30 +00:00
static bool checkPermissions();
#if defined(OS_LINUX)
private:
int netlink_socket_fd = -1;
2018-08-22 00:24:55 +00:00
UInt16 taskstats_family_id = 0;
#endif
};
}