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.
Files changed (94) hide show
  1. package/README.md +41 -7
  2. package/dist/bsd/network-stats.js +2 -2
  3. package/dist/common/darwin.d.ts +2 -0
  4. package/dist/common/darwin.js +17 -1
  5. package/dist/common/defaults.d.ts +2 -1
  6. package/dist/common/defaults.js +21 -5
  7. package/dist/common/exec.js +1 -1
  8. package/dist/common/files.d.ts +9 -0
  9. package/dist/common/files.js +67 -3
  10. package/dist/common/filesys.d.ts +10 -0
  11. package/dist/common/filesys.js +41 -10
  12. package/dist/common/host.js +55 -3
  13. package/dist/common/mappings.js +2 -1
  14. package/dist/common/network.js +4 -4
  15. package/dist/common/nvidia.d.ts +1 -1
  16. package/dist/common/nvidia.js +4 -5
  17. package/dist/common/parse.d.ts +4 -6
  18. package/dist/common/parse.js +24 -69
  19. package/dist/common/security.d.ts +1 -0
  20. package/dist/common/security.js +3 -1
  21. package/dist/common/types.d.ts +33 -5
  22. package/dist/cpu-current-load.js +28 -6
  23. package/dist/cpu-current-speed.js +5 -3
  24. package/dist/darwin/battery.d.ts +1 -1
  25. package/dist/darwin/battery.js +15 -5
  26. package/dist/darwin/camera.js +3 -3
  27. package/dist/darwin/disk-layout.js +16 -12
  28. package/dist/darwin/disks-io.js +3 -3
  29. package/dist/darwin/displays.js +34 -1
  30. package/dist/darwin/fans.d.ts +2 -0
  31. package/dist/darwin/fans.js +28 -0
  32. package/dist/darwin/gpu.js +1 -1
  33. package/dist/darwin/index.d.ts +2 -0
  34. package/dist/darwin/index.js +6 -2
  35. package/dist/darwin/keyboard.js +4 -4
  36. package/dist/darwin/mouse.js +4 -4
  37. package/dist/darwin/network-interfaces.js +5 -10
  38. package/dist/darwin/network-stats.js +5 -5
  39. package/dist/darwin/serial-ports.d.ts +2 -0
  40. package/dist/darwin/serial-ports.js +94 -0
  41. package/dist/fans.d.ts +1 -0
  42. package/dist/fans.js +17 -0
  43. package/dist/get-data.d.ts +4 -0
  44. package/dist/get-data.js +6 -2
  45. package/dist/index.d.ts +2 -0
  46. package/dist/index.js +6 -2
  47. package/dist/linux/audio.js +59 -0
  48. package/dist/linux/baseboard.js +9 -20
  49. package/dist/linux/bios.js +6 -15
  50. package/dist/linux/camera.js +2 -1
  51. package/dist/linux/chassis.js +4 -10
  52. package/dist/linux/cpu-temperature.js +34 -19
  53. package/dist/linux/cpu.js +3 -1
  54. package/dist/linux/disk-layout.js +7 -10
  55. package/dist/linux/disks-io.js +9 -9
  56. package/dist/linux/displays.js +40 -2
  57. package/dist/linux/fans.d.ts +2 -0
  58. package/dist/linux/fans.js +92 -0
  59. package/dist/linux/fs-size.js +160 -34
  60. package/dist/linux/fs-stats.js +6 -9
  61. package/dist/linux/gpu.js +15 -15
  62. package/dist/linux/index.d.ts +2 -0
  63. package/dist/linux/index.js +6 -2
  64. package/dist/linux/mem-layout.js +2 -2
  65. package/dist/linux/network-interfaces.js +36 -39
  66. package/dist/linux/network-stats.js +8 -36
  67. package/dist/linux/npu.js +2 -1
  68. package/dist/linux/os-info.js +19 -4
  69. package/dist/linux/printer.js +4 -4
  70. package/dist/linux/process-load.js +9 -12
  71. package/dist/linux/processes.js +89 -80
  72. package/dist/linux/serial-ports.d.ts +2 -0
  73. package/dist/linux/serial-ports.js +102 -0
  74. package/dist/linux/services.js +179 -47
  75. package/dist/linux/system.js +1 -7
  76. package/dist/linux/uuid.js +4 -10
  77. package/dist/serial-ports.d.ts +1 -0
  78. package/dist/serial-ports.js +17 -0
  79. package/dist/versions.js +32 -77
  80. package/dist/windows/disk-layout.js +3 -0
  81. package/dist/windows/disks-io.js +3 -3
  82. package/dist/windows/displays.js +43 -12
  83. package/dist/windows/fans.d.ts +2 -0
  84. package/dist/windows/fans.js +71 -0
  85. package/dist/windows/index.d.ts +2 -0
  86. package/dist/windows/index.js +6 -2
  87. package/dist/windows/network-interfaces.js +20 -29
  88. package/dist/windows/network-stats.js +4 -2
  89. package/dist/windows/process-load.js +7 -5
  90. package/dist/windows/processes.js +17 -11
  91. package/dist/windows/serial-ports.d.ts +3 -0
  92. package/dist/windows/serial-ports.js +73 -0
  93. package/dist/windows/services.js +3 -0
  94. package/package.json +1 -1
