Permalink
Browse files

Fix process metrics collection on some operating systems.

Some systems' 'ps' command expect no space between -p and the list of PIDs.
  • Loading branch information...
1 parent d418f54 commit 6b16991b2481c98df72f8bc61fdae1f9c510d97b @FooBarWidget FooBarWidget committed Aug 15, 2013
Showing with 9 additions and 4 deletions.
  1. +2 −0 NEWS
  2. +7 −4 ext/common/Utils/ProcessMetricsCollector.h
View
2 NEWS
@@ -16,6 +16,8 @@ Release 4.0.13
* Added a hidden configuration option for customizing the application start
timeout. A proper configuration option will be introduced in the future.
* Added autodetection support for Amazon Linux.
+ * Fixed process metrics collection on some operating systems. Some systems'
+ 'ps' command expect no space between -p and the list of PIDs.
Release 4.0.10
@@ -39,9 +39,10 @@
#include <mach/mach_vm.h>
#include <mach/mach_port.h>
#endif
-#ifndef __NetBSD__
+#if !defined(__NetBSD__) && !defined(__OpenBSD__)
// NetBSD does not support -p with multiple PIDs.
// https://code.google.com/p/phusion-passenger/issues/detail?id=736
+ // OpenBSD 5.2 doesn't support it either
#define PS_SUPPORTS_MULTIPLE_PIDS
#include <set>
#endif
@@ -418,13 +419,15 @@ class ProcessMetricsCollector {
}
ConstIterator it;
- string pidsArg;
+ // The list of PIDs must follow -p without a space.
+ // https://groups.google.com/forum/#!topic/phusion-passenger/WKXy61nJBMA
+ string pidsArg = "-p";
for (it = pids.begin(); it != pids.end(); it++) {
pidsArg.append(toString(*it));
pidsArg.append(",");
}
- if (!pidsArg.empty() && pidsArg[pidsArg.size() - 1] == ',') {
+ if (pidsArg[pidsArg.size() - 1] == ',') {
pidsArg.resize(pidsArg.size() - 1);
}
@@ -436,7 +439,7 @@ class ProcessMetricsCollector {
"pid,ppid,%cpu,rss,vsize,pgid,command",
#endif
#ifdef PS_SUPPORTS_MULTIPLE_PIDS
- "-p", pidsArg.c_str(),
+ pidsArg.c_str(),
#endif
NULL
};

0 comments on commit 6b16991

Please sign in to comment.