forked from noahpeters/overlook
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocesses.js
More file actions
19 lines (19 loc) · 692 Bytes
/
Copy pathprocesses.js
File metadata and controls
19 lines (19 loc) · 692 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
var exec = require('child_process').exec;
var processes = function (callback) {
exec('ps -x -o pid= -o command= | sed -e "s/^[ \t]*//"', function(err, stdout, stderr) {
// stdout is a string containing the output of the command.
// parse it and look for the apache and mysql processes.
//callback(err, stdout, stderr);
var pl = stdout;
var procs = pl.split("\n");
var obj = { };
procs.forEach(function (proc) {
var cols = proc.split(" ");
obj[cols.shift()] = cols.join(" ");
});
if (typeof callback === "function") {
callback(obj);
}
});
};
module.exports = processes;