@@ -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.parseProcStat = exports.parseHead = void 0;
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
- cpuu = ((utime + cutime - _cpu_old.list[pid].utime - _cpu_old.list[pid].cutime) / (all - _cpu_old.all)) * 100;
90
- cpus = ((stime + cstime - _cpu_old.list[pid].stime - _cpu_old.list[pid].cstime) / (all - _cpu_old.all)) * 100;
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 = ((utime + cutime) / all) * 100;
94
- cpus = ((stime + cstime) / all) * 100;
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
- cutime: cutime,
102
- cstime: cstime,
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;
@@ -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)
@@ -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;
@@ -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 exec_1 = require("./common/exec");
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 { stdout } = await (0, exec_1.exec)('cat /proc/stat 2>/dev/null | grep cpu');
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.steal = steal;
95
- cpus[i].times.guest = guest;
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 exec_1 = require("./common/exec");
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 { stdout } = await (0, exec_1.exec)('cat /proc/cpuinfo | grep "cpu MHz" | cut -d " " -f 3', const_1.execOptsLinux);
24
- const speedStrings = stdout.split('\n').filter((line) => line.length > 0);
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
  }
@@ -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[]>;
@@ -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.replace(/ +/g, '').replace(/"+/g, '').replace(/-/g, '').split('\n');
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 maxCapacity = Math.round(parseInt('0' + (0, common_1.getValue)(lines, 'applerawmaxcapacity', '='), 10) * (voltage || 1));
25
- const currentCapacity = Math.round(parseInt('0' + (0, common_1.getValue)(lines, 'applerawcurrentcapacity', '='), 10) * (voltage || 1));
26
- const designedCapacity = Math.round(parseInt('0' + (0, common_1.getValue)(lines, 'DesignCapacity', '='), 10) * (voltage || 1));
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;
@@ -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 = data.length >= 2 && data[0]._items ? data[0]._items : [];
46
- const usbData = data.length >= 2 && data[1]._items ? data[1]._items : [];
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 = data.length >= 4 && data[0]._items ? data[0]._items : [];
19
- const diskNVME = data.length >= 4 && data[1]._items ? data[1]._items : [];
20
- const diskUSB = data.length >= 4 && data[2]._items ? data[2]._items : [];
21
- const diskLine = data.length >= 4 && data[3]._items ? data[3]._items : [];
22
- if (diskSATA?.length && diskSATA._items) {
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
- cmd += 'printf "\n' + disk.bsd_name + '|"; diskutil info /dev/' + disk.bsd_name + ' | grep SMART;';
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
- cmd += 'printf "\n' + disk.bsd_name + '|"; diskutil info /dev/' + disk.bsd_name + ' | grep SMART;';
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
- cmd += 'printf "\n' + media.bsd_name + '|"; diskutil info /dev/' + media.bsd_name + ' | grep SMART;';
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) => {
@@ -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.rWaitTime,
48
- wWaitTime: filesys_1._disk_io.wWaitTime,
49
- tWaitTime: filesys_1._disk_io.tWaitTime,
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