systeminformation 6.0.0-beta.8 → 6.0.0-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/common/files.d.ts +8 -0
- package/dist/common/files.js +58 -3
- package/dist/common/nvidia.js +2 -1
- package/dist/common/parse.d.ts +4 -6
- package/dist/common/parse.js +24 -69
- package/dist/common/security.d.ts +1 -0
- package/dist/common/security.js +3 -1
- package/dist/common/types.d.ts +1 -2
- package/dist/cpu-current-load.js +5 -5
- package/dist/cpu-current-speed.js +5 -3
- package/dist/darwin/serial-ports.js +2 -1
- package/dist/linux/audio.js +11 -2
- package/dist/linux/baseboard.js +9 -20
- package/dist/linux/bios.js +6 -15
- package/dist/linux/camera.js +2 -1
- package/dist/linux/chassis.js +4 -10
- package/dist/linux/cpu-temperature.js +34 -19
- package/dist/linux/cpu.js +3 -1
- package/dist/linux/disk-layout.js +2 -5
- package/dist/linux/disks-io.js +6 -6
- package/dist/linux/fans.js +3 -2
- package/dist/linux/fs-size.js +120 -26
- package/dist/linux/fs-stats.js +6 -9
- package/dist/linux/gpu.js +2 -1
- package/dist/linux/mem-layout.js +2 -2
- package/dist/linux/network-interfaces.js +10 -29
- package/dist/linux/network-stats.js +1 -1
- package/dist/linux/npu.js +2 -1
- package/dist/linux/os-info.js +19 -4
- package/dist/linux/printer.js +4 -4
- package/dist/linux/process-load.js +9 -12
- package/dist/linux/processes.js +88 -79
- package/dist/linux/serial-ports.js +3 -2
- package/dist/linux/services.js +12 -12
- package/dist/linux/system.js +1 -7
- package/dist/linux/uuid.js +4 -10
- package/dist/windows/process-load.js +5 -4
- package/dist/windows/processes.js +10 -6
- package/package.json +1 -1
package/dist/linux/processes.js
CHANGED
|
@@ -36,71 +36,84 @@ const getName = (command) => {
|
|
|
36
36
|
}
|
|
37
37
|
return result;
|
|
38
38
|
};
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const checkColumn = (i) => {
|
|
46
|
-
offset = offset2;
|
|
47
|
-
if (parsedhead[i]) {
|
|
48
|
-
offset2 = line.substring(parsedhead[i].to + offset, 10000).indexOf(' ');
|
|
39
|
+
const splitPsLine = (line, count) => {
|
|
40
|
+
const fields = [];
|
|
41
|
+
let pos = 0;
|
|
42
|
+
while (fields.length < count) {
|
|
43
|
+
while (pos < line.length && line[pos] === ' ') {
|
|
44
|
+
pos++;
|
|
49
45
|
}
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
const start = pos;
|
|
47
|
+
while (pos < line.length && line[pos] !== ' ') {
|
|
48
|
+
pos++;
|
|
52
49
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const nice = (0, common_1.toInt)(line.substring(parsedhead[7].from + offset, parsedhead[7].to + offset2)) || 0;
|
|
70
|
-
checkColumn(8);
|
|
71
|
-
const started = !const_1.SUNOS
|
|
72
|
-
? (0, datetime_1.parseElapsedTime)(line.substring(parsedhead[8].from + offset, parsedhead[8].to + offset2).trim())
|
|
73
|
-
: (0, datetime_1.parseTimeUnix)(line.substring(parsedhead[8].from + offset, parsedhead[8].to + offset2).trim());
|
|
74
|
-
checkColumn(9);
|
|
75
|
-
let state = line.substring(parsedhead[9].from + offset, parsedhead[9].to + offset2).trim();
|
|
76
|
-
state =
|
|
77
|
-
state[0] === 'R'
|
|
78
|
-
? 'running'
|
|
79
|
-
: state[0] === 'S'
|
|
80
|
-
? 'sleeping'
|
|
81
|
-
: state[0] === 'T'
|
|
82
|
-
? 'stopped'
|
|
83
|
-
: state[0] === 'W'
|
|
84
|
-
? 'paging'
|
|
85
|
-
: state[0] === 'X'
|
|
86
|
-
? 'dead'
|
|
87
|
-
: state[0] === 'Z'
|
|
88
|
-
? 'zombie'
|
|
89
|
-
: state[0] === 'D' || state[0] === 'U'
|
|
90
|
-
? 'blocked'
|
|
91
|
-
: 'unknown';
|
|
92
|
-
checkColumn(10);
|
|
93
|
-
let tty = line.substring(parsedhead[10].from + offset, parsedhead[10].to + offset2).trim();
|
|
94
|
-
if (tty === '?' || tty === '??') {
|
|
95
|
-
tty = '';
|
|
50
|
+
if (pos === start) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
fields.push(line.substring(start, pos));
|
|
54
|
+
}
|
|
55
|
+
while (pos < line.length && line[pos] === ' ') {
|
|
56
|
+
pos++;
|
|
57
|
+
}
|
|
58
|
+
return { fields, rest: line.substring(pos) };
|
|
59
|
+
};
|
|
60
|
+
const parseCpuTime = (value) => {
|
|
61
|
+
const dayParts = value.split('-');
|
|
62
|
+
const days = dayParts.length > 1 ? (0, common_1.toInt)(dayParts[0]) : 0;
|
|
63
|
+
const parts = dayParts[dayParts.length - 1].split(':');
|
|
64
|
+
if (parts.length < 2 || parts.length > 3) {
|
|
65
|
+
return null;
|
|
96
66
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
67
|
+
const seconds = parseFloat(parts[parts.length - 1]);
|
|
68
|
+
if (Number.isNaN(seconds)) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
const minutes = (0, common_1.toInt)(parts[parts.length - 2]);
|
|
72
|
+
const hours = parts.length === 3 ? (0, common_1.toInt)(parts[0]) : 0;
|
|
73
|
+
return days * 86400 + hours * 3600 + minutes * 60 + seconds;
|
|
74
|
+
};
|
|
75
|
+
const parseLine = async (line) => {
|
|
76
|
+
const split = splitPsLine(line, 13);
|
|
77
|
+
if (!split) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
const [pidValue, ppidValue, cpuValue, memValue, priValue, vszValue, rssValue, niceValue, timeValue, stateValue, ttyValue, user] = split.fields;
|
|
81
|
+
const pid = (0, common_1.toInt)(pidValue);
|
|
82
|
+
if (!pid) {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
const ppid = (0, common_1.toInt)(ppidValue);
|
|
86
|
+
const cpu = parseFloat(cpuValue.replace(/,/g, '.'));
|
|
87
|
+
const mem = parseFloat(memValue.replace(/,/g, '.'));
|
|
88
|
+
const priority = (0, common_1.toInt)(priValue);
|
|
89
|
+
const vsz = (0, common_1.toInt)(vszValue);
|
|
90
|
+
const rss = (0, common_1.toInt)(rssValue);
|
|
91
|
+
const nice = (0, common_1.toInt)(niceValue) || 0;
|
|
92
|
+
const started = !const_1.SUNOS ? (0, datetime_1.parseElapsedTime)(timeValue) : (0, datetime_1.parseTimeUnix)(timeValue);
|
|
93
|
+
const state = stateValue[0] === 'R'
|
|
94
|
+
? 'running'
|
|
95
|
+
: stateValue[0] === 'S'
|
|
96
|
+
? 'sleeping'
|
|
97
|
+
: stateValue[0] === 'T'
|
|
98
|
+
? 'stopped'
|
|
99
|
+
: stateValue[0] === 'W'
|
|
100
|
+
? 'paging'
|
|
101
|
+
: stateValue[0] === 'X'
|
|
102
|
+
? 'dead'
|
|
103
|
+
: stateValue[0] === 'Z'
|
|
104
|
+
? 'zombie'
|
|
105
|
+
: stateValue[0] === 'D' || stateValue[0] === 'U'
|
|
106
|
+
? 'blocked'
|
|
107
|
+
: 'unknown';
|
|
108
|
+
const tty = ttyValue === '?' || ttyValue === '??' ? '' : ttyValue;
|
|
109
|
+
const cpuTime = parseCpuTime(split.fields[12]);
|
|
100
110
|
let cmdPath = '';
|
|
101
111
|
let command = '';
|
|
102
112
|
let params = '';
|
|
103
|
-
let fullcommand =
|
|
113
|
+
let fullcommand = split.rest.trim();
|
|
114
|
+
if (fullcommand.endsWith(' <defunct>')) {
|
|
115
|
+
fullcommand = fullcommand.slice(0, -10).trim();
|
|
116
|
+
}
|
|
104
117
|
if (fullcommand.endsWith(']')) {
|
|
105
118
|
fullcommand = fullcommand.slice(0, -1);
|
|
106
119
|
}
|
|
@@ -159,6 +172,7 @@ const parseLine = async (line, parsedhead) => {
|
|
|
159
172
|
cpu: cpu,
|
|
160
173
|
cpuu: 0,
|
|
161
174
|
cpus: 0,
|
|
175
|
+
cpuTime,
|
|
162
176
|
mem: mem,
|
|
163
177
|
priority: priority,
|
|
164
178
|
memVsz: vsz,
|
|
@@ -173,13 +187,13 @@ const parseLine = async (line, parsedhead) => {
|
|
|
173
187
|
path: cmdPath
|
|
174
188
|
};
|
|
175
189
|
};
|
|
176
|
-
const parseProcesses = async (lines
|
|
190
|
+
const parseProcesses = async (lines) => {
|
|
177
191
|
const result = [];
|
|
178
192
|
if (lines.length > 1) {
|
|
179
193
|
lines = lines.splice(1);
|
|
180
194
|
for (const line of lines) {
|
|
181
195
|
if (line.trim() !== '') {
|
|
182
|
-
const parsed = await parseLine(line
|
|
196
|
+
const parsed = await parseLine(line);
|
|
183
197
|
if (parsed) {
|
|
184
198
|
result.push(parsed);
|
|
185
199
|
}
|
|
@@ -252,6 +266,7 @@ const parseProcesses2 = (lines) => {
|
|
|
252
266
|
: 'unknown',
|
|
253
267
|
tty: parts[7],
|
|
254
268
|
user: parts[8],
|
|
269
|
+
cpuTime: null,
|
|
255
270
|
command: command,
|
|
256
271
|
params: '',
|
|
257
272
|
path: ''
|
|
@@ -268,42 +283,38 @@ const processes = async () => {
|
|
|
268
283
|
if ((_processes_cpu.ms && Date.now() - _processes_cpu.ms >= 500) || _processes_cpu.ms === 0) {
|
|
269
284
|
try {
|
|
270
285
|
if (const_1.LINUX || const_1.ANDROID) {
|
|
271
|
-
cmd = 'export LC_ALL=C; ps -axo pid:11,ppid:11,pcpu:6,pmem:6,pri:5,vsz:11,rss:11,ni:5,etime:30,state:5,tty:15,user:20,command; unset LC_ALL';
|
|
286
|
+
cmd = 'export LC_ALL=C; ps -axo pid:11,ppid:11,pcpu:6,pmem:6,pri:5,vsz:11,rss:11,ni:5,etime:30,state:5,tty:15,user:20,time,command; unset LC_ALL';
|
|
272
287
|
}
|
|
273
288
|
if (const_1.FREEBSD || const_1.NETBSD || const_1.OPENBSD) {
|
|
274
|
-
cmd = 'export LC_ALL=C; ps -axo pid,ppid,pcpu,pmem,pri,vsz,rss,ni,etime,state,tty,user,command; unset LC_ALL';
|
|
289
|
+
cmd = 'export LC_ALL=C; ps -axo pid,ppid,pcpu,pmem,pri,vsz,rss,ni,etime,state,tty,user,time,command; unset LC_ALL';
|
|
275
290
|
}
|
|
276
291
|
if (const_1.DARWIN) {
|
|
277
|
-
cmd = 'ps -axo pid,ppid,pcpu,pmem,pri,vsz=temp_title_1,rss=temp_title_2,nice,etime=temp_title_3,state,tty,user,command -r';
|
|
292
|
+
cmd = 'ps -axo pid,ppid,pcpu,pmem,pri,vsz=temp_title_1,rss=temp_title_2,nice,etime=temp_title_3,state,tty,user,time,command -r';
|
|
278
293
|
}
|
|
279
294
|
if (const_1.SUNOS) {
|
|
280
|
-
cmd = 'ps -Ao pid,ppid,pcpu,pmem,pri,vsz,rss,nice,stime,s,tty,user,comm';
|
|
295
|
+
cmd = 'ps -Ao pid,ppid,pcpu,pmem,pri,vsz,rss,nice,stime,s,tty,user,time,comm';
|
|
281
296
|
}
|
|
282
297
|
({ stdout } = await (0, exec_1.exec)(cmd, const_1.execOptsLinux));
|
|
283
298
|
if (stdout.trim()) {
|
|
284
299
|
const lines = stdout.split('\n');
|
|
285
|
-
|
|
286
|
-
result.list = (await parseProcesses(lines, parsedhead)).slice();
|
|
300
|
+
result.list = (await parseProcesses(lines)).slice();
|
|
287
301
|
result.all = result.list.length;
|
|
288
302
|
result.running = result.list.filter((e) => e.state === 'running').length;
|
|
289
303
|
result.blocked = result.list.filter((e) => e.state === 'blocked').length;
|
|
290
304
|
result.sleeping = result.list.filter((e) => e.state === 'sleeping').length;
|
|
291
305
|
if (const_1.LINUX) {
|
|
292
|
-
|
|
293
|
-
result.list.
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
({ stdout } = await (0, exec_1.execSave)(cmd, const_1.execOptsLinux));
|
|
297
|
-
let curr_processes = stdout.toString().split('\n');
|
|
298
|
-
const all = (0, parse_1.parseProcStat)(curr_processes[0]);
|
|
299
|
-
curr_processes = curr_processes.slice(1);
|
|
306
|
+
const cpuBaseline = { ..._processes_cpu };
|
|
307
|
+
const stats = await (0, files_1.readProcStats)(result.list.map((element) => element.pid));
|
|
308
|
+
const all = (0, parse_1.parseProcStat)(stats.all);
|
|
309
|
+
const curr_processes = stats.procs;
|
|
300
310
|
const list_new = {};
|
|
301
311
|
curr_processes.forEach((element) => {
|
|
302
|
-
const resultProcess = (0, parse_1.calcProcStatLinux)(element, all,
|
|
312
|
+
const resultProcess = (0, parse_1.calcProcStatLinux)(element, all, cpuBaseline);
|
|
303
313
|
if (resultProcess.pid) {
|
|
304
314
|
const listPos = result.list.map((e) => e.pid).indexOf(resultProcess.pid);
|
|
305
315
|
if (listPos >= 0) {
|
|
306
316
|
result.list[listPos].cpu = resultProcess.cpuu + resultProcess.cpus;
|
|
317
|
+
result.list[listPos].cpuTime = (resultProcess.utime + resultProcess.stime) / 100;
|
|
307
318
|
result.list[listPos].cpuu = resultProcess.cpuu;
|
|
308
319
|
result.list[listPos].cpus = resultProcess.cpus;
|
|
309
320
|
}
|
|
@@ -311,9 +322,7 @@ const processes = async () => {
|
|
|
311
322
|
cpuu: resultProcess.cpuu,
|
|
312
323
|
cpus: resultProcess.cpus,
|
|
313
324
|
utime: resultProcess.utime,
|
|
314
|
-
stime: resultProcess.stime
|
|
315
|
-
cutime: resultProcess.cutime,
|
|
316
|
-
cstime: resultProcess.cstime
|
|
325
|
+
stime: resultProcess.stime
|
|
317
326
|
};
|
|
318
327
|
}
|
|
319
328
|
});
|
|
@@ -6,6 +6,7 @@ const path_1 = require("path");
|
|
|
6
6
|
const common_1 = require("../common");
|
|
7
7
|
const defaults_1 = require("../common/defaults");
|
|
8
8
|
const files_1 = require("../common/files");
|
|
9
|
+
const security_1 = require("../common/security");
|
|
9
10
|
const busType = (subsystem, name) => {
|
|
10
11
|
switch (subsystem) {
|
|
11
12
|
case 'usb':
|
|
@@ -41,7 +42,7 @@ const usbDevicePath = async (devicePath) => {
|
|
|
41
42
|
const stableIds = async (path) => {
|
|
42
43
|
const map = {};
|
|
43
44
|
try {
|
|
44
|
-
for (const entry of await (0, promises_1.readdir)(path)) {
|
|
45
|
+
for (const entry of (await (0, promises_1.readdir)(path)).filter(security_1.isSafePathSegment)) {
|
|
45
46
|
try {
|
|
46
47
|
map[(0, path_1.basename)(await (0, promises_1.readlink)(`${path}/${entry}`))] = entry;
|
|
47
48
|
}
|
|
@@ -56,7 +57,7 @@ const serialPorts = async (sysPath = '/sys/class/tty', byIdPath = '/dev/serial/b
|
|
|
56
57
|
const result = [];
|
|
57
58
|
let names = [];
|
|
58
59
|
try {
|
|
59
|
-
names = await (0, promises_1.readdir)(sysPath);
|
|
60
|
+
names = (await (0, promises_1.readdir)(sysPath)).filter(security_1.isSafePathSegment);
|
|
60
61
|
}
|
|
61
62
|
catch {
|
|
62
63
|
return result;
|
package/dist/linux/services.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.services = void 0;
|
|
|
4
4
|
const common_1 = require("../common");
|
|
5
5
|
const const_1 = require("../common/const");
|
|
6
6
|
const exec_1 = require("../common/exec");
|
|
7
|
+
const files_1 = require("../common/files");
|
|
7
8
|
const parse_1 = require("../common/parse");
|
|
8
9
|
const security_1 = require("../common/security");
|
|
9
10
|
const _services_cpu = {
|
|
@@ -83,19 +84,20 @@ const darwinGetServices = async () => {
|
|
|
83
84
|
return srvs;
|
|
84
85
|
};
|
|
85
86
|
const calcServicesCpuLinux = async (result) => {
|
|
86
|
-
|
|
87
|
+
result.forEach((item) => {
|
|
88
|
+
item.cpu = 0;
|
|
89
|
+
});
|
|
90
|
+
const pids = [];
|
|
87
91
|
for (const i in result) {
|
|
88
|
-
|
|
89
|
-
cmd += ';cat /proc/' + result[i].pids[j] + '/stat';
|
|
90
|
-
}
|
|
92
|
+
pids.push(...result[i].pids);
|
|
91
93
|
}
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
const all = (0, parse_1.parseProcStat)(
|
|
95
|
-
curr_processes =
|
|
94
|
+
const cpuBaseline = { ..._services_cpu };
|
|
95
|
+
const stats = await (0, files_1.readProcStats)(pids);
|
|
96
|
+
const all = (0, parse_1.parseProcStat)(stats.all);
|
|
97
|
+
const curr_processes = stats.procs;
|
|
96
98
|
const list_new = {};
|
|
97
99
|
curr_processes.forEach((element) => {
|
|
98
|
-
const resultProcess = (0, parse_1.calcProcStatLinux)(element, all,
|
|
100
|
+
const resultProcess = (0, parse_1.calcProcStatLinux)(element, all, cpuBaseline);
|
|
99
101
|
if (resultProcess.pid) {
|
|
100
102
|
let listPos = -1;
|
|
101
103
|
for (let i = 0; i < result.length; i++) {
|
|
@@ -112,9 +114,7 @@ const calcServicesCpuLinux = async (result) => {
|
|
|
112
114
|
cpuu: resultProcess.cpuu,
|
|
113
115
|
cpus: resultProcess.cpus,
|
|
114
116
|
utime: resultProcess.utime,
|
|
115
|
-
stime: resultProcess.stime
|
|
116
|
-
cutime: resultProcess.cutime,
|
|
117
|
-
cstime: resultProcess.cstime
|
|
117
|
+
stime: resultProcess.stime
|
|
118
118
|
};
|
|
119
119
|
}
|
|
120
120
|
});
|
package/dist/linux/system.js
CHANGED
|
@@ -21,14 +21,8 @@ const system = async () => {
|
|
|
21
21
|
result.serial = (0, common_1.getValue)(lines, 'serial number');
|
|
22
22
|
result.uuid = (0, common_1.getValue)(lines, 'uuid').toLowerCase();
|
|
23
23
|
result.sku = (0, common_1.getValue)(lines, 'sku number');
|
|
24
|
-
const cmd = `echo -n "product_name: "; cat /sys/devices/virtual/dmi/id/product_name 2>/dev/null; echo;
|
|
25
|
-
echo -n "product_serial: "; cat /sys/devices/virtual/dmi/id/product_serial 2>/dev/null; echo;
|
|
26
|
-
echo -n "product_uuid: "; cat /sys/devices/virtual/dmi/id/product_uuid 2>/dev/null; echo;
|
|
27
|
-
echo -n "product_version: "; cat /sys/devices/virtual/dmi/id/product_version 2>/dev/null; echo;
|
|
28
|
-
echo -n "sys_vendor: "; cat /sys/devices/virtual/dmi/id/sys_vendor 2>/dev/null; echo;`;
|
|
29
24
|
try {
|
|
30
|
-
|
|
31
|
-
lines = stdout.split('\n');
|
|
25
|
+
lines = await (0, files_1.readSysfsMany)(files_1.DMI_PATH, ['product_name', 'product_serial', 'product_uuid', 'product_version', 'sys_vendor']);
|
|
32
26
|
result.manufacturer = result.manufacturer === '' ? (0, common_1.getValue)(lines, 'sys_vendor') : result.manufacturer;
|
|
33
27
|
result.model = result.model === '' ? (0, common_1.getValue)(lines, 'product_name') : result.model;
|
|
34
28
|
result.version = result.version === '' ? (0, common_1.getValue)(lines, 'product_version') : result.version;
|
package/dist/linux/uuid.js
CHANGED
|
@@ -4,21 +4,15 @@ exports.uuid = void 0;
|
|
|
4
4
|
const promises_1 = require("fs/promises");
|
|
5
5
|
const common_1 = require("../common");
|
|
6
6
|
const defaults_1 = require("../common/defaults");
|
|
7
|
-
const
|
|
7
|
+
const files_1 = require("../common/files");
|
|
8
8
|
const disk_layout_1 = require("./disk-layout");
|
|
9
9
|
const uuid = async () => {
|
|
10
10
|
await (0, common_1.nextTick)();
|
|
11
11
|
const defaults = defaults_1.initUUID;
|
|
12
12
|
try {
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
echo -n "systemuuid: "; cat /sys/devices/virtual/dmi/id/product_uuid 2>/dev/null; echo;`;
|
|
17
|
-
const { stdout } = await (0, exec_1.execSave)(cmd);
|
|
18
|
-
const lines = stdout.toString().split('\n');
|
|
19
|
-
const os = (0, common_1.getValue)(lines, 'os').toLowerCase();
|
|
20
|
-
let hardware = (0, common_1.getValue)(lines, 'hardware').toLowerCase();
|
|
21
|
-
const systemuuid = (0, common_1.getValue)(lines, 'systemuuid').toLowerCase();
|
|
13
|
+
const os = ((await (0, files_1.readSysfs)('/var/lib/dbus/machine-id')) || (await (0, files_1.readSysfs)('/etc/machine-id'))).toLowerCase();
|
|
14
|
+
let hardware = (await (0, files_1.readSysfs)('/sys/class/dmi/id/product_uuid')).toLowerCase();
|
|
15
|
+
const systemuuid = (await (0, files_1.readSysfs)(`${files_1.DMI_PATH}/product_uuid`)).toLowerCase();
|
|
22
16
|
if (!hardware) {
|
|
23
17
|
const lines = (await (0, promises_1.readFile)('/proc/cpuinfo')).toString().split('\n');
|
|
24
18
|
const serial = (0, common_1.getValue)(lines, 'serial');
|
|
@@ -20,19 +20,20 @@ const processLoad = async (proc) => {
|
|
|
20
20
|
if (!(0, security_1.isPrototypePolluted)()) {
|
|
21
21
|
const processes = (0, security_1.sanitizeServiceString)(proc);
|
|
22
22
|
if (processes.length) {
|
|
23
|
+
const cpuBaseline = { ..._process_cpu };
|
|
23
24
|
try {
|
|
24
25
|
const processArray = (0, windows_1.psArray)(await windows_1.ps.exec('Get-CimInstance Win32_Process | select ProcessId,Caption,UserModeTime,KernelModeTime,WorkingSetSize | ConvertTo-Json -compress'));
|
|
25
26
|
const procStats = [];
|
|
26
27
|
const list_new = {};
|
|
27
|
-
let allcpuu =
|
|
28
|
-
let allcpus =
|
|
28
|
+
let allcpuu = cpuBaseline.all_utime;
|
|
29
|
+
let allcpus = cpuBaseline.all_stime;
|
|
29
30
|
processArray.forEach((element) => {
|
|
30
31
|
const pid = element.ProcessId;
|
|
31
32
|
const name = element.Caption;
|
|
32
33
|
const utime = element.UserModeTime;
|
|
33
34
|
const stime = element.KernelModeTime;
|
|
34
35
|
const mem = element.WorkingSetSize;
|
|
35
|
-
const cpuOld =
|
|
36
|
+
const cpuOld = cpuBaseline.list[pid];
|
|
36
37
|
allcpuu += utime - (cpuOld ? cpuOld.utime : 0);
|
|
37
38
|
allcpus += stime - (cpuOld ? cpuOld.stime : 0);
|
|
38
39
|
procStats.push({
|
|
@@ -90,7 +91,7 @@ const processLoad = async (proc) => {
|
|
|
90
91
|
});
|
|
91
92
|
}
|
|
92
93
|
procStats.forEach((element) => {
|
|
93
|
-
const resultProcess = (0, processes_1.calcProcStatWin)(element, allcpuu + allcpus,
|
|
94
|
+
const resultProcess = (0, processes_1.calcProcStatWin)(element, allcpuu + allcpus, cpuBaseline);
|
|
94
95
|
let listPos = -1;
|
|
95
96
|
for (let j = 0; j < result.length; j++) {
|
|
96
97
|
if (result[j].pid === resultProcess.pid || result[j].pids.indexOf(resultProcess.pid) >= 0) {
|
|
@@ -6,6 +6,7 @@ const common_1 = require("../common");
|
|
|
6
6
|
const defaults_1 = require("../common/defaults");
|
|
7
7
|
const mappings_1 = require("../common/mappings");
|
|
8
8
|
const windows_1 = require("../common/windows");
|
|
9
|
+
const parse_1 = require("../common/parse");
|
|
9
10
|
const _processes_cpu = {
|
|
10
11
|
all: 0,
|
|
11
12
|
all_utime: 0,
|
|
@@ -26,12 +27,13 @@ const calcProcStatWin = (procStat, all, _cpu_old) => {
|
|
|
26
27
|
cpuu = all > 0 ? (procStat.utime / all) * 100 : 0;
|
|
27
28
|
cpus = all > 0 ? (procStat.stime / all) * 100 : 0;
|
|
28
29
|
}
|
|
30
|
+
const clamped = (0, parse_1.clampCpuPair)(cpuu, cpus);
|
|
29
31
|
return {
|
|
30
32
|
pid: procStat.pid,
|
|
31
33
|
utime: procStat.utime,
|
|
32
34
|
stime: procStat.stime,
|
|
33
|
-
cpuu: cpuu
|
|
34
|
-
cpus: cpus
|
|
35
|
+
cpuu: clamped.cpuu,
|
|
36
|
+
cpus: clamped.cpus
|
|
35
37
|
};
|
|
36
38
|
};
|
|
37
39
|
exports.calcProcStatWin = calcProcStatWin;
|
|
@@ -39,6 +41,7 @@ const processes = async () => {
|
|
|
39
41
|
await (0, common_1.nextTick)();
|
|
40
42
|
const result = (0, common_1.cloneObj)(defaults_1.initProcesses);
|
|
41
43
|
if ((_processes_cpu.ms && Date.now() - _processes_cpu.ms >= 500) || _processes_cpu.ms === 0) {
|
|
44
|
+
const cpuBaseline = { ..._processes_cpu };
|
|
42
45
|
try {
|
|
43
46
|
const processArray = (0, windows_1.psArray)(await windows_1.ps.exec(`Get-CimInstance Win32_Process | select-Object ProcessId,ParentProcessId,ExecutionState,Caption,CommandLine,ExecutablePath,UserModeTime,KernelModeTime,WorkingSetSize,Priority,PageFileUsage,
|
|
44
47
|
@{n="CreationDate";e={$_.CreationDate.ToString("yyyy-MM-dd HH:mm:ss")}} | ConvertTo-Json -compress`));
|
|
@@ -46,8 +49,8 @@ const processes = async () => {
|
|
|
46
49
|
const procs = [];
|
|
47
50
|
const procStats = [];
|
|
48
51
|
const list_new = {};
|
|
49
|
-
let allcpuu =
|
|
50
|
-
let allcpus =
|
|
52
|
+
let allcpuu = cpuBaseline.all_utime;
|
|
53
|
+
let allcpus = cpuBaseline.all_stime;
|
|
51
54
|
processArray.forEach((element) => {
|
|
52
55
|
const pid = element.ProcessId;
|
|
53
56
|
const parentPid = element.ParentProcessId;
|
|
@@ -58,7 +61,7 @@ const processes = async () => {
|
|
|
58
61
|
const utime = element.UserModeTime;
|
|
59
62
|
const stime = element.KernelModeTime;
|
|
60
63
|
const memw = element.WorkingSetSize;
|
|
61
|
-
const cpuOld =
|
|
64
|
+
const cpuOld = cpuBaseline.list[pid];
|
|
62
65
|
allcpuu += utime - (cpuOld ? cpuOld.utime : 0);
|
|
63
66
|
allcpus += stime - (cpuOld ? cpuOld.stime : 0);
|
|
64
67
|
result.all++;
|
|
@@ -87,6 +90,7 @@ const processes = async () => {
|
|
|
87
90
|
cpu: 0,
|
|
88
91
|
cpuu: 0,
|
|
89
92
|
cpus: 0,
|
|
93
|
+
cpuTime: (utime + stime) / 1e7,
|
|
90
94
|
mem: (memw / (0, node_os_1.totalmem)()) * 100,
|
|
91
95
|
priority: element.Priority || 0,
|
|
92
96
|
memVsz: element.PageFileUsage || null,
|
|
@@ -104,7 +108,7 @@ const processes = async () => {
|
|
|
104
108
|
result.sleeping = result.all - result.running - result.blocked - result.unknown;
|
|
105
109
|
result.list = procs;
|
|
106
110
|
procStats.forEach((element) => {
|
|
107
|
-
const resultProcess = (0, exports.calcProcStatWin)(element, allcpuu + allcpus,
|
|
111
|
+
const resultProcess = (0, exports.calcProcStatWin)(element, allcpuu + allcpus, cpuBaseline);
|
|
108
112
|
const listPos = result.list
|
|
109
113
|
.map((e) => {
|
|
110
114
|
return e.pid;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "systeminformation",
|
|
3
|
-
"version": "6.0.0-beta.
|
|
3
|
+
"version": "6.0.0-beta.9",
|
|
4
4
|
"description": "Advanced, lightweight system and OS information library",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Sebastian Hildebrandt <hildebrandt@plus-innovations.com> (https://plus-innovations.com)",
|