Skip to content

Commit 314c2b6

Browse files
authored
Merge pull request #374 from ktf/pr374
Detect smaps_rollup at runtime
2 parents df706fa + c7bdc9f commit 314c2b6

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

src/ProcessMonitor.cxx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,8 @@ namespace o2
3636
namespace monitoring
3737
{
3838

39-
#ifdef O2_MONITORING_OS_CC7
39+
static constexpr auto SMAPS_ROLLUP_FILE = "/proc/self/smaps_rollup";
4040
static constexpr auto SMAPS_FILE = "/proc/self/smaps";
41-
#else
42-
static constexpr auto SMAPS_FILE = "/proc/self/smaps_rollup";
43-
#endif
4441

4542
#ifdef O2_MONITORING_OS_LINUX
4643
namespace
@@ -148,7 +145,9 @@ std::vector<Metric> ProcessMonitor::getMemoryUsage()
148145

149146
std::vector<Metric> ProcessMonitor::getSmaps()
150147
{
151-
std::ifstream statusStream(SMAPS_FILE);
148+
static const char* const smapsFile =
149+
(::access(SMAPS_ROLLUP_FILE, R_OK) == 0) ? SMAPS_ROLLUP_FILE : SMAPS_FILE;
150+
std::ifstream statusStream(smapsFile);
152151
double pssTotal = 0;
153152
double cleanTotal = 0;
154153
double dirtyTotal = 0;

0 commit comments

Comments
 (0)