Skip to content

Commit

Permalink
[OMON-363] Add proportional set size to process monitoring (#206)
Browse files Browse the repository at this point in the history
  • Loading branch information
awegrzyn authored Aug 11, 2020
1 parent 734c1e7 commit e3c630a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions include/Monitoring/ProcessMonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ class ProcessMonitor
/// Retrieves virtual memory and resident set size usage
std::vector<Metric> getMemoryUsage();

/// Retrieves proportional set size
Metric getPss();

/// Retrieves CPU usage (%) and number of context switches during the interval
std::vector<Metric> getCpuAndContexts();

Expand Down
15 changes: 15 additions & 0 deletions src/ProcessMonitor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,20 @@ std::vector<Metric> ProcessMonitor::getMemoryUsage()
return metrics;
}

Metric ProcessMonitor::getPss()
{
std::ifstream statusStream("/proc/self/smaps");
double pssTotal = 0;
std::string pssString;

while (std::getline(statusStream, pssString)) {
if (pssString.rfind("Pss:", 0) == 0) {
pssTotal += splitStatusLineAndRetriveValue(pssString);
}
}
return {pssTotal, "pss"};
}

std::vector<Metric> ProcessMonitor::getCpuAndContexts()
{
std::vector<Metric> metrics;
Expand Down Expand Up @@ -116,6 +130,7 @@ std::vector<Metric> ProcessMonitor::getPerformanceMetrics()
#ifdef O2_MONITORING_OS_LINUX
auto memoryMetrics = getMemoryUsage();
std::move(memoryMetrics.begin(), memoryMetrics.end(), std::back_inserter(metrics));
metrics.emplace_back(getPss());
#endif
return metrics;
}
Expand Down

0 comments on commit e3c630a

Please sign in to comment.