File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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+
7589std::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}
You can’t perform that action at this time.
0 commit comments