Skip to content

Commit

Permalink
Merge pull request #3725 from soyuka/fix-list
Browse files Browse the repository at this point in the history
Fix pm2 list cpu display
  • Loading branch information
wallet77 authored Jun 19, 2018
2 parents 8545826 + 623eb78 commit a39eb4f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions lib/API.js
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ class API {
return false;
}

return cb ? cb(null, list) : that.speedList();
return cb ? cb(null, list) : that.speedList(null, list);
});
}

Expand Down Expand Up @@ -1467,13 +1467,19 @@ class API {
* @method speedList
* @return
*/
speedList (code) {
speedList (code, list) {
var that = this;

// Do nothing if PM2 called programmatically and not called from CLI (also in exitCli)
if (conf.PM2_PROGRAMMATIC && process.env.PM2_USAGE != 'CLI') return false;

that.Client.executeRemote('getMonitorData', {}, function(err, list) {
if (list) {
return doList(null, list)
}

that.Client.executeRemote('getMonitorData', {}, doList);

function doList(err, list) {
if (err) {
if (gl_retry == 0) {
gl_retry += 1;
Expand Down Expand Up @@ -1510,7 +1516,7 @@ class API {
else {
return that.exitCli(code ? code : conf.SUCCESS_EXIT);
}
});
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/API/CliUx.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ UX.dispAsTable = function(list, commander) {
obj[key].push((l.pm2_env.pm_uptime && status == 'online') ? timeSince(l.pm2_env.pm_uptime) : 0);

// CPU
obj[key].push(l.monit ? l.monit.cpu + '%' : 'N/A');
obj[key].push(l.monit ? l.monit.cpu.toFixed(2) + '%' : 'N/A');

// Memory
obj[key].push(l.monit ? UX.bytesToSize(l.monit.memory, 1) : 'N/A');
Expand Down

0 comments on commit a39eb4f

Please sign in to comment.