ClickHouse/dbms/src/Common/TaskStatsInfoGetter.h

35 lines
706 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();
2018-08-22 00:24:55 +00:00
void getStat(::taskstats & stat, pid_t tid);
/// Make a syscall and returns Linux thread id
2018-08-22 00:05:06 +00:00
static pid_t getCurrentTID();
/// 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(__linux__)
private:
int netlink_socket_fd = -1;
2018-08-22 00:24:55 +00:00
UInt16 taskstats_family_id = 0;
#endif
};
}