processes() fix command line parsing (win) wip

This commit is contained in:
Sebastian Hildebrandt 2025-12-27 14:34:06 +01:00
parent 1512eabec1
commit f6acf2e30e

View File

@ -949,59 +949,57 @@ function processes(callback) {
processArray = JSON.parse(stdout); processArray = JSON.parse(stdout);
} catch {} } catch {}
processArray.forEach((element) => { processArray.forEach((element) => {
if (element.trim() !== '') { const pid = element.ProcessId;
const pid = element.ProcessId; const parentPid = element.ParentProcessId;
const parentPid = element.ParentProcessId; const statusValue = element.ExecutionState || null;
const statusValue = element.ExecutionState || null; const name = element.Caption;
const name = element.Caption; const commandLine = element.CommandLine;
const commandLine = element.CommandLine; // get additional command line data
// get additional command line data const commandPath = element.ExecutablePath;
const commandPath = element.ExecutablePath; const utime = element.UserModeTime;
const utime = element.UserModeTime; const stime = element.KernelModeTime;
const stime = element.KernelModeTime; const memw = element.WorkingSetSize;
const memw = element.WorkingSetSize; allcpuu = allcpuu + utime;
allcpuu = allcpuu + utime; allcpus = allcpus + stime;
allcpus = allcpus + stime; result.all++;
result.all++; if (!statusValue) {
if (!statusValue) { result.unknown++;
result.unknown++;
}
if (statusValue === '3') {
result.running++;
}
if (statusValue === '4' || statusValue === '5') {
result.blocked++;
}
procStats.push({
pid: pid,
utime: utime,
stime: stime,
cpu: 0,
cpuu: 0,
cpus: 0
});
procs.push({
pid: pid,
parentPid: parentPid,
name: name,
cpu: 0,
cpuu: 0,
cpus: 0,
mem: (memw / os.totalmem()) * 100,
priority: element.Priority | null,
memVsz: element.PageFileUsage || null,
memRss: Math.floor((element.WorkingSetSize || 0) / 1024),
nice: 0,
started: element.CreationDate,
state: statusValue ? _winStatusValues[statusValue] : _winStatusValues[0],
tty: '',
user: '',
command: commandLine || name,
path: commandPath,
params: ''
});
} }
if (statusValue === '3') {
result.running++;
}
if (statusValue === '4' || statusValue === '5') {
result.blocked++;
}
procStats.push({
pid: pid,
utime: utime,
stime: stime,
cpu: 0,
cpuu: 0,
cpus: 0
});
procs.push({
pid: pid,
parentPid: parentPid,
name: name,
cpu: 0,
cpuu: 0,
cpus: 0,
mem: (memw / os.totalmem()) * 100,
priority: element.Priority | null,
memVsz: element.PageFileUsage || null,
memRss: Math.floor((element.WorkingSetSize || 0) / 1024),
nice: 0,
started: element.CreationDate,
state: statusValue ? _winStatusValues[statusValue] : _winStatusValues[0],
tty: '',
user: '',
command: commandLine || name,
path: commandPath,
params: ''
});
}); });
result.sleeping = result.all - result.running - result.blocked - result.unknown; result.sleeping = result.all - result.running - result.blocked - result.unknown;