diff options
author | robot-piglet <robot-piglet@yandex-team.com> | 2023-11-12 21:25:31 +0300 |
---|---|---|
committer | robot-piglet <robot-piglet@yandex-team.com> | 2023-11-12 21:39:54 +0300 |
commit | d28c55ab25cc8cedab8a5f4736c0d66e88b3da95 (patch) | |
tree | 73d373709b74fa2baaa4fe02a40a77c0a5baf6b7 /library/cpp/porto/metrics.hpp | |
parent | 35b17f4f3b6e0ed855e7e47d3f1eb57470388a2c (diff) | |
download | ydb-d28c55ab25cc8cedab8a5f4736c0d66e88b3da95.tar.gz |
Intermediate changes
Diffstat (limited to 'library/cpp/porto/metrics.hpp')
-rw-r--r-- | library/cpp/porto/metrics.hpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/library/cpp/porto/metrics.hpp b/library/cpp/porto/metrics.hpp new file mode 100644 index 0000000000..5b2ffde8d9 --- /dev/null +++ b/library/cpp/porto/metrics.hpp @@ -0,0 +1,50 @@ +#pragma once + +#include "libporto.hpp" + +#include <util/generic/map.h> +#include <util/generic/vector.h> +#include <util/string/cast.h> +#include <util/string/type.h> + +#include <library/cpp/porto/proto/rpc.pb.h> +namespace Porto { + +constexpr const char *M_CTXSW = "ctxsw"; + +enum class EMetric { + NONE, + CTXSW, +}; + +class TMetric { +public: + TString Name; + EMetric Metric; + + TMetric(const TString& name, EMetric metric); + + void ClearValues(const TVector<TString>& names, TMap<TString, uint64_t>& values) const; + EError GetValues(const TVector<TString>& names, TMap<TString, uint64_t>& values, TPortoApi& api) const; + + // Returns value of metric from /proc/tid/sched for some tid + uint64_t GetTidSchedMetricValue(int procFd, const TString& tid, const TString& metricName) const; + + void TidSnapshot(TVector<TString>& tids) const; + void GetPidTasks(const TString& pid, TVector<TString>& tids) const; + + // Returns freezer cgroup from /proc/tid/cgroup + TString GetFreezerCgroup(int procFd, const TString& tid) const; + + // Resurns clean cgroup[freezer] for containers names + TMap<TString, TString> GetCtFreezerCgroups(const TGetResponse* response) const; + + // Verify inclusion of container cgroup in process cgroup + bool MatchCgroups(const TString& tidCgroup, const TString& ctCgroup) const; + +private: + virtual uint64_t GetMetric(int procFd, const TString& tid) const = 0; +}; + +extern TMap<TString, TMetric*> ProcMetrics; +} /* namespace Porto */ |