Permalink
Browse files

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.
  • Loading branch information...
1 parent 4bbcd93 commit f55f1f5b0b813a8a9e6aba3071d7fadbeeb9dc4d @walquis walquis committed Feb 1, 2014
Showing with 9 additions and 6 deletions.
  1. +9 −6 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<Collection, ConstIterator>(psOutput, pids);
psOutput.resize(0);
if (canMeasureRealMemory) {

0 comments on commit f55f1f5

Please sign in to comment.