systeminformation 6.0.0-beta.1 → 6.0.0-beta.11
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 +41 -7
- package/dist/bsd/network-stats.js +2 -2
- package/dist/common/darwin.d.ts +2 -0
- package/dist/common/darwin.js +17 -1
- package/dist/common/defaults.d.ts +2 -1
- package/dist/common/defaults.js +21 -5
- package/dist/common/exec.js +1 -1
- package/dist/common/files.d.ts +9 -0
- package/dist/common/files.js +67 -3
- package/dist/common/filesys.d.ts +10 -0
- package/dist/common/filesys.js +41 -10
- package/dist/common/host.js +55 -3
- package/dist/common/mappings.js +2 -1
- package/dist/common/network.js +4 -4
- package/dist/common/nvidia.d.ts +1 -1
- package/dist/common/nvidia.js +4 -5
- 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 +33 -5
- package/dist/cpu-current-load.js +28 -6
- package/dist/cpu-current-speed.js +5 -3
- package/dist/darwin/battery.d.ts +1 -1
- package/dist/darwin/battery.js +15 -5
- package/dist/darwin/camera.js +3 -3
- package/dist/darwin/disk-layout.js +16 -12
- package/dist/darwin/disks-io.js +3 -3
- package/dist/darwin/displays.js +34 -1
- package/dist/darwin/fans.d.ts +2 -0
- package/dist/darwin/fans.js +28 -0
- package/dist/darwin/gpu.js +1 -1
- package/dist/darwin/index.d.ts +2 -0
- package/dist/darwin/index.js +6 -2
- package/dist/darwin/keyboard.js +4 -4
- package/dist/darwin/mouse.js +4 -4
- package/dist/darwin/network-interfaces.js +5 -10
- package/dist/darwin/network-stats.js +5 -5
- package/dist/darwin/serial-ports.d.ts +2 -0
- package/dist/darwin/serial-ports.js +94 -0
- package/dist/fans.d.ts +1 -0
- package/dist/fans.js +17 -0
- package/dist/get-data.d.ts +4 -0
- package/dist/get-data.js +6 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +6 -2
- package/dist/linux/audio.js +59 -0
- 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 +7 -10
- package/dist/linux/disks-io.js +9 -9
- package/dist/linux/displays.js +40 -2
- package/dist/linux/fans.d.ts +2 -0
- package/dist/linux/fans.js +92 -0
- package/dist/linux/fs-size.js +160 -34
- package/dist/linux/fs-stats.js +6 -9
- package/dist/linux/gpu.js +15 -15
- package/dist/linux/index.d.ts +2 -0
- package/dist/linux/index.js +6 -2
- package/dist/linux/mem-layout.js +2 -2
- package/dist/linux/network-interfaces.js +36 -39
- package/dist/linux/network-stats.js +8 -36
- 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 +89 -80
- package/dist/linux/serial-ports.d.ts +2 -0
- package/dist/linux/serial-ports.js +102 -0
- package/dist/linux/services.js +179 -47
- package/dist/linux/system.js +1 -7
- package/dist/linux/uuid.js +4 -10
- package/dist/serial-ports.d.ts +1 -0
- package/dist/serial-ports.js +17 -0
- package/dist/versions.js +32 -77
- package/dist/windows/disk-layout.js +3 -0
- package/dist/windows/disks-io.js +3 -3
- package/dist/windows/displays.js +43 -12
- package/dist/windows/fans.d.ts +2 -0
- package/dist/windows/fans.js +71 -0
- package/dist/windows/index.d.ts +2 -0
- package/dist/windows/index.js +6 -2
- package/dist/windows/network-interfaces.js +20 -29
- package/dist/windows/network-stats.js +4 -2
- package/dist/windows/process-load.js +7 -5
- package/dist/windows/processes.js +17 -11
- package/dist/windows/serial-ports.d.ts +3 -0
- package/dist/windows/serial-ports.js +73 -0
- package/dist/windows/services.js +3 -0
- package/package.json +1 -1
package/dist/common/parse.js
CHANGED
|
@@ -1,63 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.splitByNumber = exports.kFactor = exports.cleanDefaults = exports.parseJsonArray = exports.calcProcStatLinux = exports.
|
|
3
|
+
exports.splitByNumber = exports.kFactor = exports.cleanDefaults = exports.parseJsonArray = exports.calcProcStatLinux = exports.clampCpuPair = exports.parseProcStat = void 0;
|
|
4
4
|
const index_1 = require("./index");
|
|
5
|
-
const parseHead = (head, rights) => {
|
|
6
|
-
let space = rights > 0;
|
|
7
|
-
let count = 1;
|
|
8
|
-
let from = 0;
|
|
9
|
-
let to = 0;
|
|
10
|
-
const result = [];
|
|
11
|
-
for (let i = 0; i < head.length; i++) {
|
|
12
|
-
if (count <= rights) {
|
|
13
|
-
if (/\s/.test(head[i]) && !space) {
|
|
14
|
-
to = i - 1;
|
|
15
|
-
result.push({
|
|
16
|
-
from: from,
|
|
17
|
-
to: to + 1,
|
|
18
|
-
cap: head.substring(from, to + 1)
|
|
19
|
-
});
|
|
20
|
-
from = to + 2;
|
|
21
|
-
count++;
|
|
22
|
-
}
|
|
23
|
-
space = head[i] === ' ';
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
if (!/\s/.test(head[i]) && space) {
|
|
27
|
-
to = i - 1;
|
|
28
|
-
if (from < to) {
|
|
29
|
-
result.push({
|
|
30
|
-
from: from,
|
|
31
|
-
to: to,
|
|
32
|
-
cap: head.substring(from, to)
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
from = to + 1;
|
|
36
|
-
count++;
|
|
37
|
-
}
|
|
38
|
-
space = head[i] === ' ';
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
to = 5000;
|
|
42
|
-
result.push({
|
|
43
|
-
from: from,
|
|
44
|
-
to: to,
|
|
45
|
-
cap: head.substring(from, to)
|
|
46
|
-
});
|
|
47
|
-
let len = result.length;
|
|
48
|
-
for (let i = 0; i < len; i++) {
|
|
49
|
-
if (result[i].cap.replace(/\s/g, '').length === 0) {
|
|
50
|
-
if (i + 1 < len) {
|
|
51
|
-
result[i].to = result[i + 1].to;
|
|
52
|
-
result[i].cap = result[i].cap + result[i + 1].cap;
|
|
53
|
-
result.splice(i + 1, 1);
|
|
54
|
-
len = len - 1;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return result;
|
|
59
|
-
};
|
|
60
|
-
exports.parseHead = parseHead;
|
|
61
5
|
const parseProcStat = (line) => {
|
|
62
6
|
const parts = line.replace(/ +/g, ' ').split(' ');
|
|
63
7
|
const user = parts.length >= 2 ? (0, index_1.toInt)(parts[1]) : 0;
|
|
@@ -73,6 +17,21 @@ const parseProcStat = (line) => {
|
|
|
73
17
|
return user + nice + system + idle + iowait + irq + softirq + steal + guest + guest_nice;
|
|
74
18
|
};
|
|
75
19
|
exports.parseProcStat = parseProcStat;
|
|
20
|
+
const clampCpuPair = (cpuu, cpus) => {
|
|
21
|
+
if (!Number.isFinite(cpuu) || cpuu < 0) {
|
|
22
|
+
cpuu = 0;
|
|
23
|
+
}
|
|
24
|
+
if (!Number.isFinite(cpus) || cpus < 0) {
|
|
25
|
+
cpus = 0;
|
|
26
|
+
}
|
|
27
|
+
const total = cpuu + cpus;
|
|
28
|
+
if (total > 100) {
|
|
29
|
+
cpuu = (cpuu / total) * 100;
|
|
30
|
+
cpus = (cpus / total) * 100;
|
|
31
|
+
}
|
|
32
|
+
return { cpuu, cpus };
|
|
33
|
+
};
|
|
34
|
+
exports.clampCpuPair = clampCpuPair;
|
|
76
35
|
const calcProcStatLinux = (line, all, _cpu_old) => {
|
|
77
36
|
const statparts = line.replace(/ +/g, ' ').split(')');
|
|
78
37
|
if (statparts.length >= 2) {
|
|
@@ -81,27 +40,25 @@ const calcProcStatLinux = (line, all, _cpu_old) => {
|
|
|
81
40
|
const pid = (0, index_1.toInt)(statparts[0].split(' ')[0]);
|
|
82
41
|
const utime = (0, index_1.toInt)(parts[12]);
|
|
83
42
|
const stime = (0, index_1.toInt)(parts[13]);
|
|
84
|
-
const cutime = (0, index_1.toInt)(parts[14]);
|
|
85
|
-
const cstime = (0, index_1.toInt)(parts[15]);
|
|
86
43
|
let cpuu = 0;
|
|
87
44
|
let cpus = 0;
|
|
88
45
|
if (_cpu_old.all > 0 && _cpu_old.list[pid]) {
|
|
89
|
-
|
|
90
|
-
|
|
46
|
+
const delta = all - _cpu_old.all;
|
|
47
|
+
cpuu = delta > 0 ? ((utime - _cpu_old.list[pid].utime) / delta) * 100 : 0;
|
|
48
|
+
cpus = delta > 0 ? ((stime - _cpu_old.list[pid].stime) / delta) * 100 : 0;
|
|
91
49
|
}
|
|
92
50
|
else {
|
|
93
|
-
cpuu = (
|
|
94
|
-
cpus = (
|
|
51
|
+
cpuu = all > 0 ? (utime / all) * 100 : 0;
|
|
52
|
+
cpus = all > 0 ? (stime / all) * 100 : 0;
|
|
95
53
|
}
|
|
54
|
+
const clamped = (0, exports.clampCpuPair)(cpuu, cpus);
|
|
96
55
|
return {
|
|
97
56
|
pid: pid,
|
|
98
57
|
name: '',
|
|
99
58
|
utime: utime,
|
|
100
59
|
stime: stime,
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
cpuu: cpuu,
|
|
104
|
-
cpus: cpus
|
|
60
|
+
cpuu: clamped.cpuu,
|
|
61
|
+
cpus: clamped.cpus
|
|
105
62
|
};
|
|
106
63
|
}
|
|
107
64
|
}
|
|
@@ -110,8 +67,6 @@ const calcProcStatLinux = (line, all, _cpu_old) => {
|
|
|
110
67
|
name: '',
|
|
111
68
|
utime: 0,
|
|
112
69
|
stime: 0,
|
|
113
|
-
cutime: 0,
|
|
114
|
-
cstime: 0,
|
|
115
70
|
cpuu: 0,
|
|
116
71
|
cpus: 0
|
|
117
72
|
};
|
|
@@ -22,6 +22,7 @@ export declare const stringSplit: {
|
|
|
22
22
|
export declare const stringStartWith: (searchString: string, position?: number) => boolean;
|
|
23
23
|
export declare const mathMin: (...values: number[]) => number;
|
|
24
24
|
export declare const sanitizeShellString: (str: string, strict?: any) => string;
|
|
25
|
+
export declare const isSafePathSegment: (segment: string) => boolean;
|
|
25
26
|
export declare const sanitizeContainerID: (str: string) => string;
|
|
26
27
|
export declare const sanitizeImageID: (str: string) => string;
|
|
27
28
|
export declare const isPrototypePolluted: () => boolean;
|
package/dist/common/security.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sanitizeString = exports.sanitizeInterfacesString = exports.sanitizeServiceString = exports.sanitizeUrl = exports.isPrototypePolluted = exports.sanitizeImageID = exports.sanitizeContainerID = exports.sanitizeShellString = exports.mathMin = exports.stringStartWith = exports.stringSplit = exports.stringTrim = exports.stringSubstring = exports.stringSubstr = exports.stringToString = exports.stringToLower = exports.stringReplace = void 0;
|
|
3
|
+
exports.sanitizeString = exports.sanitizeInterfacesString = exports.sanitizeServiceString = exports.sanitizeUrl = exports.isPrototypePolluted = exports.sanitizeImageID = exports.sanitizeContainerID = exports.isSafePathSegment = exports.sanitizeShellString = exports.mathMin = exports.stringStartWith = exports.stringSplit = exports.stringTrim = exports.stringSubstring = exports.stringSubstr = exports.stringToString = exports.stringToLower = exports.stringReplace = void 0;
|
|
4
4
|
exports.stringReplace = new String().replace;
|
|
5
5
|
exports.stringToLower = new String().toLowerCase;
|
|
6
6
|
exports.stringToString = new String().toString;
|
|
@@ -56,6 +56,8 @@ const sanitizeShellString = (str, strict) => {
|
|
|
56
56
|
return result;
|
|
57
57
|
};
|
|
58
58
|
exports.sanitizeShellString = sanitizeShellString;
|
|
59
|
+
const isSafePathSegment = (segment) => !!segment && segment.indexOf('/') === -1 && segment.indexOf('\0') === -1 && segment !== '.' && segment !== '..';
|
|
60
|
+
exports.isSafePathSegment = isSafePathSegment;
|
|
59
61
|
const sanitizeContainerID = (str) => {
|
|
60
62
|
const s = String(str || '')
|
|
61
63
|
.substring(0, 2000)
|
package/dist/common/types.d.ts
CHANGED
|
@@ -321,6 +321,24 @@ export type CpuTemperatureObject = {
|
|
|
321
321
|
socket: number[];
|
|
322
322
|
chipset: number | null;
|
|
323
323
|
};
|
|
324
|
+
export type FanData = {
|
|
325
|
+
id: string;
|
|
326
|
+
label: string | null;
|
|
327
|
+
rpm: number | null;
|
|
328
|
+
pwm: number | null;
|
|
329
|
+
source: string;
|
|
330
|
+
};
|
|
331
|
+
export type SerialPortType = 'usb' | 'onboard' | 'pci' | 'bluetooth' | 'virtual' | 'unknown';
|
|
332
|
+
export type SerialPortData = {
|
|
333
|
+
device: string;
|
|
334
|
+
name: string | null;
|
|
335
|
+
manufacturer: string | null;
|
|
336
|
+
serialNumber: string | null;
|
|
337
|
+
vendorId: string | null;
|
|
338
|
+
productId: string | null;
|
|
339
|
+
pnpId: string | null;
|
|
340
|
+
type: SerialPortType;
|
|
341
|
+
};
|
|
324
342
|
export type CurrentLoadData = {
|
|
325
343
|
avgLoad: number;
|
|
326
344
|
currentLoad: number;
|
|
@@ -328,6 +346,7 @@ export type CurrentLoadData = {
|
|
|
328
346
|
currentLoadSystem: number;
|
|
329
347
|
currentLoadNice: number;
|
|
330
348
|
currentLoadIdle: number;
|
|
349
|
+
currentLoadIowait: number;
|
|
331
350
|
currentLoadIrq: number;
|
|
332
351
|
currentLoadSteal: number;
|
|
333
352
|
currentLoadGuest: number;
|
|
@@ -336,6 +355,7 @@ export type CurrentLoadData = {
|
|
|
336
355
|
rawCurrentLoadSystem: number;
|
|
337
356
|
rawCurrentLoadNice: number;
|
|
338
357
|
rawCurrentLoadIdle: number;
|
|
358
|
+
rawCurrentLoadIowait: number;
|
|
339
359
|
rawCurrentLoadIrq: number;
|
|
340
360
|
rawCurrentLoadSteal: number;
|
|
341
361
|
rawCurrentLoadGuest: number;
|
|
@@ -347,12 +367,14 @@ export type CurrentLoadCpuData = {
|
|
|
347
367
|
loadSystem: number;
|
|
348
368
|
loadNice: number;
|
|
349
369
|
loadIdle: number;
|
|
370
|
+
loadIowait: number;
|
|
350
371
|
loadIrq: number;
|
|
351
372
|
rawLoad: number;
|
|
352
373
|
rawLoadUser: number;
|
|
353
374
|
rawLoadSystem: number;
|
|
354
375
|
rawLoadNice: number;
|
|
355
376
|
rawLoadIdle: number;
|
|
377
|
+
rawLoadIowait: number;
|
|
356
378
|
rawLoadIrq: number;
|
|
357
379
|
};
|
|
358
380
|
export type WifiNetworkData = {
|
|
@@ -629,9 +651,9 @@ export type DisksIoData = {
|
|
|
629
651
|
rIO_sec: number | null;
|
|
630
652
|
wIO_sec: number | null;
|
|
631
653
|
tIO_sec: number | null;
|
|
632
|
-
rWaitTime: number;
|
|
633
|
-
wWaitTime: number;
|
|
634
|
-
tWaitTime: number;
|
|
654
|
+
rWaitTime: number | null;
|
|
655
|
+
wWaitTime: number | null;
|
|
656
|
+
tWaitTime: number | null;
|
|
635
657
|
rWaitPercent: number | null;
|
|
636
658
|
wWaitPercent: number | null;
|
|
637
659
|
tWaitPercent: number | null;
|
|
@@ -811,6 +833,7 @@ export type DisplayData = {
|
|
|
811
833
|
deviceName: string | null;
|
|
812
834
|
displayId: string | null;
|
|
813
835
|
main: boolean;
|
|
836
|
+
mirror: boolean;
|
|
814
837
|
builtin: boolean;
|
|
815
838
|
connection: string | null;
|
|
816
839
|
sizeX: number | null;
|
|
@@ -822,7 +845,12 @@ export type DisplayData = {
|
|
|
822
845
|
currentResY: number | null;
|
|
823
846
|
positionX: number;
|
|
824
847
|
positionY: number;
|
|
848
|
+
workAreaResolutionX: number | null;
|
|
849
|
+
workAreaResolutionY: number | null;
|
|
850
|
+
workAreaPositionX: number | null;
|
|
851
|
+
workAreaPositionY: number | null;
|
|
825
852
|
currentRefreshRate: number | null;
|
|
853
|
+
scale: number | null;
|
|
826
854
|
};
|
|
827
855
|
export type GpuNvidiaData = {
|
|
828
856
|
driverVersion: string;
|
|
@@ -847,8 +875,6 @@ export type ProcStatData = {
|
|
|
847
875
|
name: string;
|
|
848
876
|
utime: number;
|
|
849
877
|
stime: number;
|
|
850
|
-
cutime?: number;
|
|
851
|
-
cstime?: number;
|
|
852
878
|
cpu?: number;
|
|
853
879
|
cpuu: number;
|
|
854
880
|
cpus: number;
|
|
@@ -866,6 +892,7 @@ export type ServicesData = {
|
|
|
866
892
|
name: string;
|
|
867
893
|
running: boolean;
|
|
868
894
|
startmode: string;
|
|
895
|
+
lastChanged: Date | null;
|
|
869
896
|
pids: number[];
|
|
870
897
|
cpu: number;
|
|
871
898
|
mem: number;
|
|
@@ -884,6 +911,7 @@ export type ProcessesProcessData = {
|
|
|
884
911
|
cpu: number;
|
|
885
912
|
cpuu: number;
|
|
886
913
|
cpus: number;
|
|
914
|
+
cpuTime: number | null;
|
|
887
915
|
mem: number;
|
|
888
916
|
priority: number;
|
|
889
917
|
memVsz: number;
|
package/dist/cpu-current-load.js
CHANGED
|
@@ -4,12 +4,14 @@ exports.currentLoad = void 0;
|
|
|
4
4
|
const node_os_1 = require("node:os");
|
|
5
5
|
const common_1 = require("./common");
|
|
6
6
|
const const_1 = require("./common/const");
|
|
7
|
-
const
|
|
7
|
+
const files_1 = require("./common/files");
|
|
8
|
+
const JIFFY_MS = 10;
|
|
8
9
|
let _current_cpu = {
|
|
9
10
|
user: 0,
|
|
10
11
|
nice: 0,
|
|
11
12
|
system: 0,
|
|
12
13
|
idle: 0,
|
|
14
|
+
iowait: 0,
|
|
13
15
|
irq: 0,
|
|
14
16
|
steal: 0,
|
|
15
17
|
guest: 0,
|
|
@@ -21,6 +23,7 @@ let _current_cpu = {
|
|
|
21
23
|
currentLoadSystem: 0,
|
|
22
24
|
currentLoadNice: 0,
|
|
23
25
|
currentLoadIdle: 0,
|
|
26
|
+
currentLoadIowait: 0,
|
|
24
27
|
currentLoadIrq: 0,
|
|
25
28
|
currentLoadSteal: 0,
|
|
26
29
|
currentLoadGuest: 0,
|
|
@@ -29,6 +32,7 @@ let _current_cpu = {
|
|
|
29
32
|
rawCurrentLoadSystem: 0,
|
|
30
33
|
rawCurrentLoadNice: 0,
|
|
31
34
|
rawCurrentLoadIdle: 0,
|
|
35
|
+
rawCurrentLoadIowait: 0,
|
|
32
36
|
rawCurrentLoadIrq: 0,
|
|
33
37
|
rawCurrentLoadSteal: 0,
|
|
34
38
|
rawCurrentLoadGuest: 0
|
|
@@ -46,6 +50,7 @@ const currentLoad = async () => {
|
|
|
46
50
|
currentLoadSystem: 0,
|
|
47
51
|
currentLoadNice: 0,
|
|
48
52
|
currentLoadIdle: 0,
|
|
53
|
+
currentLoadIowait: 0,
|
|
49
54
|
currentLoadIrq: 0,
|
|
50
55
|
currentLoadSteal: 0,
|
|
51
56
|
currentLoadGuest: 0,
|
|
@@ -54,6 +59,7 @@ const currentLoad = async () => {
|
|
|
54
59
|
rawCurrentLoadSystem: 0,
|
|
55
60
|
rawCurrentLoadNice: 0,
|
|
56
61
|
rawCurrentLoadIdle: 0,
|
|
62
|
+
rawCurrentLoadIowait: 0,
|
|
57
63
|
rawCurrentLoadIrq: 0,
|
|
58
64
|
rawCurrentLoadSteal: 0,
|
|
59
65
|
rawCurrentLoadGuest: 0,
|
|
@@ -75,24 +81,26 @@ const currentLoad = async () => {
|
|
|
75
81
|
let totalNice = 0;
|
|
76
82
|
let totalIrq = 0;
|
|
77
83
|
let totalIdle = 0;
|
|
84
|
+
let totalIowait = 0;
|
|
78
85
|
let totalSteal = 0;
|
|
79
86
|
let totalGuest = 0;
|
|
80
87
|
const cores = [];
|
|
81
88
|
_corecount = cpus && cpus.length ? cpus.length : 0;
|
|
82
89
|
if (const_1.LINUX) {
|
|
83
90
|
try {
|
|
84
|
-
const
|
|
85
|
-
const lines = stdout.split('\n');
|
|
91
|
+
const lines = (await (0, files_1.readFileLines)('/proc/stat')).filter((line) => line.startsWith('cpu'));
|
|
86
92
|
if (lines.length > 1) {
|
|
87
93
|
lines.shift();
|
|
88
94
|
if (lines.length === cpus.length) {
|
|
89
95
|
for (let i = 0; i < lines.length; i++) {
|
|
90
96
|
const parts = lines[i].split(' ');
|
|
91
97
|
if (parts.length >= 10) {
|
|
98
|
+
const iowait = parseFloat(parts[5]) || 0;
|
|
92
99
|
const steal = parseFloat(parts[8]) || 0;
|
|
93
100
|
const guest = parseFloat(parts[9]) || 0;
|
|
94
|
-
cpus[i].times.
|
|
95
|
-
cpus[i].times.
|
|
101
|
+
cpus[i].times.iowait = iowait * JIFFY_MS;
|
|
102
|
+
cpus[i].times.steal = steal * JIFFY_MS;
|
|
103
|
+
cpus[i].times.guest = guest * JIFFY_MS;
|
|
96
104
|
}
|
|
97
105
|
}
|
|
98
106
|
}
|
|
@@ -106,6 +114,7 @@ const currentLoad = async () => {
|
|
|
106
114
|
totalSystem += cpu.sys;
|
|
107
115
|
totalNice += cpu.nice;
|
|
108
116
|
totalIdle += cpu.idle;
|
|
117
|
+
totalIowait += cpu.iowait || 0;
|
|
109
118
|
totalIrq += cpu.irq;
|
|
110
119
|
totalSteal += cpu.steal || 0;
|
|
111
120
|
totalGuest += cpu.guest || 0;
|
|
@@ -115,6 +124,7 @@ const currentLoad = async () => {
|
|
|
115
124
|
const tmpSystem = _cpus && _cpus[i] && _cpus[i].sys ? _cpus[i].sys : 0;
|
|
116
125
|
const tmpNice = _cpus && _cpus[i] && _cpus[i].nice ? _cpus[i].nice : 0;
|
|
117
126
|
const tmpIdle = _cpus && _cpus[i] && _cpus[i].idle ? _cpus[i].idle : 0;
|
|
127
|
+
const tmpIowait = _cpus && _cpus[i] && _cpus[i].iowait ? _cpus[i].iowait : 0;
|
|
118
128
|
const tmpIrq = _cpus && _cpus[i] && _cpus[i].irq ? _cpus[i].irq : 0;
|
|
119
129
|
const tmpSteal = _cpus && _cpus[i] && _cpus[i].steal ? _cpus[i].steal : 0;
|
|
120
130
|
const tmpGuest = _cpus && _cpus[i] && _cpus[i].guest ? _cpus[i].guest : 0;
|
|
@@ -127,6 +137,7 @@ const currentLoad = async () => {
|
|
|
127
137
|
_cpus[i].loadSystem = _cpus[i].sys - tmpSystem;
|
|
128
138
|
_cpus[i].loadNice = _cpus[i].nice - tmpNice;
|
|
129
139
|
_cpus[i].loadIdle = _cpus[i].idle - tmpIdle;
|
|
140
|
+
_cpus[i].loadIowait = (_cpus[i].iowait || 0) - tmpIowait;
|
|
130
141
|
_cpus[i].loadIrq = _cpus[i].irq - tmpIrq;
|
|
131
142
|
_cpus[i].loadSteal = _cpus[i].steal - tmpSteal;
|
|
132
143
|
_cpus[i].loadGuest = _cpus[i].guest - tmpGuest;
|
|
@@ -137,6 +148,7 @@ const currentLoad = async () => {
|
|
|
137
148
|
cores[i].loadSystem = (_cpus[i].loadSystem / coreTick) * 100;
|
|
138
149
|
cores[i].loadNice = (_cpus[i].loadNice / coreTick) * 100;
|
|
139
150
|
cores[i].loadIdle = (_cpus[i].loadIdle / coreTick) * 100;
|
|
151
|
+
cores[i].loadIowait = (_cpus[i].loadIowait / coreTick) * 100;
|
|
140
152
|
cores[i].loadIrq = (_cpus[i].loadIrq / coreTick) * 100;
|
|
141
153
|
cores[i].loadSteal = (_cpus[i].loadSteal / coreTick) * 100;
|
|
142
154
|
cores[i].loadGuest = (_cpus[i].loadGuest / coreTick) * 100;
|
|
@@ -145,11 +157,12 @@ const currentLoad = async () => {
|
|
|
145
157
|
cores[i].rawLoadSystem = _cpus[i].loadSystem;
|
|
146
158
|
cores[i].rawLoadNice = _cpus[i].loadNice;
|
|
147
159
|
cores[i].rawLoadIdle = _cpus[i].loadIdle;
|
|
160
|
+
cores[i].rawLoadIowait = _cpus[i].loadIowait;
|
|
148
161
|
cores[i].rawLoadIrq = _cpus[i].loadIrq;
|
|
149
162
|
cores[i].rawLoadSteal = _cpus[i].loadSteal;
|
|
150
163
|
cores[i].rawLoadGuest = _cpus[i].loadGuest;
|
|
151
164
|
}
|
|
152
|
-
const totalTick = totalUser + totalSystem + totalNice + totalIrq + totalSteal + totalGuest + totalIdle;
|
|
165
|
+
const totalTick = totalUser + totalSystem + totalNice + totalIrq + totalSteal + totalGuest + totalIdle + totalIowait;
|
|
153
166
|
const totalLoad = totalUser + totalSystem + totalNice + totalIrq + totalSteal + totalGuest;
|
|
154
167
|
const currentTick = totalTick - _current_cpu.tick || 1;
|
|
155
168
|
result = {
|
|
@@ -159,6 +172,7 @@ const currentLoad = async () => {
|
|
|
159
172
|
currentLoadSystem: ((totalSystem - _current_cpu.system) / currentTick) * 100,
|
|
160
173
|
currentLoadNice: ((totalNice - _current_cpu.nice) / currentTick) * 100,
|
|
161
174
|
currentLoadIdle: ((totalIdle - _current_cpu.idle) / currentTick) * 100,
|
|
175
|
+
currentLoadIowait: ((totalIowait - _current_cpu.iowait) / currentTick) * 100,
|
|
162
176
|
currentLoadIrq: ((totalIrq - _current_cpu.irq) / currentTick) * 100,
|
|
163
177
|
currentLoadSteal: ((totalSteal - _current_cpu.steal) / currentTick) * 100,
|
|
164
178
|
currentLoadGuest: ((totalGuest - _current_cpu.guest) / currentTick) * 100,
|
|
@@ -167,6 +181,7 @@ const currentLoad = async () => {
|
|
|
167
181
|
rawCurrentLoadSystem: totalSystem - _current_cpu.system,
|
|
168
182
|
rawCurrentLoadNice: totalNice - _current_cpu.nice,
|
|
169
183
|
rawCurrentLoadIdle: totalIdle - _current_cpu.idle,
|
|
184
|
+
rawCurrentLoadIowait: totalIowait - _current_cpu.iowait,
|
|
170
185
|
rawCurrentLoadIrq: totalIrq - _current_cpu.irq,
|
|
171
186
|
rawCurrentLoadSteal: totalSteal - _current_cpu.steal,
|
|
172
187
|
rawCurrentLoadGuest: totalGuest - _current_cpu.guest,
|
|
@@ -177,6 +192,7 @@ const currentLoad = async () => {
|
|
|
177
192
|
nice: totalNice,
|
|
178
193
|
system: totalSystem,
|
|
179
194
|
idle: totalIdle,
|
|
195
|
+
iowait: totalIowait,
|
|
180
196
|
irq: totalIrq,
|
|
181
197
|
steal: totalSteal,
|
|
182
198
|
guest: totalGuest,
|
|
@@ -188,6 +204,7 @@ const currentLoad = async () => {
|
|
|
188
204
|
currentLoadSystem: result.currentLoadSystem,
|
|
189
205
|
currentLoadNice: result.currentLoadNice,
|
|
190
206
|
currentLoadIdle: result.currentLoadIdle,
|
|
207
|
+
currentLoadIowait: result.currentLoadIowait,
|
|
191
208
|
currentLoadIrq: result.currentLoadIrq,
|
|
192
209
|
currentLoadSteal: result.currentLoadSteal,
|
|
193
210
|
currentLoadGuest: result.currentLoadGuest,
|
|
@@ -196,6 +213,7 @@ const currentLoad = async () => {
|
|
|
196
213
|
rawCurrentLoadSystem: result.rawCurrentLoadSystem,
|
|
197
214
|
rawCurrentLoadNice: result.rawCurrentLoadNice,
|
|
198
215
|
rawCurrentLoadIdle: result.rawCurrentLoadIdle,
|
|
216
|
+
rawCurrentLoadIowait: result.rawCurrentLoadIowait,
|
|
199
217
|
rawCurrentLoadIrq: result.rawCurrentLoadIrq,
|
|
200
218
|
rawCurrentLoadSteal: result.rawCurrentLoadSteal,
|
|
201
219
|
rawCurrentLoadGuest: result.rawCurrentLoadGuest
|
|
@@ -211,6 +229,7 @@ const currentLoad = async () => {
|
|
|
211
229
|
cores[i].loadSystem = (_cpus[i].loadSystem / coreTick) * 100;
|
|
212
230
|
cores[i].loadNice = (_cpus[i].loadNice / coreTick) * 100;
|
|
213
231
|
cores[i].loadIdle = (_cpus[i].loadIdle / coreTick) * 100;
|
|
232
|
+
cores[i].loadIowait = (_cpus[i].loadIowait / coreTick) * 100;
|
|
214
233
|
cores[i].loadIrq = (_cpus[i].loadIrq / coreTick) * 100;
|
|
215
234
|
cores[i].loadSteal = (_cpus[i].loadSteal / coreTick) * 100;
|
|
216
235
|
cores[i].loadGuest = (_cpus[i].loadGuest / coreTick) * 100;
|
|
@@ -219,6 +238,7 @@ const currentLoad = async () => {
|
|
|
219
238
|
cores[i].rawLoadSystem = _cpus[i].loadSystem;
|
|
220
239
|
cores[i].rawLoadNice = _cpus[i].loadNice;
|
|
221
240
|
cores[i].rawLoadIdle = _cpus[i].loadIdle;
|
|
241
|
+
cores[i].rawLoadIowait = _cpus[i].loadIowait;
|
|
222
242
|
cores[i].rawLoadIrq = _cpus[i].loadIrq;
|
|
223
243
|
cores[i].rawLoadSteal = _cpus[i].loadSteal;
|
|
224
244
|
cores[i].rawLoadGuest = _cpus[i].loadGuest;
|
|
@@ -230,6 +250,7 @@ const currentLoad = async () => {
|
|
|
230
250
|
currentLoadSystem: _current_cpu.currentLoadSystem,
|
|
231
251
|
currentLoadNice: _current_cpu.currentLoadNice,
|
|
232
252
|
currentLoadIdle: _current_cpu.currentLoadIdle,
|
|
253
|
+
currentLoadIowait: _current_cpu.currentLoadIowait,
|
|
233
254
|
currentLoadIrq: _current_cpu.currentLoadIrq,
|
|
234
255
|
currentLoadSteal: _current_cpu.currentLoadSteal,
|
|
235
256
|
currentLoadGuest: _current_cpu.currentLoadGuest,
|
|
@@ -238,6 +259,7 @@ const currentLoad = async () => {
|
|
|
238
259
|
rawCurrentLoadSystem: _current_cpu.rawCurrentLoadSystem,
|
|
239
260
|
rawCurrentLoadNice: _current_cpu.rawCurrentLoadNice,
|
|
240
261
|
rawCurrentLoadIdle: _current_cpu.rawCurrentLoadIdle,
|
|
262
|
+
rawCurrentLoadIowait: _current_cpu.rawCurrentLoadIowait,
|
|
241
263
|
rawCurrentLoadIrq: _current_cpu.rawCurrentLoadIrq,
|
|
242
264
|
rawCurrentLoadSteal: _current_cpu.rawCurrentLoadSteal,
|
|
243
265
|
rawCurrentLoadGuest: _current_cpu.rawCurrentLoadGuest,
|
|
@@ -5,7 +5,7 @@ const node_os_1 = require("node:os");
|
|
|
5
5
|
const common_1 = require("./common");
|
|
6
6
|
const const_1 = require("./common/const");
|
|
7
7
|
const cpu_1 = require("./common/cpu");
|
|
8
|
-
const
|
|
8
|
+
const files_1 = require("./common/files");
|
|
9
9
|
const getCpuCurrentSpeed = async () => {
|
|
10
10
|
const oscpus = (0, node_os_1.cpus)();
|
|
11
11
|
let minFreq = 999999999;
|
|
@@ -20,8 +20,10 @@ const getCpuCurrentSpeed = async () => {
|
|
|
20
20
|
}
|
|
21
21
|
else if (const_1.LINUX) {
|
|
22
22
|
try {
|
|
23
|
-
const
|
|
24
|
-
|
|
23
|
+
const speedStrings = (await (0, files_1.readFileLines)('/proc/cpuinfo'))
|
|
24
|
+
.filter((line) => line.toLowerCase().startsWith('cpu mhz'))
|
|
25
|
+
.map((line) => (line.split(':')[1] || '').trim())
|
|
26
|
+
.filter((line) => line.length > 0);
|
|
25
27
|
for (const i in speedStrings) {
|
|
26
28
|
speeds.push(Math.floor(parseInt(speedStrings[i], 10) / 10) / 100);
|
|
27
29
|
}
|
package/dist/darwin/battery.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { BatteryObject } from '../common/types';
|
|
1
|
+
import type { BatteryObject } from '../common/types';
|
|
2
2
|
export declare const battery: () => Promise<BatteryObject[]>;
|
package/dist/darwin/battery.js
CHANGED
|
@@ -7,7 +7,12 @@ const exec_1 = require("../common/exec");
|
|
|
7
7
|
const parseBatteryObject = (data) => {
|
|
8
8
|
const defaults = (0, common_1.cloneObj)(defaults_1.initBatteryResult);
|
|
9
9
|
data = data || '';
|
|
10
|
-
const lines = data
|
|
10
|
+
const lines = data
|
|
11
|
+
.replace(/^[ |]+/gm, '')
|
|
12
|
+
.replace(/ +/g, '')
|
|
13
|
+
.replace(/"+/g, '')
|
|
14
|
+
.replace(/-/g, '')
|
|
15
|
+
.split('\n');
|
|
11
16
|
let percent = null;
|
|
12
17
|
const line = (0, common_1.getValue)(lines, 'internal', 'Battery');
|
|
13
18
|
const parts = line.split(';');
|
|
@@ -21,9 +26,14 @@ const parseBatteryObject = (data) => {
|
|
|
21
26
|
const acConnected = parts && parts[1] ? parts[1].trim() !== 'discharging' : false;
|
|
22
27
|
const voltage = parseInt('0' + (0, common_1.getValue)(lines, 'voltage', '='), 10) / 1000.0;
|
|
23
28
|
const capacityUnit = voltage ? 'mWh' : 'mAh';
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
|
|
29
|
+
const batteryData = (0, common_1.getValue)(lines, 'BatteryData', '=').replace(/^\{/, '').replace(/\}$/, '').split(',');
|
|
30
|
+
const maxCapacity = Math.round(parseInt('0' +
|
|
31
|
+
((0, common_1.getValue)(lines, 'AppleRawMaxCapacity', '=') ||
|
|
32
|
+
(0, common_1.getValue)(lines, 'NominalChargeCapacity', '=') ||
|
|
33
|
+
(0, common_1.getValue)(batteryData, 'FullChargeCapacity', '=') ||
|
|
34
|
+
(0, common_1.getValue)(batteryData, 'NominalChargeCapacity', '=')), 10) * (voltage || 1));
|
|
35
|
+
const currentCapacity = Math.round(parseInt('0' + ((0, common_1.getValue)(lines, 'AppleRawCurrentCapacity', '=') || (0, common_1.getValue)(batteryData, 'RemainingCapacity', '=')), 10) * (voltage || 1));
|
|
36
|
+
const designedCapacity = Math.round(parseInt('0' + ((0, common_1.getValue)(lines, 'DesignCapacity', '=') || (0, common_1.getValue)(batteryData, 'DesignCapacity', '=')), 10) * (voltage || 1));
|
|
27
37
|
let hasBattery = defaults.hasBattery;
|
|
28
38
|
let type = defaults.type;
|
|
29
39
|
let timeRemaining = defaults.timeRemaining;
|
|
@@ -59,7 +69,7 @@ const parseBatteryObject = (data) => {
|
|
|
59
69
|
};
|
|
60
70
|
const battery = async () => {
|
|
61
71
|
await (0, common_1.nextTick)();
|
|
62
|
-
const { stdout } = await (0, exec_1.execSave)('ioreg -n AppleSmartBattery -r | egrep "CycleCount|IsCharging|DesignCapacity|MaxCapacity|CurrentCapacity|DeviceName|BatterySerialNumber|Serial|TimeRemaining|Voltage"; pmset -g batt | grep %');
|
|
72
|
+
const { stdout } = await (0, exec_1.execSave)('ioreg -n AppleSmartBattery -r | egrep "CycleCount|IsCharging|DesignCapacity|MaxCapacity|CurrentCapacity|DeviceName|BatterySerialNumber|Serial|TimeRemaining|Voltage|BatteryData|NominalChargeCapacity"; pmset -g batt | grep %');
|
|
63
73
|
return parseBatteryObject(stdout);
|
|
64
74
|
};
|
|
65
75
|
exports.battery = battery;
|
package/dist/darwin/camera.js
CHANGED
|
@@ -40,10 +40,10 @@ const parseUsb = (data) => {
|
|
|
40
40
|
const camera = async () => {
|
|
41
41
|
await (0, common_1.nextTick)();
|
|
42
42
|
try {
|
|
43
|
-
const { stdout } = await (0, exec_1.exec)('system_profiler SPCameraDataType SPUSBDataType -xml');
|
|
43
|
+
const { stdout } = await (0, exec_1.exec)('system_profiler SPCameraDataType SPUSBDataType SPUSBHostDataType -xml');
|
|
44
44
|
const data = (0, darwin_1.plistParser)(stdout, false);
|
|
45
|
-
const cameraData =
|
|
46
|
-
const usbData =
|
|
45
|
+
const cameraData = (0, darwin_1.spItems)(data, 'SPCameraDataType');
|
|
46
|
+
const usbData = (0, darwin_1.spItems)(data, darwin_1.USB_DATA_TYPES);
|
|
47
47
|
let result = parseCamera(cameraData);
|
|
48
48
|
result = result.concat(parseUsb(usbData));
|
|
49
49
|
return result;
|
|
@@ -12,14 +12,21 @@ const diskLayout = async () => {
|
|
|
12
12
|
let stdout = '';
|
|
13
13
|
let cmd = '';
|
|
14
14
|
let cmdFullSmart = '';
|
|
15
|
+
const addSmartCmds = (bsdName) => {
|
|
16
|
+
if (typeof bsdName !== 'string' || !/^disk\d+(s\d+)*$/.test(bsdName)) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
cmd += `printf "\n${bsdName}|"; diskutil info /dev/${bsdName} | grep SMART;`;
|
|
20
|
+
cmdFullSmart += `${cmdFullSmart ? 'printf ",";' : ''}smartctl -a -j ${bsdName};`;
|
|
21
|
+
};
|
|
15
22
|
try {
|
|
16
|
-
({ stdout } = await (0, exec_1.exec)(`system_profiler SPSerialATADataType SPNVMeDataType SPUSBDataType SPStorageDataType -xml`, { maxBuffer: const_1.MAX_BUFFER_SIZE }));
|
|
23
|
+
({ stdout } = await (0, exec_1.exec)(`system_profiler SPSerialATADataType SPNVMeDataType SPUSBDataType SPUSBHostDataType SPStorageDataType -xml`, { maxBuffer: const_1.MAX_BUFFER_SIZE }));
|
|
17
24
|
const data = (0, darwin_1.plistParser)(stdout, false);
|
|
18
|
-
const diskSATA =
|
|
19
|
-
const diskNVME =
|
|
20
|
-
const diskUSB =
|
|
21
|
-
const diskLine =
|
|
22
|
-
if (diskSATA?.length
|
|
25
|
+
const diskSATA = (0, darwin_1.spItems)(data, 'SPSerialATADataType');
|
|
26
|
+
const diskNVME = (0, darwin_1.spItems)(data, 'SPNVMeDataType');
|
|
27
|
+
const diskUSB = (0, darwin_1.spItems)(data, darwin_1.USB_DATA_TYPES);
|
|
28
|
+
const diskLine = (0, darwin_1.spItems)(data, 'SPStorageDataType');
|
|
29
|
+
if (diskSATA?.length) {
|
|
23
30
|
diskSATA.forEach((controller) => {
|
|
24
31
|
if (controller?._items && controller._items.length) {
|
|
25
32
|
const deviceType = controller._names && controller._names.tolower().indexOf('ssd') >= 0 ? 'SSD' : 'HD';
|
|
@@ -44,8 +51,7 @@ const diskLayout = async () => {
|
|
|
44
51
|
temperature: null,
|
|
45
52
|
bsdName: disk.bsd_name
|
|
46
53
|
});
|
|
47
|
-
|
|
48
|
-
cmdFullSmart += `${cmdFullSmart ? 'printf ",";' : ''}smartctl -a -j ${disk.bsd_name};`;
|
|
54
|
+
addSmartCmds(disk.bsd_name);
|
|
49
55
|
});
|
|
50
56
|
}
|
|
51
57
|
});
|
|
@@ -74,8 +80,7 @@ const diskLayout = async () => {
|
|
|
74
80
|
temperature: null,
|
|
75
81
|
bsdName: disk.bsd_name
|
|
76
82
|
});
|
|
77
|
-
|
|
78
|
-
cmdFullSmart += `${cmdFullSmart ? 'printf ",";' : ''}smartctl -a -j ${disk.bsd_name};`;
|
|
83
|
+
addSmartCmds(disk.bsd_name);
|
|
79
84
|
});
|
|
80
85
|
}
|
|
81
86
|
});
|
|
@@ -106,8 +111,7 @@ const diskLayout = async () => {
|
|
|
106
111
|
temperature: null,
|
|
107
112
|
bsdName: media.bsd_name
|
|
108
113
|
});
|
|
109
|
-
|
|
110
|
-
cmdFullSmart += `${cmdFullSmart ? 'printf ",";' : ''}smartctl -a -j ${disk.bsd_name};`;
|
|
114
|
+
addSmartCmds(media.bsd_name);
|
|
111
115
|
}
|
|
112
116
|
else if (disk?._items.length) {
|
|
113
117
|
disk._items.forEach((subdisk) => {
|
package/dist/darwin/disks-io.js
CHANGED
|
@@ -44,9 +44,9 @@ const disksIO = async () => {
|
|
|
44
44
|
rIO_sec: filesys_1._disk_io.rIO_sec,
|
|
45
45
|
wIO_sec: filesys_1._disk_io.wIO_sec,
|
|
46
46
|
tIO_sec: filesys_1._disk_io.tIO_sec,
|
|
47
|
-
rWaitTime: filesys_1._disk_io.
|
|
48
|
-
wWaitTime: filesys_1._disk_io.
|
|
49
|
-
tWaitTime: filesys_1._disk_io.
|
|
47
|
+
rWaitTime: filesys_1._disk_io.rWaitTimeDelta,
|
|
48
|
+
wWaitTime: filesys_1._disk_io.wWaitTimeDelta,
|
|
49
|
+
tWaitTime: filesys_1._disk_io.tWaitTimeDelta,
|
|
50
50
|
rWaitPercent: filesys_1._disk_io.rWaitPercent,
|
|
51
51
|
wWaitPercent: filesys_1._disk_io.wWaitPercent,
|
|
52
52
|
tWaitPercent: filesys_1._disk_io.tWaitPercent
|