systeminformation 6.0.0-beta.1 → 6.0.0-beta.10

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 (84) hide show
  1. package/README.md +37 -7
  2. package/dist/bsd/network-stats.js +2 -2
  3. package/dist/common/defaults.d.ts +2 -1
  4. package/dist/common/defaults.js +17 -5
  5. package/dist/common/exec.js +1 -1
  6. package/dist/common/files.d.ts +9 -0
  7. package/dist/common/files.js +67 -3
  8. package/dist/common/filesys.d.ts +10 -0
  9. package/dist/common/filesys.js +41 -10
  10. package/dist/common/network.js +4 -4
  11. package/dist/common/nvidia.d.ts +1 -1
  12. package/dist/common/nvidia.js +4 -5
  13. package/dist/common/parse.d.ts +4 -6
  14. package/dist/common/parse.js +24 -69
  15. package/dist/common/security.d.ts +1 -0
  16. package/dist/common/security.js +3 -1
  17. package/dist/common/types.d.ts +29 -5
  18. package/dist/cpu-current-load.js +28 -6
  19. package/dist/cpu-current-speed.js +5 -3
  20. package/dist/darwin/disk-layout.js +10 -6
  21. package/dist/darwin/disks-io.js +3 -3
  22. package/dist/darwin/displays.js +3 -1
  23. package/dist/darwin/fans.d.ts +2 -0
  24. package/dist/darwin/fans.js +28 -0
  25. package/dist/darwin/index.d.ts +2 -0
  26. package/dist/darwin/index.js +6 -2
  27. package/dist/darwin/network-interfaces.js +5 -10
  28. package/dist/darwin/network-stats.js +5 -5
  29. package/dist/darwin/serial-ports.d.ts +2 -0
  30. package/dist/darwin/serial-ports.js +94 -0
  31. package/dist/fans.d.ts +1 -0
  32. package/dist/fans.js +17 -0
  33. package/dist/get-data.d.ts +4 -0
  34. package/dist/get-data.js +6 -2
  35. package/dist/index.d.ts +2 -0
  36. package/dist/index.js +6 -2
  37. package/dist/linux/audio.js +59 -0
  38. package/dist/linux/baseboard.js +9 -20
  39. package/dist/linux/bios.js +6 -15
  40. package/dist/linux/camera.js +2 -1
  41. package/dist/linux/chassis.js +4 -10
  42. package/dist/linux/cpu-temperature.js +34 -19
  43. package/dist/linux/cpu.js +3 -1
  44. package/dist/linux/disk-layout.js +7 -10
  45. package/dist/linux/disks-io.js +9 -9
  46. package/dist/linux/displays.js +6 -1
  47. package/dist/linux/fans.d.ts +2 -0
  48. package/dist/linux/fans.js +92 -0
  49. package/dist/linux/fs-size.js +160 -34
  50. package/dist/linux/fs-stats.js +6 -9
  51. package/dist/linux/gpu.js +15 -15
  52. package/dist/linux/index.d.ts +2 -0
  53. package/dist/linux/index.js +6 -2
  54. package/dist/linux/mem-layout.js +2 -2
  55. package/dist/linux/network-interfaces.js +36 -39
  56. package/dist/linux/network-stats.js +8 -36
  57. package/dist/linux/npu.js +2 -1
  58. package/dist/linux/os-info.js +19 -4
  59. package/dist/linux/printer.js +4 -4
  60. package/dist/linux/process-load.js +9 -12
  61. package/dist/linux/processes.js +89 -80
  62. package/dist/linux/serial-ports.d.ts +2 -0
  63. package/dist/linux/serial-ports.js +102 -0
  64. package/dist/linux/services.js +179 -47
  65. package/dist/linux/system.js +1 -7
  66. package/dist/linux/uuid.js +4 -10
  67. package/dist/serial-ports.d.ts +1 -0
  68. package/dist/serial-ports.js +17 -0
  69. package/dist/versions.js +32 -77
  70. package/dist/windows/disk-layout.js +3 -0
  71. package/dist/windows/disks-io.js +3 -3
  72. package/dist/windows/displays.js +29 -12
  73. package/dist/windows/fans.d.ts +2 -0
  74. package/dist/windows/fans.js +71 -0
  75. package/dist/windows/index.d.ts +2 -0
  76. package/dist/windows/index.js +6 -2
  77. package/dist/windows/network-interfaces.js +20 -29
  78. package/dist/windows/network-stats.js +4 -2
  79. package/dist/windows/process-load.js +7 -5
  80. package/dist/windows/processes.js +17 -11
  81. package/dist/windows/serial-ports.d.ts +3 -0
  82. package/dist/windows/serial-ports.js +73 -0
  83. package/dist/windows/services.js +3 -0
  84. package/package.json +1 -1
