Skip to content

Commit e3c630a

Browse files
authored
[OMON-363] Add proportional set size to process monitoring (#206)
1 parent 734c1e7 commit e3c630a

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

include/Monitoring/ProcessMonitor.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ class ProcessMonitor
9999
/// Retrieves virtual memory and resident set size usage
100100
std::vector<Metric> getMemoryUsage();
101101

102+
/// Retrieves proportional set size
103+
Metric getPss();
104+
102105
/// Retrieves CPU usage (%) and number of context switches during the interval
103106
std::vector<Metric> getCpuAndContexts();
104107

src/ProcessMonitor.cxx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,20 @@ std::vector<Metric> ProcessMonitor::getMemoryUsage()
7272
return metrics;
7373
}
7474

75+
Metric ProcessMonitor::getPss()
76+
{
77+
std::ifstream statusStream("/proc/self/smaps");
78+
double pssTotal = 0;
79+
std::string pssString;
80+
81+
while (std::getline(statusStream, pssString)) {
82+
if (pssString.rfind("Pss:", 0) == 0) {
83+
pssTotal += splitStatusLineAndRetriveValue(pssString);
84+
}
85+
}
86+
return {pssTotal, "pss"};
87+
}
88+
7589
std::vector<Metric> ProcessMonitor::getCpuAndContexts()
7690
{
7791
std::vector<Metric> metrics;
@@ -116,6 +130,7 @@ std::vector<Metric> ProcessMonitor::getPerformanceMetrics()
116130
#ifdef O2_MONITORING_OS_LINUX
117131
auto memoryMetrics = getMemoryUsage();
118132
std::move(memoryMetrics.begin(), memoryMetrics.end(), std::back_inserter(metrics));
133+
metrics.emplace_back(getPss());
119134
#endif
120135
return metrics;
121136
}

0 commit comments

Comments
 (0)