From f55f1f5b0b813a8a9e6aba3071d7fadbeeb9dc4d Mon Sep 17 00:00:00 2001 From: Chris Walquist Date: Fri, 31 Jan 2014 22:54:46 -0600 Subject: [PATCH] Apply a fix similar to 6b16991 'ps -p', no space before dash-p option args; also needed for the '-o' option of ps. Tested on Ubuntu 11.04 vm. Without this fix, the passenger logfile grows out of control. --- ext/common/Utils/ProcessMetricsCollector.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/ext/common/Utils/ProcessMetricsCollector.h b/ext/common/Utils/ProcessMetricsCollector.h index d3fba83660..493740cd83 100644 --- a/ext/common/Utils/ProcessMetricsCollector.h +++ b/ext/common/Utils/ProcessMetricsCollector.h @@ -450,14 +450,16 @@ class ProcessMetricsCollector { if (pidsArg[pidsArg.size() - 1] == ',') { pidsArg.resize(pidsArg.size() - 1); } + + string fmtArg = "-o"; + #if defined(sun) || defined(__sun) + fmtArg.append("pid,ppid,pcpu,rss,vsz,pgid,uid,args"); + #else + fmtArg.append("pid,ppid,%cpu,rss,vsize,pgid,uid,command"); + #endif const char *command[] = { - "ps", "-o", - #if defined(sun) || defined(__sun) - "pid,ppid,pcpu,rss,vsz,pgid,uid,args", - #else - "pid,ppid,%cpu,rss,vsize,pgid,uid,command", - #endif + "ps", fmtArg.c_str(), #ifdef PS_SUPPORTS_MULTIPLE_PIDS pidsArg.c_str(), #endif @@ -469,6 +471,7 @@ class ProcessMetricsCollector { psOutput = runCommandAndCaptureOutput(command); } pidsArg.resize(0); + fmtArg.resize(0); ProcessMetricMap result = parsePsOutput(psOutput, pids); psOutput.resize(0); if (canMeasureRealMemory) {