@@ -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;
@@ -823,6 +846,7 @@ export type DisplayData = {
823
846
  positionX: number;
824
847
  positionY: number;
825
848
  currentRefreshRate: number | null;
849
+ scale: number | null;
826
850
  };
827
851
  export type GpuNvidiaData = {
828
852
  driverVersion: string;
@@ -847,8 +871,6 @@ export type ProcStatData = {
847
871
  name: string;
848
872
  utime: number;
849
873
  stime: number;
850
- cutime?: number;
851
- cstime?: number;
852
874
  cpu?: number;
853
875
  cpuu: number;
854
876
  cpus: number;
@@ -866,6 +888,7 @@ export type ServicesData = {
866
888
  name: string;
867
889
  running: boolean;
868
890
  startmode: string;
891
+ lastChanged: Date | null;
869
892
  pids: number[];
870
893
  cpu: number;
871
894
  mem: number;
@@ -884,6 +907,7 @@ export type ProcessesProcessData = {
884
907
  cpu: number;
885
908
  cpuu: number;
886
909
  cpus: number;
910
+ cpuTime: number | null;
887
911
  mem: number;
888
912
  priority: number;
889
913
  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
  }
@@ -12,6 +12,13 @@ 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
23
  ({ stdout } = await (0, exec_1.exec)(`system_profiler SPSerialATADataType SPNVMeDataType SPUSBDataType SPStorageDataType -xml`, { maxBuffer: const_1.MAX_BUFFER_SIZE }));
17
24
  const data = (0, darwin_1.plistParser)(stdout, false);
@@ -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
@@ -26,6 +26,7 @@ const parseDisplaysDarwin = (graphicsArr) => {
26
26
  displayId: displayItem['_spdisplays_displayID'] || null,
27
27
  deviceName: null,
28
28
  main: displayItem['spdisplays_main'] ? displayItem['spdisplays_main'] === 'spdisplays_yes' : false,
29
+ mirror: (displayItem['spdisplays_mirror'] || 'spdisplays_off') !== 'spdisplays_off',
29
30
  builtin: (displayItem['spdisplays_display_type'] || '').indexOf('built-in') > -1,
30
31
  connection: connectionType.indexOf('_internal') > -1 ? 'Internal' : connectionType.indexOf('_displayport') > -1 ? 'Display Port' : connectionType.indexOf('_hdmi') > -1 ? 'HDMI' : null,
31
32
  sizeX: null,
@@ -37,7 +38,8 @@ const parseDisplaysDarwin = (graphicsArr) => {
37
38
  currentResY: currentResolution.length > 1 ? parseInt(currentResolution[1], 10) : null,
38
39
  positionX: 0,
39
40
  positionY: 0,
40
- currentRefreshRate: currentResolutionParts.length > 1 ? parseInt(currentResolutionParts[1], 10) : null
41
+ currentRefreshRate: currentResolutionParts.length > 1 ? parseInt(currentResolutionParts[1], 10) : null,
42
+ scale: null
41
43
  });
42
44
  });
43
45
  }
@@ -0,0 +1,2 @@
1
+ import type { FanData } from '../common/types';
2
+ export declare const fans: () => Promise<FanData[]>;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fans = void 0;
4
+ const common_1 = require("../common");
5
+ const fans = async () => {
6
+ await (0, common_1.nextTick)();
7
+ const result = [];
8
+ try {
9
+ const macosTemp = require('macos-temperature-sensor');
10
+ if (typeof macosTemp.fans === 'function') {
11
+ const res = macosTemp.fans();
12
+ if (Array.isArray(res)) {
13
+ res.forEach((fan, index) => {
14
+ result.push({
15
+ id: `fan${index}`,
16
+ label: fan?.label || null,
17
+ rpm: typeof fan?.rpm === 'number' ? Math.round(fan.rpm) : null,
18
+ pwm: typeof fan?.pwm === 'number' ? Math.round(fan.pwm) : null,
19
+ source: 'SMC'
20
+ });
21
+ });
22
+ }
23
+ }
24
+ }
25
+ catch { }
26
+ return result;
27
+ };
28
+ exports.fans = fans;
@@ -11,6 +11,7 @@ export { cpuCache } from './cpu-cache';
11
11
  export { cpuCurrentSpeed } from '../cpu-current-speed';
