diff --git a/lib/processes.js b/lib/processes.js index dacc7b3a..db6824d4 100644 --- a/lib/processes.js +++ b/lib/processes.js @@ -1005,7 +1005,7 @@ function processLoad(proc, callback) { let processes = processesString.split('|'); let result = []; - const procSanitized = util.isPrototypePolluted() ? '' : util.sanitizeShellString(proc); + const procSanitized = util.isPrototypePolluted() ? '' : (util.sanitizeShellString(proc) || '*'); // from here new // let result = { @@ -1149,12 +1149,14 @@ function processLoad(proc, callback) { }); return found; }); - + lines.shift(); lines.forEach(function (line) { let data = line.trim().replace(/ +/g, ' ').split(' '); if (data.length > 4) { + const linuxName = data[4].indexOf('/') >= 0 ? data[4].substring(0, data[4].indexOf('/') - 1) : data[4]; + const name = _linux ? (linuxName) : data[4].substring(data[4].lastIndexOf('/') + 1); procStats.push({ - name: data[4].substring(data[4].lastIndexOf('/') + 1), + name, pid: parseInt(data[0]) || 0, ppid: parseInt(data[1]) || 0, cpu: parseFloat(data[2].replace(',', '.')), @@ -1166,7 +1168,7 @@ function processLoad(proc, callback) { procStats.forEach(function (item) { let listPos = -1; let inList = false; - let name = ''; + let name = item.name; for (let j = 0; j < result.length; j++) { if (item.name.toLowerCase().indexOf(result[j].proc.toLowerCase()) >= 0) { listPos = j; @@ -1181,13 +1183,15 @@ function processLoad(proc, callback) { }); if ((processesString === '*') || inList) { if (listPos < 0) { - result.push({ - proc: name, - pid: item.pid, - pids: [item.pid], - cpu: item.cpu, - mem: item.mem - }); + if (name) { + result.push({ + proc: name, + pid: item.pid, + pids: [item.pid], + cpu: item.cpu, + mem: item.mem + }); + } } else { if (item.ppid < 10) { result[listPos].pid = item.pid;