systeminformation 6.0.0-beta.0 → 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 (103) hide show
  1. package/README.md +37 -7
  2. package/dist/bsd/network-stats.js +2 -2
  3. package/dist/bsd/os-info.d.ts +3 -0
  4. package/dist/bsd/os-info.js +9 -0
  5. package/dist/common/acceleration.d.ts +8 -0
  6. package/dist/common/acceleration.js +86 -0
  7. package/dist/common/defaults.d.ts +2 -1
  8. package/dist/common/defaults.js +23 -6
  9. package/dist/common/exec.js +1 -1
  10. package/dist/common/files.d.ts +9 -0
  11. package/dist/common/files.js +67 -3
  12. package/dist/common/filesys.d.ts +10 -0
  13. package/dist/common/filesys.js +41 -10
  14. package/dist/common/internet.d.ts +5 -0
  15. package/dist/common/internet.js +46 -1
  16. package/dist/common/mappings.d.ts +1 -1
  17. package/dist/common/mappings.js +1134 -1134
  18. package/dist/common/network.js +4 -4
  19. package/dist/common/nvidia.d.ts +1 -1
  20. package/dist/common/nvidia.js +4 -5
  21. package/dist/common/parse.d.ts +4 -6
  22. package/dist/common/parse.js +24 -69
  23. package/dist/common/security.d.ts +1 -0
  24. package/dist/common/security.js +3 -1
  25. package/dist/common/types.d.ts +79 -23
  26. package/dist/cpu-current-load.js +28 -6
  27. package/dist/cpu-current-speed.js +5 -3
  28. package/dist/darwin/disk-layout.js +10 -6
  29. package/dist/darwin/disks-io.js +3 -3
  30. package/dist/darwin/displays.js +3 -1
  31. package/dist/darwin/fans.d.ts +2 -0
  32. package/dist/darwin/fans.js +28 -0
  33. package/dist/darwin/index.d.ts +2 -0
  34. package/dist/darwin/index.js +6 -2
  35. package/dist/darwin/network-interfaces.js +5 -10
  36. package/dist/darwin/network-stats.js +5 -5
  37. package/dist/darwin/os-info.d.ts +1 -0
  38. package/dist/darwin/os-info.js +32 -2
  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 +6 -2
  44. package/dist/get-data.js +6 -2
  45. package/dist/index.d.ts +3 -0
  46. package/dist/index.js +8 -2
  47. package/dist/inet-public-ip.d.ts +2 -0
  48. package/dist/inet-public-ip.js +10 -0
  49. package/dist/linux/audio.js +59 -0
  50. package/dist/linux/baseboard.js +9 -20
  51. package/dist/linux/bios.js +6 -15
  52. package/dist/linux/camera.js +2 -1
  53. package/dist/linux/chassis.js +4 -10
  54. package/dist/linux/cpu-temperature.js +34 -19
  55. package/dist/linux/cpu.js +3 -1
  56. package/dist/linux/disk-layout.js +7 -10
  57. package/dist/linux/disks-io.js +9 -9
  58. package/dist/linux/displays.js +6 -1
  59. package/dist/linux/fans.d.ts +2 -0
  60. package/dist/linux/fans.js +92 -0
  61. package/dist/linux/fs-size.js +160 -34
  62. package/dist/linux/fs-stats.js +6 -9
  63. package/dist/linux/gpu.d.ts +13 -0
  64. package/dist/linux/gpu.js +111 -1
  65. package/dist/linux/index.d.ts +2 -0
  66. package/dist/linux/index.js +6 -2
  67. package/dist/linux/mem-layout.js +2 -2
  68. package/dist/linux/network-interfaces.js +36 -39
  69. package/dist/linux/network-stats.js +8 -36
  70. package/dist/linux/npu.js +2 -1
  71. package/dist/linux/os-info.js +35 -10
  72. package/dist/linux/printer.js +4 -4
  73. package/dist/linux/process-load.js +9 -12
  74. package/dist/linux/processes.js +89 -80
  75. package/dist/linux/serial-ports.d.ts +2 -0
  76. package/dist/linux/serial-ports.js +102 -0
  77. package/dist/linux/services.js +179 -47
  78. package/dist/linux/system.js +1 -7
  79. package/dist/linux/time.d.ts +2 -2
  80. package/dist/linux/time.js +3 -3
  81. package/dist/linux/uuid.js +4 -10
  82. package/dist/serial-ports.d.ts +1 -0
  83. package/dist/serial-ports.js +17 -0
  84. package/dist/time.d.ts +1 -1
  85. package/dist/versions.js +60 -77
  86. package/dist/windows/block-devices.d.ts +1 -0
  87. package/dist/windows/block-devices.js +15 -5
  88. package/dist/windows/disk-layout.js +21 -1
  89. package/dist/windows/disks-io.js +8 -5
  90. package/dist/windows/displays.js +29 -12
  91. package/dist/windows/fans.d.ts +2 -0
  92. package/dist/windows/fans.js +71 -0
  93. package/dist/windows/index.d.ts +2 -0
  94. package/dist/windows/index.js +6 -2
  95. package/dist/windows/network-interfaces.js +20 -29
  96. package/dist/windows/network-stats.js +4 -2
  97. package/dist/windows/os-info.js +5 -0
  98. package/dist/windows/process-load.js +7 -5
  99. package/dist/windows/processes.js +17 -11
  100. package/dist/windows/serial-ports.d.ts +3 -0
  101. package/dist/windows/serial-ports.js +73 -0
  102. package/dist/windows/services.js +3 -0
  103. package/package.json +1 -1