12
12
  export { cpuFlags } from './cpu-flags';
13
13
  export { cpuTemperature } from './cpu-temperature';
14
+ export { fans } from './fans';
14
15
  export { currentLoad } from '../cpu-current-load';
15
16
  export { diskLayout } from './disk-layout';
16
17
  export { disksIO } from './disks-io';
@@ -45,6 +46,7 @@ export { software } from './software';
45
46
  export { system } from './system';
46
47
  export { thunderbolt } from './thunderbolt';
47
48
  export { time } from '../time';
49
+ export { serialPorts } from './serial-ports';
48
50
  export { usb } from './usb';
49
51
  export { users } from './users';
50
52
  export { uuid } from './uuid';
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.software = exports.shell = exports.services = exports.processLoad = exports.processes = exports.printer = exports.pci = exports.osInfo = exports.npu = exports.npm = exports.networkStats = exports.networkInterfaces = exports.networkInterfaceDefault = exports.networkGatewayDefault = exports.networkConnections = exports.mouse = exports.memLayout = exports.mem = exports.keyboard = exports.inetLatency = exports.inetChecksite = exports.gpu = exports.fullLoad = exports.fsStats = exports.fsSize = exports.fsOpenFiles = exports.dockerAll = exports.dockerVolumes = exports.dockerContainerProcesses = exports.dockerContainerStats = exports.dockerContainers = exports.dockerImages = exports.dockerInfo = exports.displays = exports.disksIO = exports.diskLayout = exports.currentLoad = exports.cpuTemperature = exports.cpuFlags = exports.cpuCurrentSpeed = exports.cpuCache = exports.cpu = exports.chassis = exports.camera = exports.bluetoothDevices = exports.blockDevices = exports.bios = exports.battery = exports.baseboard = exports.audio = void 0;
4
- exports.wifiNetworks = exports.wifiInterfaces = exports.wifiConnections = exports.versions = exports.version = exports.vboxInfo = exports.uuid = exports.users = exports.usb = exports.time = exports.thunderbolt = exports.system = void 0;
3
+ exports.shell = exports.services = exports.processLoad = exports.processes = exports.printer = exports.pci = exports.osInfo = exports.npu = exports.npm = exports.networkStats = exports.networkInterfaces = exports.networkInterfaceDefault = exports.networkGatewayDefault = exports.networkConnections = exports.mouse = exports.memLayout = exports.mem = exports.keyboard = exports.inetLatency = exports.inetChecksite = exports.gpu = exports.fullLoad = exports.fsStats = exports.fsSize = exports.fsOpenFiles = exports.dockerAll = exports.dockerVolumes = exports.dockerContainerProcesses = exports.dockerContainerStats = exports.dockerContainers = exports.dockerImages = exports.dockerInfo = exports.displays = exports.disksIO = exports.diskLayout = exports.currentLoad = exports.fans = exports.cpuTemperature = exports.cpuFlags = exports.cpuCurrentSpeed = exports.cpuCache = exports.cpu = exports.chassis = exports.camera = exports.bluetoothDevices = exports.blockDevices = exports.bios = exports.battery = exports.baseboard = exports.audio = void 0;
4
+ exports.wifiNetworks = exports.wifiInterfaces = exports.wifiConnections = exports.versions = exports.version = exports.vboxInfo = exports.uuid = exports.users = exports.usb = exports.serialPorts = exports.time = exports.thunderbolt = exports.system = exports.software = void 0;
5
5
  var audio_1 = require("./audio");
6
6
  Object.defineProperty(exports, "audio", { enumerable: true, get: function () { return audio_1.audio; } });
7
7
  var baseboard_1 = require("./baseboard");
@@ -28,6 +28,8 @@ var cpu_flags_1 = require("./cpu-flags");
28
28
  Object.defineProperty(exports, "cpuFlags", { enumerable: true, get: function () { return cpu_flags_1.cpuFlags; } });
