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);
} catch {}
processArray.forEach((element) => {
if (element.trim() !== '') {
const pid = element.ProcessId;
const parentPid = element.ParentProcessId;
const statusValue = element.ExecutionState || null;
const name = element.Caption;
const commandLine = element.CommandLine;
// get additional command line data
const commandPath = element.ExecutablePath;
const utime = element.UserModeTime;
const stime = element.KernelModeTime;
const memw = element.WorkingSetSize;
allcpuu = allcpuu + utime;
allcpus = allcpus + stime;
result.all++;
if (!statusValue) {
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: ''
});
const pid = element.ProcessId;
const parentPid = element.ParentProcessId;
const statusValue = element.ExecutionState || null;
const name = element.Caption;
const commandLine = element.CommandLine;
// get additional command line data
const commandPath = element.ExecutablePath;
const utime = element.UserModeTime;
const stime = element.KernelModeTime;
const memw = element.WorkingSetSize;
allcpuu = allcpuu + utime;
allcpus = allcpus + stime;
result.all++;
if (!statusValue) {
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: ''
});
});
result.sleeping = result.all - result.running - result.blocked - result.unknown;