@@ -137,10 +137,10 @@ const calcNetworkSpeed = (iface, rx_bytes, tx_bytes, rx_dropped, rx_errors, tx_d
137
137
  _network[iface].tx_bytes = tx_bytes;
138
138
  _network[iface].rx_sec = null;
139
139
  _network[iface].tx_sec = null;
140
- _network[iface].rx_dropped = result.rx_dropped;
141
- _network[iface].rx_errors = result.rx_errors;
142
- _network[iface].tx_dropped = result.tx_dropped;
143
- _network[iface].tx_errors = result.tx_errors;
140
+ _network[iface].rx_dropped = rx_dropped;
141
+ _network[iface].rx_errors = rx_errors;
142
+ _network[iface].tx_dropped = tx_dropped;
143
+ _network[iface].tx_errors = tx_errors;
144
144
  _network[iface].ms = Date.now();
145
145
  _network[iface].last_ms = 0;
146
146
  _network[iface].operstate = operstate;
@@ -1,5 +1,5 @@
1
1
  import type { GpuData, GpuNvidiaData } from './types';
2
- export declare const getNvidiaSmi: () => Promise<string | null>;
2
+ export declare const getNvidiaSmi: () => Promise<string>;
3
3
  export declare const nvidiaSmi: () => Promise<string>;
4
4
  export declare const nvidiaDevices: () => Promise<({
5
5
  driverVersion: string | undefined;
@@ -22,7 +22,7 @@ const getNvidiaSmi = async () => {
22
22
  const basePath = String.raw `${const_1.WINDIR}\System32\DriverStore\FileRepository`;
23
23
  let lastMod = 0;
24
24
  for (const dir of await (0, promises_1.readdir)(basePath)) {
25
- if (!dir.toLowerCase().startsWith('nv')) {
25
+ if (!dir.toLowerCase().startsWith('nv') || !(0, security_1.isSafePathSegment)(dir)) {
26
26
  continue;
27
27
  }
28
28
  const smiPath = [basePath, dir, 'nvidia-smi.exe'].join('\\');
@@ -41,6 +41,7 @@ const getNvidiaSmi = async () => {
41
41
  else if (const_1.LINUX) {
42
42
  _nvidiaSmiPath = 'nvidia-smi';
43
43
  }
44
+ _nvidiaSmiPath = _nvidiaSmiPath || '';
44
45
  return _nvidiaSmiPath;
45
46
  };
46
47
  exports.getNvidiaSmi = getNvidiaSmi;
@@ -48,11 +49,9 @@ const nvidiaSmi = async () => {
48
49
  const nvidiaSmiExe = await (0, exports.getNvidiaSmi)();
49
50
  if (nvidiaSmiExe) {
50
51
  const nvidiaSmiOpts = '--query-gpu=driver_version,pci.sub_device_id,name,pci.bus_id,fan.speed,memory.total,memory.used,memory.free,utilization.gpu,utilization.memory,temperature.gpu,temperature.memory,power.draw,power.limit,clocks.gr,clocks.mem --format=csv,noheader,nounits';
51
- const cmd = `${nvidiaSmiExe} ${nvidiaSmiOpts}`;
52
52
  try {
53
- const sanitized = (0, security_1.sanitizeShellString)(cmd) + (const_1.LINUX ? ' 2>/dev/null' : '') + (const_1.WINDOWS ? ' 2> nul' : '');
54
- const { stdout } = await (0, exec_1.exec)(sanitized, const_1.execOptsWin);
55
- return stdout;
53
+ const { stdout } = await (0, exec_1.execFile)(nvidiaSmiExe, nvidiaSmiOpts.split(' '), const_1.execOptsWin);
54
+ return String(stdout);
56
55
  }
57
56
  catch { }
58
57
  }
@@ -1,11 +1,9 @@
1
1
  import type { CpuData, ProcStatData } from './types';
2
- export type headerType = {
3
- from: number;
4
- to: number;
5
- cap: string;
6
- };
7
- export declare const parseHead: (head: string, rights: number) => headerType[];
8
2
  export declare const parseProcStat: (line: string) => number;
3
+ export declare const clampCpuPair: (cpuu: number, cpus: number) => {
4
+ cpuu: number;
5
+ cpus: number;
6
+ };
9
7
  export declare const calcProcStatLinux: (line: string, all: number, _cpu_old: CpuData) => ProcStatData;
10
8
  export declare const parseJsonArray: (data: string) => any[];
11
9
  export declare const cleanDefaults: (str: string) => string;
@@ -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 = {
@@ -458,11 +480,19 @@ export type OsData = {
458
480
  servicepack: string;
459
481
  uefi: boolean;
460
482
  installDate: Date | null;
483
+ lastUpdate: Date | null;
461
484
  displayServer: string;
485
+ awake: boolean;
486
+ hwAcceleration: string[];
462
487
  hypervizor?: boolean;
463
488
  remoteSession?: boolean;
464
489
  hypervisor?: boolean;
465
490
  };
491
+ export type InetPublicIpData = {
492
+ ip4: string;
493
+ ip6: string;
494
+ ms: number;
495
+ };
466
496
  export type UuidData = {
467
497
  os: string;
468
498
  hardware: string;
@@ -476,33 +506,56 @@ export type VersionData = {
476
506
  systemOpensslLib?: string;
477
507
  node?: string;
478
508
  v8?: string;
479
- npm?: string;
480
- yarn?: string;
481
- pm2?: string;
482
- gulp?: string;
483
- grunt?: string;
509
+ angular?: string;
510
+ apache?: string;
511
+ bash?: string;
512
+ bun?: string;
513
+ cargo?: string;
514
+ composer?: string;
515
+ curl?: string;
516
+ deno?: string;
517
+ docker?: string;
518
+ dockerCompose?: string;
519
+ dotnet?: string;
520
+ fish?: string;
521
+ gcc?: string;
484
522
  git?: string;
485
- tsc?: string;
486
- mysql?: string;
487
- redis?: string;
523
+ go?: string;
524
+ gradle?: string;
525
+ grunt?: string;
526
+ gulp?: string;
527
+ herd?: string;
528
+ homebrew?: string;
529
+ java?: string;
530
+ laravel?: string;
531
+ maven?: string;
488
532
  mongodb?: string;
533
+ mysql?: string;
489
534
  nginx?: string;
535
+ npm?: string;
536
+ perl?: string;
490
537
  php?: string;
491
- docker?: string;
538
+ pip?: string;
539
+ pip3?: string;
540
+ pm2?: string;
541
+ podman?: string;
492
542
  postfix?: string;
493
543
  postgresql?: string;
494
- perl?: string;
544
+ powershell?: string;
495
545
  python?: string;
496
546
  python3?: string;
497
- pip?: string;
498
- pip3?: string;
499
- java?: string;
500
- gcc?: string;
547
+ rails?: string;
548
+ redis?: string;
549
+ ruby?: string;
550
+ rust?: string;
551
+ sqlite3?: string;
552
+ tsc?: string;
553
+ vi?: string;
554
+ vim?: string;
501
555
  virtualbox?: string;
502
- dotnet?: string;
503
- composer?: string;
504
- herd?: string;
505
- laravel?: string;
556
+ vue?: string;
557
+ yarn?: string;
558
+ zsh?: string;
506
559
  };
507
560
  export type SystemData = {
508
561
  manufacturer: string;
@@ -573,6 +626,7 @@ export type FsBlockDevicesData = {
573
626
  size: number;
574
627
  physical: string;
575
628
  uuid: string;
629
+ guid: string;
576
630
  label: string;
577
631
  model: string;
578
632
  serial: string;
@@ -597,9 +651,9 @@ export type DisksIoData = {
597
651
  rIO_sec: number | null;
598
652
  wIO_sec: number | null;
599
653
  tIO_sec: number | null;
600
- rWaitTime: number;
601
- wWaitTime: number;
602
- tWaitTime: number;
654
+ rWaitTime: number | null;
655
+ wWaitTime: number | null;
656
+ tWaitTime: number | null;
603
657
  rWaitPercent: number | null;
604
658
  wWaitPercent: number | null;
605
659
  tWaitPercent: number | null;
@@ -779,6 +833,7 @@ export type DisplayData = {
779
833
  deviceName: string | null;
780
834
  displayId: string | null;
781
835
  main: boolean;
836
+ mirror: boolean;
782
837
  builtin: boolean;
783
838
  connection: string | null;
784
839
  sizeX: number | null;
@@ -791,6 +846,7 @@ export type DisplayData = {
791
846
  positionX: number;
792
847
  positionY: number;
793
848
  currentRefreshRate: number | null;
849
+ scale: number | null;
794
850
  };
795
851
  export type GpuNvidiaData = {
796
852
  driverVersion: string;
@@ -815,8 +871,6 @@ export type ProcStatData = {
815
871
  name: string;
816
872
  utime: number;
817
873
  stime: number;
818
- cutime?: number;
819
- cstime?: number;
820
874
  cpu?: number;
821
875
  cpuu: number;
822
876
  cpus: number;
@@ -834,6 +888,7 @@ export type ServicesData = {
834
888
  name: string;
835
889
  running: boolean;
836
890
  startmode: string;
891
+ lastChanged: Date | null;
837
892
  pids: number[];
838
893
  cpu: number;
839
894
  mem: number;
@@ -852,6 +907,7 @@ export type ProcessesProcessData = {
852
907
  cpu: number;
853
908
  cpuu: number;
854
909
  cpus: number;
910
+ cpuTime: number | null;
855
911
  mem: number;
856
912
  priority: number;
857
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
  }