29
29
  var cpu_temperature_1 = require("./cpu-temperature");
30
30
  Object.defineProperty(exports, "cpuTemperature", { enumerable: true, get: function () { return cpu_temperature_1.cpuTemperature; } });
31
+ var fans_1 = require("./fans");
32
+ Object.defineProperty(exports, "fans", { enumerable: true, get: function () { return fans_1.fans; } });
31
33
  var cpu_current_load_1 = require("../cpu-current-load");
32
34
  Object.defineProperty(exports, "currentLoad", { enumerable: true, get: function () { return cpu_current_load_1.currentLoad; } });
33
35
  var disk_layout_1 = require("./disk-layout");
@@ -102,6 +104,8 @@ var thunderbolt_1 = require("./thunderbolt");
102
104
  Object.defineProperty(exports, "thunderbolt", { enumerable: true, get: function () { return thunderbolt_1.thunderbolt; } });
103
105
  var time_1 = require("../time");
104
106
  Object.defineProperty(exports, "time", { enumerable: true, get: function () { return time_1.time; } });
107
+ var serial_ports_1 = require("./serial-ports");
108
+ Object.defineProperty(exports, "serialPorts", { enumerable: true, get: function () { return serial_ports_1.serialPorts; } });
105
109
  var usb_1 = require("./usb");
106
110
  Object.defineProperty(exports, "usb", { enumerable: true, get: function () { return usb_1.usb; } });
107
111
  var users_1 = require("./users");
@@ -187,16 +187,11 @@ const networkInterfaces = async (defaultString = '', rescan = true) => {
187
187
  ieee8021xState: '',
188
188
  carrierChanges: 0
189
189
  });
190
- _networkInterfaces = result;
191
- if (defaultString.toLowerCase().indexOf('default') >= 0) {
192
- result = result.filter((item) => item.default);
193
- if (result.length > 0) {
194
- return [result[0]];
195
- }
196
- else {
197
- result = [];
198
- }
199
- }
190
+ }
191
+ _networkInterfaces = result;
192
+ if (defaultString.toLowerCase().indexOf('default') >= 0) {
193
+ result = result.filter((item) => item.default);
194
+ return result.length ? [result[0]] : [];
200
195
  }
201
196
  }
202
197
  catch { }
@@ -10,7 +10,7 @@ const darwin_1 = require("../darwin");
10
10
  const _network = {};
