processes() fix calculation (windows)

This commit is contained in:
Sebastian Hildebrandt
2022-01-19 16:50:12 +01:00
parent 4e580fac16
commit 75fb6e7525
5 changed files with 16 additions and 10 deletions
+6 -6
View File
@@ -324,13 +324,13 @@ function services(srv, callback) {
}
if (_windows) {
try {
let wincommand = "Get-WmiObject Win32_Service";
let wincommand = 'Get-WmiObject Win32_Service';
if (srvs[0] !== '*') {
wincommand += ' -Filter "';
for (let i = 0; i < srvs.length; i++) {
wincommand += `Name='${srvs[i]}' or `;
}
wincommand = `${wincommand.slice(0,-4)}"`;
wincommand = `${wincommand.slice(0, -4)}"`;
}
wincommand += ' | fl *';
util.powerShell(wincommand).then((stdout, error) => {
@@ -817,8 +817,8 @@ function processes(callback) {
let utime = parseInt(util.getValue(lines, 'UserModeTime', ':', true), 10);
let stime = parseInt(util.getValue(lines, 'KernelModeTime', ':', true), 10);
let memw = parseInt(util.getValue(lines, 'WorkingSetSize', ':', true), 10);
allcpuu = allcpuu + utime;
allcpus = allcpus + stime;
allcpuu += utime - (_processes_cpu.list[pid] ? _processes_cpu.list[pid].utime : 0);
allcpus += stime - (_processes_cpu.list[pid] ? _processes_cpu.list[pid].stime : 0);
result.all++;
if (!statusValue) { result.unknown++; }
if (statusValue === '3') { result.running++; }
@@ -982,8 +982,8 @@ function processLoad(proc, callback) {
let utime = parseInt(util.getValue(lines, 'UserModeTime', ':', true), 10);
let stime = parseInt(util.getValue(lines, 'KernelModeTime', ':', true), 10);
let mem = parseInt(util.getValue(lines, 'WorkingSetSize', ':', true), 10);
allcpuu = allcpuu + utime;
allcpus = allcpus + stime;
allcpuu += utime - (_process_cpu.list[pid] ? _process_cpu.list[pid].utime : 0);
allcpus += stime - (_process_cpu.list[pid] ? _process_cpu.list[pid].stime : 0);
procStats.push({
pid: pid,