16 #ifndef ALICEO2_MONITORING_CORE_PROCESSMONITOR_H 17 #define ALICEO2_MONITORING_CORE_PROCESSMONITOR_H 20 #include <boost/algorithm/string.hpp> 24 #include <sys/resource.h> 41 MEMORY_USAGE_PERCENTAGE = 0,
45 INVOLUNTARY_CONTEXT_SWITCHING,
47 AVG_RESIDENT_SET_SIZE,
48 AVG_VIRTUAL_MEMORY_SIZE,
49 AVG_CPU_USED_PERCENTAGE,
52 AVAILABLE_METRICS_SIZE
55 static std::vector<std::string> getAvailableMetricsNames();
56 std::vector<Metric> getPerformanceMetrics();
68 double splitStatusLineAndRetriveValue(
const std::string& line)
const;
71 void setTotalMemory();
74 static constexpr
const char* metricsNames[] = {
"memoryUsagePercentage",
"virtualMemorySize",
"residentSetSize",
75 "cpuUsedPercentage",
"involuntaryContextSwitches",
"cpuUsedAbsolute",
76 "averageResidentSetSize",
"averageVirtualMemorySize",
"averageCpuUsedPercentage",
77 "cpuTimeConsumedByProcess",
"proportionalSetSize"};
79 static constexpr
unsigned int VM_SIZE_INDEX = 18;
80 static constexpr
unsigned int VM_RSS_INDEX = 22;
86 unsigned int mTotalMemory;
89 struct rusage mPreviousGetrUsage;
92 std::vector<double> mVmSizeMeasurements;
93 std::vector<double> mVmRssMeasurements;
94 std::vector<uint64_t> mCpuMicroSeconds;
95 std::vector<double> mCpuPerctange;
98 std::chrono::high_resolution_clock::time_point mTimeLastRun;
101 std::vector<Metric> getMemoryUsage();
107 std::vector<Metric> getCpuAndContexts();
109 std::vector<Metric> makeLastMeasurementAndGetMetrics();
115 #endif // ALICEO2_MONITORING_CORE_PROCESSMONITOR_H
Monitors current process and/or other processes running at the same machien.
Definition: ProcessMonitor.h:35
ProcessMonitor()
Prepares externam software commands (ps)
Definition: ProcessMonitor.cxx:22
Main class that collects metrics from user and dispatches them to selected monitoring backends...
Definition: Monitoring.h:46
Represents a metric including value, type of the value, name, timestamp and tags. ...
Definition: Metric.h:37
~ProcessMonitor()=default
Default destructor.