1#pragma once
2
3#include <sys/types.h>
4#include <Core/Types.h>
5#include <boost/noncopyable.hpp>
6
7struct taskstats;
8
9namespace DB
10{
11
12/// Get taskstat info from OS kernel via Netlink protocol.
13class TaskStatsInfoGetter : private boost::noncopyable
14{
15public:
16 TaskStatsInfoGetter();
17 ~TaskStatsInfoGetter();
18
19 void getStat(::taskstats & stat, pid_t tid);
20
21 /// Make a syscall and returns Linux thread id
22 static pid_t getCurrentTID();
23
24 /// Whether the current process has permissions (sudo or cap_net_admin capabilties) to get taskstats info
25 static bool checkPermissions();
26
27#if defined(OS_LINUX)
28private:
29 int netlink_socket_fd = -1;
30 UInt16 taskstats_family_id = 0;
31#endif
32};
33
34}
35