ClickHouse/src/Common/TaskStatsInfoGetter.h

32 lines
631 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>
2021-10-02 07:13:14 +00:00
#include <base/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-04-22 05:39:31 +00:00
void getStat(::taskstats & out_stats, pid_t tid) const;
2018-08-22 00:24:55 +00:00
2020-08-08 00:47:03 +00:00
/// Whether the current process has permissions (sudo or cap_net_admin capabilities) 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
};
}