2018-05-17 16:01:41 +00:00
|
|
|
#pragma once
|
2018-08-21 23:56:55 +00:00
|
|
|
|
2018-08-22 00:05:06 +00:00
|
|
|
#include <sys/types.h>
|
2018-05-17 16:01:41 +00:00
|
|
|
#include <Core/Types.h>
|
2018-08-22 00:05:06 +00:00
|
|
|
#include <boost/noncopyable.hpp>
|
2018-05-17 16:01:41 +00:00
|
|
|
|
|
|
|
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
|
2018-05-17 16:01:41 +00:00
|
|
|
{
|
|
|
|
public:
|
2018-08-22 00:24:55 +00:00
|
|
|
TaskStatsInfoGetter();
|
2018-06-14 14:29:42 +00:00
|
|
|
~TaskStatsInfoGetter();
|
2018-05-17 16:01:41 +00:00
|
|
|
|
2020-03-08 21:18:53 +00:00
|
|
|
void getStat(::taskstats & out_stats, pid_t tid);
|
2018-08-22 00:24:55 +00:00
|
|
|
|
2018-06-14 14:29:42 +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();
|
2018-05-17 16:01:41 +00:00
|
|
|
|
2019-12-22 17:20:33 +00:00
|
|
|
#if defined(OS_LINUX)
|
2018-05-17 16:01:41 +00:00
|
|
|
private:
|
|
|
|
int netlink_socket_fd = -1;
|
2018-08-22 00:24:55 +00:00
|
|
|
UInt16 taskstats_family_id = 0;
|
2018-08-22 05:56:06 +00:00
|
|
|
#endif
|
2018-05-17 16:01:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|