diff --git a/include/Monitoring/ProcessMonitor.h b/include/Monitoring/ProcessMonitor.h index f408fe5a6..8b18167e4 100644 --- a/include/Monitoring/ProcessMonitor.h +++ b/include/Monitoring/ProcessMonitor.h @@ -99,6 +99,9 @@ class ProcessMonitor /// Retrieves virtual memory and resident set size usage std::vector getMemoryUsage(); + /// Retrieves proportional set size + Metric getPss(); + /// Retrieves CPU usage (%) and number of context switches during the interval std::vector getCpuAndContexts(); diff --git a/src/ProcessMonitor.cxx b/src/ProcessMonitor.cxx index 139451d7c..286d6e35b 100644 --- a/src/ProcessMonitor.cxx +++ b/src/ProcessMonitor.cxx @@ -72,6 +72,20 @@ std::vector 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 ProcessMonitor::getCpuAndContexts() { std::vector metrics; @@ -116,6 +130,7 @@ std::vector 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; }