11
11
  const networkStatsSingle = async (iface) => {
12
12
  await (0, common_1.nextTick)();
13
- const defaults = defaults_1.initNetworkSpeed;
13
+ const defaults = { ...defaults_1.initNetworkSpeed, iface };
14
14
  if (!_network[iface] || (_network[iface] && !_network[iface].ms) || (_network[iface] && _network[iface].ms && Date.now() - _network[iface].ms >= 500)) {
15
15
  let operstate = 'unknown';
16
16
  let rx_bytes = 0;
@@ -19,11 +19,11 @@ const networkStatsSingle = async (iface) => {
19
19
  let rx_errors = 0;
20
20
  let tx_dropped = 0;
21
21
  let tx_errors = 0;
22
- let stdout = '';
23
- ({ stdout } = await (0, exec_1.execSave)(`ifconfig ${iface} | grep "status"`));
24
- operstate = (stdout.split(':')[1] || '').trim().toLowerCase();
22
+ let stdout = await (0, exec_1.execSecure)('ifconfig', [iface]);
23
+ const statusLine = stdout.split('\n').find((l) => l.includes('status')) || '';
24
+ operstate = (statusLine.split(':')[1] || '').trim().toLowerCase();
25
25
  operstate = operstate === 'active' ? 'up' : operstate === 'inactive' ? 'down' : 'unknown';
26
- ({ stdout } = await (0, exec_1.execSave)(`netstat -bdnI ${iface}`));
26
+ stdout = await (0, exec_1.execSecure)('netstat', ['-bdnI', iface]);
27
27
  if (stdout) {
28
28
  const lines = stdout.toString().split('\n');
29
29
  if (lines.length > 1 && lines[1].trim() !== '') {
@@ -0,0 +1,2 @@
1
+ import type { SerialPortData } from '../common/types';
2
+ export declare const serialPorts: () => Promise<SerialPortData[]>;
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serialPorts = void 0;
4
+ const promises_1 = require("fs/promises");
5
+ const common_1 = require("../common");
6
+ const defaults_1 = require("../common/defaults");
7
+ const exec_1 = require("../common/exec");
8
+ const security_1 = require("../common/security");
9
+ const toHex4 = (value) => {
10
+ const num = Number.parseInt(value, 10);
11
+ return Number.isNaN(num) ? null : num.toString(16).padStart(4, '0');
12
+ };
13
+ const parseUsbPorts = (stdout) => {
14
+ const ports = new Map();
15
+ let usb = {};
16
+ for (const raw of stdout.split('\n')) {
17
+ const line = raw.replace(/\|/g, '').trim();
18
+ if (line.startsWith('+-o')) {
19
+ if (line.includes('class IOUSBHostDevice')) {
20
+ usb = {};
21
+ }
22
+ continue;
23
+ }
24
+ const entry = /^"([^"]+)" = (.+)$/.exec(line);
25
+ if (!entry) {
26
+ continue;
27
+ }
28
+ const key = entry[1];
29
+ const value = (entry[2] || '').replace(/^"|"$/g, '').trim();
30
+ switch (key) {
31
+ case 'idVendor':
32
+ usb.vendorId = toHex4(value);
33
+ break;
34
+ case 'idProduct':
35
+ usb.productId = toHex4(value);
36
+ break;
37
+ case 'USB Vendor Name':
38
+ usb.manufacturer = value || null;
39
+ break;
40
+ case 'USB Product Name':
41
+ usb.name = value || null;
42
+ break;
43
+ case 'USB Serial Number':
44
+ usb.serialNumber = value || null;
45
+ break;
46
+ case 'IOCalloutDevice':
47
+ ports.set(value, { ...usb });
48
+ break;
49
+ default:
50
+ break;
51
+ }
52
+ }
53
+ return ports;
54
+ };
55
+ const calloutDevices = (stdout) => {
56
+ const devices = new Set();
57
+ const regex = /"IOCalloutDevice" = "([^"]+)"/g;
58
+ let match = regex.exec(stdout);
59
+ while (match) {
60
+ if (match[1]) {
61
+ devices.add(match[1]);
62
+ }
63
+ match = regex.exec(stdout);
64
+ }
65
+ return devices;
66
+ };
67
+ const serialPorts = async () => {
68
+ await (0, common_1.nextTick)();
69
+ const result = [];
70
+ let devices = [];
71
+ try {
72
+ devices = (await (0, promises_1.readdir)('/dev')).filter((device) => device.startsWith('cu.') && (0, security_1.isSafePathSegment)(device));
73
+ }
74
+ catch {
75
+ return result;
76
+ }
77
+ const [usbTree, bluetoothTree] = await Promise.all([(0, exec_1.execSave)('ioreg -r -c IOUSBHostDevice -l -w0'), (0, exec_1.execSave)('ioreg -r -c IOBluetoothDevice -l -w0')]);
78
+ const usbPorts = parseUsbPorts(usbTree.stdout);
79
+ const bluetoothPorts = calloutDevices(bluetoothTree.stdout);
80
+ for (const device of devices.sort()) {
81
+ const path = `/dev/${device}`;
82
+ const usb = usbPorts.get(path);
83
+ const name = device.substring(3);
84
+ result.push({
85
+ ...(0, common_1.cloneObj)(defaults_1.initSerialPortResult),
86
+ ...usb,
87
+ device: path,
88
+ name: usb?.name || name,
89
+ type: usb ? 'usb' : bluetoothPorts.has(path) ? 'bluetooth' : 'unknown'
90
+ });
91
+ }
92
+ return result;
93
+ };
94
+ exports.serialPorts = serialPorts;
package/dist/fans.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare const fans: () => Promise<import("./common/types").FanData[] | null>;
package/dist/fans.js ADDED
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fans = void 0;
4
+ const const_1 = require("./common/const");
5
+ const fans = async () => {
6
+ switch (true) {
7
+ case const_1.LINUX || const_1.ANDROID:
8
+ return (await import('./linux/fans.js')).fans();
9
+ case const_1.DARWIN:
10
+ return (await import('./darwin/fans.js')).fans();
11
+ case const_1.WINDOWS:
12
+ return (await import('./windows/fans.js')).fans();
13
+ default:
14
+ return null;
15
+ }
16
+ };
17
+ exports.fans = fans;