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
@@ -10,13 +10,16 @@ const disksIO = async () => {
10
10
  if ((filesys_1._disk_io && !filesys_1._disk_io.ms) || (filesys_1._disk_io && filesys_1._disk_io.ms && Date.now() - filesys_1._disk_io.ms >= 500)) {
11
11
  const defaults = (0, common_1.cloneObj)(defaults_1.initDiskIo);
12
12
  try {
13
- const data = await windows_1.ps.exec("Get-CimInstance Win32_PerfRawData_PerfDisk_PhysicalDisk -Filter \"Name='_Total'\" | Select-Object DiskReadsPersec,DiskWritesPersec | ConvertTo-Json");
13
+ const data = await windows_1.ps.exec("Get-CimInstance Win32_PerfRawData_PerfDisk_PhysicalDisk -Filter \"Name='_Total'\" | Select-Object DiskReadsPersec,DiskWritesPersec,PercentDiskReadTime,PercentDiskWriteTime,PercentDiskTime | ConvertTo-Json");
14
14
  if (!data) {
15
15
  return defaults;
16
16
  }
17
17
  const rIO = (0, common_1.toInt)(data.DiskReadsPersec);
18
18
  const wIO = (0, common_1.toInt)(data.DiskWritesPersec);
19
- return (0, filesys_1.calcDiskIO)(rIO, wIO, 0, 0, 0);
19
+ const rWaitTime = (0, common_1.toInt)(data.PercentDiskReadTime) / 10000;
20
+ const wWaitTime = (0, common_1.toInt)(data.PercentDiskWriteTime) / 10000;
21
+ const tWaitTime = (0, common_1.toInt)(data.PercentDiskTime) / 10000;
22
+ return (0, filesys_1.calcDiskIO)(rIO, wIO, rWaitTime, wWaitTime, tWaitTime);
20
23
  }
21
24
  catch {
22
25
  return defaults;
@@ -31,9 +34,9 @@ const disksIO = async () => {
31
34
  rIO_sec: filesys_1._disk_io.rIO_sec,
32
35
  wIO_sec: filesys_1._disk_io.wIO_sec,
33
36
  tIO_sec: filesys_1._disk_io.tIO_sec,
34
- rWaitTime: filesys_1._disk_io.rWaitTime,
35
- wWaitTime: filesys_1._disk_io.wWaitTime,
36
- tWaitTime: filesys_1._disk_io.tWaitTime,
37
+ rWaitTime: filesys_1._disk_io.rWaitTimeDelta,
38
+ wWaitTime: filesys_1._disk_io.wWaitTimeDelta,
39
+ tWaitTime: filesys_1._disk_io.tWaitTimeDelta,
37
40
  rWaitPercent: filesys_1._disk_io.rWaitPercent,
38
41
  wWaitPercent: filesys_1._disk_io.wWaitPercent,
39
42
  tWaitPercent: filesys_1._disk_io.tWaitPercent
@@ -5,7 +5,7 @@ const common_1 = require("../common");
5
5
  const mappings_1 = require("../common/mappings");
6
6
  const exec_1 = require("../common/exec");
7
7
  const windows_1 = require("../common/windows");
8
- const psCurrentModes = "Add-Type -AssemblyName System.Windows.Forms; if (-not ('SiDevMode' -as [Type])) { Add-Type -TypeDefinition 'using System;using System.Runtime.InteropServices;[StructLayout(LayoutKind.Sequential,CharSet=CharSet.Ansi)]public struct SIDEVMODE{[MarshalAs(UnmanagedType.ByValTStr,SizeConst=32)]public string dmDeviceName;public short dmSpecVersion;public short dmDriverVersion;public short dmSize;public short dmDriverExtra;public int dmFields;public int dmPositionX;public int dmPositionY;public int dmDisplayOrientation;public int dmDisplayFixedOutput;public short dmColor;public short dmDuplex;public short dmYResolution;public short dmTTOption;public short dmCollate;[MarshalAs(UnmanagedType.ByValTStr,SizeConst=32)]public string dmFormName;public short dmLogPixels;public int dmBitsPerPel;public int dmPelsWidth;public int dmPelsHeight;public int dmDisplayFlags;public int dmDisplayFrequency;public int dmICMMethod;public int dmICMIntent;public int dmMediaType;public int dmDitherType;public int dmReserved1;public int dmReserved2;public int dmPanningWidth;public int dmPanningHeight;}public class SiDevMode{[DllImport(\"user32.dll\",CharSet=CharSet.Ansi)]public static extern bool EnumDisplaySettings(string lpszDeviceName,int iModeNum,ref SIDEVMODE lpDevMode);}' }; [System.Windows.Forms.Screen]::AllScreens | ForEach-Object { $dm = New-Object SIDEVMODE; $dm.dmSize = [System.Runtime.InteropServices.Marshal]::SizeOf($dm); if ([SiDevMode]::EnumDisplaySettings($_.DeviceName, -1, [ref]$dm)) { $_.DeviceName + '|' + $dm.dmDisplayFrequency + '|' + $dm.dmBitsPerPel + '|' + $dm.dmPelsWidth + '|' + $dm.dmPelsHeight } }";
8
+ const psCurrentModes = "Add-Type -AssemblyName System.Windows.Forms; if (-not ('SiDevMode' -as [Type])) { Add-Type -TypeDefinition 'using System;using System.Runtime.InteropServices;[StructLayout(LayoutKind.Sequential,CharSet=CharSet.Ansi)]public struct SIDEVMODE{[MarshalAs(UnmanagedType.ByValTStr,SizeConst=32)]public string dmDeviceName;public short dmSpecVersion;public short dmDriverVersion;public short dmSize;public short dmDriverExtra;public int dmFields;public int dmPositionX;public int dmPositionY;public int dmDisplayOrientation;public int dmDisplayFixedOutput;public short dmColor;public short dmDuplex;public short dmYResolution;public short dmTTOption;public short dmCollate;[MarshalAs(UnmanagedType.ByValTStr,SizeConst=32)]public string dmFormName;public short dmLogPixels;public int dmBitsPerPel;public int dmPelsWidth;public int dmPelsHeight;public int dmDisplayFlags;public int dmDisplayFrequency;public int dmICMMethod;public int dmICMIntent;public int dmMediaType;public int dmDitherType;public int dmReserved1;public int dmReserved2;public int dmPanningWidth;public int dmPanningHeight;}public class SiDevMode{[DllImport(\"user32.dll\",CharSet=CharSet.Ansi)]public static extern bool EnumDisplaySettings(string lpszDeviceName,int iModeNum,ref SIDEVMODE lpDevMode);}' }; [System.Windows.Forms.Screen]::AllScreens | ForEach-Object { $dm = New-Object SIDEVMODE; $dm.dmSize = [System.Runtime.InteropServices.Marshal]::SizeOf($dm); if ([SiDevMode]::EnumDisplaySettings($_.DeviceName, -1, [ref]$dm)) { $_.DeviceName + '|' + $dm.dmDisplayFrequency + '|' + $dm.dmBitsPerPel + '|' + $dm.dmPelsWidth + '|' + $dm.dmPelsHeight + '|' + $dm.dmPositionX + '|' + $dm.dmPositionY } }";
9
9
  const parseLinesWindowsDisplaysPowershell = (ssections, monitors, dsections, connections, isections, currentModes) => {
10
10
  const displays = [];
11
11
  const desktopMonitors = (dsections || []).map((section) => {
@@ -33,6 +33,13 @@ const parseLinesWindowsDisplaysPowershell = (ssections, monitors, dsections, con
33
33
  const sizeY = monitor ? monitor.sizeY : '';
34
34
  const videoOutputTechnology = instanceName && connections[instanceName] !== undefined ? connections[instanceName] : '';
35
35
  const deviceName = (0, common_1.getValue)(linesScreen, 'DeviceName');
36
+ const mode = currentModes[deviceName.toLowerCase()];
37
+ const boundsWidth = (0, common_1.toInt)((0, common_1.getValue)(bounds, 'Width', ':'));
38
+ const boundsHeight = (0, common_1.toInt)((0, common_1.getValue)(bounds, 'Height', ':'));
39
+ const boundsX = (0, common_1.toInt)((0, common_1.getValue)(bounds, 'X', ':'));
40
+ const boundsY = (0, common_1.toInt)((0, common_1.getValue)(bounds, 'Y', ':'));
41
+ const resX = mode ? mode.width : boundsWidth;
42
+ const resY = mode ? mode.height : boundsHeight;
36
43
  const isection = instanceName ? isections.find((element) => element.instanceId.toLowerCase().startsWith(instanceName)) : undefined;
37
44
  const dsection = instanceName ? desktopMonitors.find((element) => element.deviceId && instanceName.startsWith(element.deviceId)) : undefined;
38
45
  displays.push({
@@ -44,18 +51,20 @@ const parseLinesWindowsDisplaysPowershell = (ssections, monitors, dsections, con
44
51
  deviceName,
45
52
  displayId: instanceName || null,
46
53
  main: hasOwnScreen ? primary.toLowerCase() === 'true' : false,
54
+ mirror: !hasOwnScreen || (monitors.length > ssections.length && i === 0),
47
55
  builtin: videoOutputTechnology === '2147483648',
48
56
  connection: videoOutputTechnology && mappings_1.graphicsVideoTypes[videoOutputTechnology] ? mappings_1.graphicsVideoTypes[videoOutputTechnology] : '',
49
- resolutionX: (0, common_1.toInt)((0, common_1.getValue)(bounds, 'Width', ':')),
50
- resolutionY: (0, common_1.toInt)((0, common_1.getValue)(bounds, 'Height', ':')),
57
+ resolutionX: resX,
58
+ resolutionY: resY,
51
59
  sizeX: sizeX ? parseInt(sizeX, 10) : null,
52
60
  sizeY: sizeY ? parseInt(sizeY, 10) : null,
53
61
  pixelDepth: bitsPerPixel,
54
- currentResX: (0, common_1.toInt)((0, common_1.getValue)(bounds, 'Width', ':')),
55
- currentResY: (0, common_1.toInt)((0, common_1.getValue)(bounds, 'Height', ':')),
56
- positionX: (0, common_1.toInt)((0, common_1.getValue)(bounds, 'X', ':')),
57
- positionY: (0, common_1.toInt)((0, common_1.getValue)(bounds, 'Y', ':')),
58
- currentRefreshRate: currentModes[deviceName.toLowerCase()] || null
62
+ currentResX: resX,
63
+ currentResY: resY,
64
+ positionX: mode ? mode.positionX : boundsX,
65
+ positionY: mode ? mode.positionY : boundsY,
66
+ currentRefreshRate: (mode && mode.refreshRate) || null,
67
+ scale: mode && boundsWidth ? Math.round((mode.width / boundsWidth) * 100) / 100 : null
59
68
  });
60
69
  }
61
70
  }
@@ -70,6 +79,7 @@ const parseLinesWindowsDisplaysPowershell = (ssections, monitors, dsections, con
70
79
  deviceName: '',
71
80
  displayId: null,
72
81
  main: true,
82
+ mirror: false,
73
83
  builtin: true,
74
84
  sizeX: null,
75
85
  sizeY: null,
@@ -81,7 +91,8 @@ const parseLinesWindowsDisplaysPowershell = (ssections, monitors, dsections, con
81
91
  currentResY: first ? first.resolutionY : 0,
82
92
  positionX: 0,
83
93
  positionY: 0,
84
- currentRefreshRate: null
94
+ currentRefreshRate: null,
95
+ scale: null
85
96
  });
86
97
  }
87
98
  return displays;
@@ -177,9 +188,15 @@ const displays = async () => {
177
188
  .split(/\n/)
178
189
  .forEach((element) => {
179
190
  const parts = element.split('|');
180
- const frequency = parts.length === 5 ? (0, common_1.toInt)(parts[1]) : 0;
181
- if (frequency > 1 && parts[0]) {
182
- currentModes[parts[0].trim().toLowerCase()] = frequency;
191
+ if (parts.length === 7 && parts[0].trim() && (0, common_1.toInt)(parts[3])) {
192
+ const frequency = (0, common_1.toInt)(parts[1]);
193
+ currentModes[parts[0].trim().toLowerCase()] = {
194
+ refreshRate: frequency > 1 ? frequency : 0,
195
+ width: (0, common_1.toInt)(parts[3]),
196
+ height: (0, common_1.toInt)(parts[4]),
197
+ positionX: (0, common_1.toInt)(parts[5]),
198
+ positionY: (0, common_1.toInt)(parts[6])
199
+ };
183
200
  }
184
201
  });
185
202
  result = parseLinesWindowsDisplaysPowershell(ssections, monitors, dsections, connections, isections, currentModes);
@@ -0,0 +1,2 @@
1
+ import type { FanData } from '../common/types';
2
+ export declare const fans: () => Promise<FanData[]>;
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fans = void 0;
4
+ const common_1 = require("../common");
5
+ const windows_1 = require("../common/windows");
6
+ const HARDWARE_MONITORS = [
7
+ { namespace: 'root\\LibreHardwareMonitor', source: 'LibreHardwareMonitor' },
8
+ { namespace: 'root\\OpenHardwareMonitor', source: 'OpenHardwareMonitor' }
9
+ ];
10
+ const toNumber = (value) => {
11
+ const result = Number.parseFloat(value);
12
+ return Number.isNaN(result) ? null : result;
13
+ };
14
+ const win32Fans = async () => {
15
+ const fans = [];
16
+ try {
17
+ const entries = (0, windows_1.psArray)(await windows_1.ps.exec('Get-CimInstance Win32_Fan | Select-Object DeviceID,Name,DesiredSpeed | ConvertTo-Json -compress'));
18
+ entries.forEach((entry, index) => {
19
+ const rpm = toNumber(entry?.DesiredSpeed);
20
+ fans.push({
21
+ id: entry?.DeviceID || `fan${index}`,
22
+ label: entry?.Name || null,
23
+ rpm: rpm && rpm > 0 ? rpm : null,
24
+ pwm: null,
25
+ source: 'Win32_Fan'
26
+ });
27
+ });
28
+ }
29
+ catch { }
30
+ return fans;
31
+ };
32
+ const monitorFans = async (namespace, source) => {
33
+ const fans = [];
34
+ try {
35
+ const entries = (0, windows_1.psArray)(await windows_1.ps.exec(`Get-CimInstance -Namespace "${namespace}" -ClassName Sensor | Where-Object { $_.SensorType -eq 'Fan' -or $_.SensorType -eq 'Control' } | Select-Object Identifier,Name,SensorType,Value | ConvertTo-Json -compress`));
36
+ const controls = {};
37
+ entries.forEach((entry) => {
38
+ const value = toNumber(entry?.Value);
39
+ if (entry?.SensorType === 'Control' && entry?.Identifier && value !== null) {
40
+ controls[String(entry.Identifier).replace('/control/', '/fan/')] = Math.round(value);
41
+ }
42
+ });
43
+ entries.forEach((entry, index) => {
44
+ if (entry?.SensorType !== 'Fan') {
45
+ return;
46
+ }
47
+ const identifier = entry?.Identifier ? String(entry.Identifier) : `fan${index}`;
48
+ const pwm = controls[identifier];
49
+ fans.push({
50
+ id: identifier,
51
+ label: entry?.Name || null,
52
+ rpm: toNumber(entry?.Value),
53
+ pwm: pwm === undefined ? null : pwm,
54
+ source
55
+ });
56
+ });
57
+ }
58
+ catch { }
59
+ return fans;
60
+ };
61
+ const fans = async () => {
62
+ await (0, common_1.nextTick)();
63
+ for (const monitor of HARDWARE_MONITORS) {
64
+ const result = await monitorFans(monitor.namespace, monitor.source);
65
+ if (result.length) {
66
+ return result;
67
+ }
68
+ }
69
+ return win32Fans();
70
+ };
71
+ exports.fans = fans;
@@ -19,6 +19,7 @@ export { cpu } from './cpu';
19
19
  export { cpuCache } from './cpu-cache';
20
20
  export { cpuFlags } from './cpu-flags';
21
21
  export { cpuTemperature } from './cpu-temperature';
22
+ export { fans } from './fans';
22
23
  export { diskLayout } from './disk-layout';
23
24
  export { disksIO } from './disks-io';
24
25
  export { displays } from './displays';
@@ -48,6 +49,7 @@ export { shell } from './shell';
48
49
  export { software } from './software';
49
50
  export { system } from './system';
50
51
  export { thunderbolt } from './thunderbolt';
52
+ export { serialPorts } from './serial-ports';
51
53
  export { usb } from './usb';
52
54
  export { users } from './users';
53
55
  export { uuid } from './uuid';
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.processLoad = 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.gpu = exports.fsStats = exports.fsSize = exports.fsOpenFiles = exports.displays = exports.disksIO = exports.diskLayout = exports.cpuTemperature = exports.cpuFlags = exports.cpuCache = exports.cpu = exports.chassis = exports.camera = exports.bluetoothDevices = exports.blockDevices = exports.bios = exports.battery = exports.baseboard = exports.audio = exports.vboxInfo = exports.versions = exports.version = exports.time = exports.inetChecksite = exports.dockerVolumes = exports.dockerInfo = exports.dockerImages = exports.dockerContainerStats = exports.dockerContainers = exports.dockerContainerProcesses = exports.dockerAll = exports.fullLoad = exports.cpuCurrentSpeed = exports.currentLoad = void 0;
4
- exports.wifiNetworks = exports.wifiInterfaces = exports.wifiConnections = exports.uuid = exports.users = exports.usb = exports.thunderbolt = exports.system = exports.software = exports.shell = exports.services = exports.processes = void 0;
3
+ 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.gpu = exports.fsStats = exports.fsSize = exports.fsOpenFiles = exports.displays = exports.disksIO = exports.diskLayout = exports.fans = exports.cpuTemperature = exports.cpuFlags = exports.cpuCache = exports.cpu = exports.chassis = exports.camera = exports.bluetoothDevices = exports.blockDevices = exports.bios = exports.battery = exports.baseboard = exports.audio = exports.vboxInfo = exports.versions = exports.version = exports.time = exports.inetChecksite = exports.dockerVolumes = exports.dockerInfo = exports.dockerImages = exports.dockerContainerStats = exports.dockerContainers = exports.dockerContainerProcesses = exports.dockerAll = exports.fullLoad = exports.cpuCurrentSpeed = exports.currentLoad = void 0;
4
+ exports.wifiNetworks = exports.wifiInterfaces = exports.wifiConnections = exports.uuid = exports.users = exports.usb = exports.serialPorts = exports.thunderbolt = exports.system = exports.software = exports.shell = exports.services = exports.processes = exports.processLoad = void 0;
5
5
  var cpu_current_load_1 = require("../cpu-current-load");
6
6
  Object.defineProperty(exports, "currentLoad", { enumerable: true, get: function () { return cpu_current_load_1.currentLoad; } });
7
7
  var cpu_current_speed_1 = require("../cpu-current-speed");
@@ -50,6 +50,8 @@ var cpu_flags_1 = require("./cpu-flags");
50
50
  Object.defineProperty(exports, "cpuFlags", { enumerable: true, get: function () { return cpu_flags_1.cpuFlags; } });
51
51
  var cpu_temperature_1 = require("./cpu-temperature");
52
52
  Object.defineProperty(exports, "cpuTemperature", { enumerable: true, get: function () { return cpu_temperature_1.cpuTemperature; } });
53
+ var fans_1 = require("./fans");
54
+ Object.defineProperty(exports, "fans", { enumerable: true, get: function () { return fans_1.fans; } });
53
55
  var disk_layout_1 = require("./disk-layout");
54
56
  Object.defineProperty(exports, "diskLayout", { enumerable: true, get: function () { return disk_layout_1.diskLayout; } });
55
57
  var disks_io_1 = require("./disks-io");
@@ -108,6 +110,8 @@ var system_1 = require("./system");
108
110
  Object.defineProperty(exports, "system", { enumerable: true, get: function () { return system_1.system; } });
109
111
  var thunderbolt_1 = require("./thunderbolt");
110
112
  Object.defineProperty(exports, "thunderbolt", { enumerable: true, get: function () { return thunderbolt_1.thunderbolt; } });
113
+ var serial_ports_1 = require("./serial-ports");
114
+ Object.defineProperty(exports, "serialPorts", { enumerable: true, get: function () { return serial_ports_1.serialPorts; } });
111
115
  var usb_1 = require("./usb");
112
116
  Object.defineProperty(exports, "usb", { enumerable: true, get: function () { return usb_1.usb; } });
113
117
  var users_1 = require("./users");
@@ -149,8 +149,8 @@ const getWindowsWiredProfilesInformation = async () => {
149
149
  };
150
150
  const getWindowsWirelessIfaceSSID = async (interfaceName) => {
151
151
  try {
152
- const { stdout } = await (0, exec_1.exec)(`netsh wlan show interface name="${interfaceName}" | findstr "SSID"`, const_1.execOptsWin);
153
- const SSID = stdout.split('\r\n')[0];
152
+ const { stdout } = await (0, exec_1.execFile)('netsh', ['wlan', 'show', 'interface', `name=${(0, security_1.sanitizeString)(interfaceName)}`], const_1.execOptsWin);
153
+ const SSID = String(stdout).split('\r\n').find((l) => l.includes('SSID')) || '';
154
154
  const parseSSID = (SSID.split(':').pop() || '').trim();
155
155
  return parseSSID;
156
156
  }
@@ -197,11 +197,10 @@ const getWindowsIEEE8021x = async (connectionType, iface, interfaces) => {
197
197
  let i8021xState = '';
198
198
  let i8021xProtocol = '';
199
199
  try {
200
- const SSID = await getWindowsWirelessIfaceSSID((0, security_1.sanitizeString)(iface));
200
+ const SSID = await getWindowsWirelessIfaceSSID(iface);
201
201
  if (SSID !== 'Unknown') {
202
- const ifaceSanitized = (0, security_1.sanitizeString)(SSID);
203
- const { stdout } = await (0, exec_1.exec)(`netsh wlan show profiles "${ifaceSanitized}"`, const_1.execOptsWin);
204
- const profiles = stdout.split('\r\n');
202
+ const { stdout } = await (0, exec_1.execFile)('netsh', ['wlan', 'show', 'profiles', (0, security_1.sanitizeString)(SSID)], const_1.execOptsWin);
203
+ const profiles = String(stdout).split('\r\n');
205
204
  i8021xState = (profiles.find((l) => l.indexOf('802.1X') >= 0) || '').trim();
206
205
  i8021xProtocol = (profiles.find((l) => l.indexOf('EAP') >= 0) || '').trim();
207
206
  }
@@ -234,18 +233,9 @@ const networkInterfaces = async (defaultString = '', rescan = true) => {
234
233
  const defaultInterface = await (0, network_interface_default_1.networkInterfaceDefault)();
235
234
  const nics = await getWindowsNics();
236
235
  nics.forEach((nic) => {
237
- let found = false;
238
- Object.keys(interfaces).forEach((key) => {
239
- if (!found) {
240
- (interfaces[key] || []).forEach((value) => {
241
- if (Object.keys(value).indexOf('mac') >= 0) {
242
- found = value['mac'] === nic.mac;
243
- }
244
- });
245
- }
246
- });
247
- if (!found) {
248
- interfaces[nic.name] = [{ mac: nic.mac }];
236
+ const name = nic.iface || nic.name;
237
+ if (name && !Object.keys(interfaces).some((key) => key.toLowerCase() === name.toLowerCase())) {
238
+ interfaces[name] = [{ mac: nic.mac }];
249
239
  }
250
240
  });
251
241
  const nics8021xInfo = await getWindowsWiredProfilesInformation();
@@ -280,18 +270,19 @@ const networkInterfaces = async (defaultString = '', rescan = true) => {
280
270
  mac = details.mac;
281
271
  });
282
272
  dnsSuffix = getWindowsIfaceDNSsuffix(dnsSuffixes.interfaces, ifaceSanitized);
283
- let foundFirst = false;
284
- nics.forEach((detail) => {
285
- if (detail.mac === mac && !foundFirst) {
286
- iface = detail.iface || iface;
287
- ifaceName = detail.name;
288
- dhcp = detail.dhcp;
289
- operstate = detail.operstate;
290
- speed = operstate === 'up' ? detail.speed : 0;
291
- type = detail.type;
292
- foundFirst = true;
273
+ const detail = nics.find((nic) => (nic.iface || '').toLowerCase() === dev.toLowerCase() || (nic.name || '').toLowerCase() === dev.toLowerCase()) ||
274
+ (mac ? nics.find((nic) => nic.mac === mac) : undefined);
275
+ if (detail) {
276
+ iface = detail.iface || iface;
277
+ ifaceName = detail.name;
278
+ dhcp = detail.dhcp;
279
+ operstate = detail.operstate;
280
+ speed = operstate === 'up' ? detail.speed : 0;
281
+ type = detail.type;
282
+ if (!mac) {
283
+ mac = detail.mac;
293
284
  }
294
- });
285
+ }
295
286
  if (dev.toLowerCase().indexOf('wlan') >= 0 ||
296
287
  ifaceName.toLowerCase().indexOf('wlan') >= 0 ||
297
288
  ifaceName.toLowerCase().indexOf('802.11n') >= 0 ||
@@ -32,7 +32,7 @@ const parseLinesWindowsPerfData = (sections) => {
32
32
  };
33
33
  const networkStatsSingle = async (iface) => {
34
34
  await (0, common_1.nextTick)();
35
- const defaults = defaults_1.initNetworkSpeed;
35
+ const defaults = { ...defaults_1.initNetworkSpeed, iface };
36
36
  if (!_network[iface] || (_network[iface] && !_network[iface].ms) || (_network[iface] && _network[iface].ms && Date.now() - _network[iface].ms >= 500)) {
37
37
  let operstate = 'unknown';
38
38
  let rx_bytes = 0;
@@ -43,6 +43,7 @@ const networkStatsSingle = async (iface) => {
43
43
  let tx_errors = 0;
44
44
  let perfData = [];
45
45
  let ifaceName = iface;
46
+ let found = false;
46
47
  try {
47
48
  const stdout = String((await windows_1.ps.exec('Get-NetAdapterStatistics | select Name,InterfaceDescription,ReceivedBytes,ReceivedPacketErrors,ReceivedDiscardedPackets,SentBytes,OutboundPacketErrors,OutboundDiscardedPackets | fl')) || '');
48
49
  if (stdout) {
@@ -73,6 +74,7 @@ const networkStatsSingle = async (iface) => {
73
74
  .replace(/[()[\] ]+/g, '')
74
75
  .replace(/#|\//g, '_')
75
76
  .toLowerCase() === detail.desc)) {
77
+ found = true;
76
78
  ifaceName = det.iface;
77
79
  rx_bytes = detail.rx_bytes;
78
80
  rx_dropped = detail.rx_dropped;
@@ -84,7 +86,7 @@ const networkStatsSingle = async (iface) => {
84
86
  }
85
87
  });
86
88
  });
87
- if (rx_bytes && tx_bytes) {
89
+ if (found) {
88
90
  return (0, network_1.calcNetworkSpeed)(ifaceName, rx_bytes, tx_bytes, rx_dropped, rx_errors, tx_dropped, tx_errors, operstate, _network);
89
91
  }
90
92
  return defaults;
@@ -32,6 +32,7 @@ const osInfo = async () => {
32
32
  workload.push(windows_1.ps.exec('reg query "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion" /v DisplayVersion'));
33
33
  workload.push(windows_1.ps.exec("(Get-CimInstance Win32_OperatingSystem).InstallDate.ToString('yyyy-MM-ddTHH:mm:ss')"));
34
34
  workload.push(windows_1.ps.exec('[bool](Get-Process dwm -ErrorAction SilentlyContinue)'));
35
+ workload.push(windows_1.ps.exec("Get-HotFix | Where-Object { $_.Description -match 'Update' } | Sort-Object InstalledOn -Descending | Select-Object -First 1 -ExpandProperty InstalledOn | ForEach-Object { $_.ToString('yyyy-MM-ddTHH:mm:ss') }"));
35
36
  const data = await Promise.allSettled(workload).then((results) => results.map((result) => (result.status === 'fulfilled' ? result.value : null)));
36
37
  const lines = data[0] ? data[0].toString().split('\r\n') : [''];
37
38
  result.distro = (0, common_1.getValue)(lines, 'Caption', ':').trim();
@@ -58,6 +59,10 @@ const osInfo = async () => {
58
59
  result.installDate = Number.isNaN(installDate.getTime()) ? null : installDate;
59
60
  }
60
61
  result.displayServer = data[5] && data[5].toString().toLowerCase().indexOf('true') >= 0 ? 'dwm' : '';
62
+ if (data[6]) {
63
+ const lastUpdate = new Date(data[6].toString().trim());
64
+ result.lastUpdate = Number.isNaN(lastUpdate.getTime()) ? null : lastUpdate;
65
+ }
61
66
  }
62
67
  catch { }
63
68
  return result;
@@ -20,20 +20,22 @@ const processLoad = async (proc) => {
20
20
  if (!(0, security_1.isPrototypePolluted)()) {
21
21
  const processes = (0, security_1.sanitizeServiceString)(proc);
22
22
  if (processes.length) {
23
+ const cpuBaseline = { ..._process_cpu };
23
24
  try {
24
25
  const processArray = (0, windows_1.psArray)(await windows_1.ps.exec('Get-CimInstance Win32_Process | select ProcessId,Caption,UserModeTime,KernelModeTime,WorkingSetSize | ConvertTo-Json -compress'));
25
26
  const procStats = [];
26
27
  const list_new = {};
27
- let allcpuu = 0;
28
- let allcpus = 0;
28
+ let allcpuu = cpuBaseline.all_utime;
29
+ let allcpus = cpuBaseline.all_stime;
29
30
  processArray.forEach((element) => {
30
31
  const pid = element.ProcessId;
31
32
  const name = element.Caption;
32
33
  const utime = element.UserModeTime;
33
34
  const stime = element.KernelModeTime;
34
35
  const mem = element.WorkingSetSize;
35
- allcpuu = allcpuu + utime;
36
- allcpus = allcpus + stime;
36
+ const cpuOld = cpuBaseline.list[pid];
37
+ allcpuu += utime - (cpuOld ? cpuOld.utime : 0);
38
+ allcpus += stime - (cpuOld ? cpuOld.stime : 0);
37
39
  procStats.push({
38
40
  pid: pid,
39
41
  name,
@@ -89,7 +91,7 @@ const processLoad = async (proc) => {
89
91
  });
90
92
  }
91
93
  procStats.forEach((element) => {
92
- const resultProcess = (0, processes_1.calcProcStatWin)(element, allcpuu + allcpus, _process_cpu);
94
+ const resultProcess = (0, processes_1.calcProcStatWin)(element, allcpuu + allcpus, cpuBaseline);
93
95
  let listPos = -1;
94
96
  for (let j = 0; j < result.length; j++) {
95
97
  if (result[j].pid === resultProcess.pid || result[j].pids.indexOf(resultProcess.pid) >= 0) {
@@ -6,6 +6,7 @@ const common_1 = require("../common");
6
6
  const defaults_1 = require("../common/defaults");
7
7
  const mappings_1 = require("../common/mappings");
8
8
  const windows_1 = require("../common/windows");
9
+ const parse_1 = require("../common/parse");
9
10
  const _processes_cpu = {
10
11
  all: 0,
11
12
  all_utime: 0,
@@ -18,19 +19,21 @@ const calcProcStatWin = (procStat, all, _cpu_old) => {
18
19
  let cpuu = 0;
19
20
  let cpus = 0;
20
21
  if (_cpu_old.all > 0 && _cpu_old.list[procStat.pid]) {
21
- cpuu = ((procStat.utime - _cpu_old.list[procStat.pid].utime) / (all - _cpu_old.all)) * 100;
22
- cpus = ((procStat.stime - _cpu_old.list[procStat.pid].stime) / (all - _cpu_old.all)) * 100;
22
+ const delta = all - _cpu_old.all;
23
+ cpuu = delta > 0 ? ((procStat.utime - _cpu_old.list[procStat.pid].utime) / delta) * 100 : 0;
24
+ cpus = delta > 0 ? ((procStat.stime - _cpu_old.list[procStat.pid].stime) / delta) * 100 : 0;
23
25
  }
24
26
  else {
25
- cpuu = (procStat.utime / all) * 100;
26
- cpus = (procStat.stime / all) * 100;
27
+ cpuu = all > 0 ? (procStat.utime / all) * 100 : 0;
28
+ cpus = all > 0 ? (procStat.stime / all) * 100 : 0;
27
29
  }
30
+ const clamped = (0, parse_1.clampCpuPair)(cpuu, cpus);
28
31
  return {
29
32
  pid: procStat.pid,
30
33
  utime: procStat.utime,
31
34
  stime: procStat.stime,
32
- cpuu: cpuu > 0 ? cpuu : 0,
33
- cpus: cpus > 0 ? cpus : 0
35
+ cpuu: clamped.cpuu,
36
+ cpus: clamped.cpus
34
37
  };
35
38
  };
36
39
  exports.calcProcStatWin = calcProcStatWin;
@@ -38,6 +41,7 @@ const processes = async () => {
38
41
  await (0, common_1.nextTick)();
39
42
  const result = (0, common_1.cloneObj)(defaults_1.initProcesses);
40
43
  if ((_processes_cpu.ms && Date.now() - _processes_cpu.ms >= 500) || _processes_cpu.ms === 0) {
44
+ const cpuBaseline = { ..._processes_cpu };
41
45
  try {
42
46
  const processArray = (0, windows_1.psArray)(await windows_1.ps.exec(`Get-CimInstance Win32_Process | select-Object ProcessId,ParentProcessId,ExecutionState,Caption,CommandLine,ExecutablePath,UserModeTime,KernelModeTime,WorkingSetSize,Priority,PageFileUsage,
43
47
  @{n="CreationDate";e={$_.CreationDate.ToString("yyyy-MM-dd HH:mm:ss")}} | ConvertTo-Json -compress`));
@@ -45,8 +49,8 @@ const processes = async () => {
45
49
  const procs = [];
46
50
  const procStats = [];
47
51
  const list_new = {};
48
- let allcpuu = 0;
49
- let allcpus = 0;
52
+ let allcpuu = cpuBaseline.all_utime;
53
+ let allcpus = cpuBaseline.all_stime;
50
54
  processArray.forEach((element) => {
51
55
  const pid = element.ProcessId;
52
56
  const parentPid = element.ParentProcessId;
@@ -57,8 +61,9 @@ const processes = async () => {
57
61
  const utime = element.UserModeTime;
58
62
  const stime = element.KernelModeTime;
59
63
  const memw = element.WorkingSetSize;
60
- allcpuu = allcpuu + utime;
61
- allcpus = allcpus + stime;
64
+ const cpuOld = cpuBaseline.list[pid];
65
+ allcpuu += utime - (cpuOld ? cpuOld.utime : 0);
66
+ allcpus += stime - (cpuOld ? cpuOld.stime : 0);
62
67
  result.all++;
63
68
  if (!statusValue) {
64
69
  result.unknown++;
@@ -85,6 +90,7 @@ const processes = async () => {
85
90
  cpu: 0,
86
91
  cpuu: 0,
87
92
  cpus: 0,
93
+ cpuTime: (utime + stime) / 1e7,
88
94
  mem: (memw / (0, node_os_1.totalmem)()) * 100,
89
95
  priority: element.Priority || 0,
90
96
  memVsz: element.PageFileUsage || null,
@@ -102,7 +108,7 @@ const processes = async () => {
102
108
  result.sleeping = result.all - result.running - result.blocked - result.unknown;
103
109
  result.list = procs;
104
110
  procStats.forEach((element) => {
105
- const resultProcess = (0, exports.calcProcStatWin)(element, allcpuu + allcpus, _processes_cpu);
111
+ const resultProcess = (0, exports.calcProcStatWin)(element, allcpuu + allcpus, cpuBaseline);
106
112
  const listPos = result.list
107
113
  .map((e) => {
108
114
  return e.pid;
@@ -0,0 +1,3 @@
1
+ import type { SerialPortData } from '../common/types';
2
+ export declare const parseSerialPorts: (devices: any[]) => SerialPortData[];
3
+ export declare const serialPorts: () => Promise<SerialPortData[]>;
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serialPorts = exports.parseSerialPorts = void 0;
4
+ const common_1 = require("../common");
5
+ const defaults_1 = require("../common/defaults");
6
+ const windows_1 = require("../common/windows");
7
+ const matchId = (deviceId, key) => {
8
+ const match = new RegExp(`${key}_([0-9A-Fa-f]{4})`).exec(deviceId);
9
+ return match?.[1] ? match[1].toLowerCase() : null;
10
+ };
11
+ const parseSerial = (deviceId) => {
12
+ const ftdi = /PID_[0-9A-Fa-f]{4}\+([^+\\]+)/.exec(deviceId);
13
+ if (ftdi?.[1]) {
14
+ return ftdi[1];
15
+ }
16
+ const last = deviceId.split('\\').pop() || '';
17
+ return last && !last.includes('&') ? last : null;
18
+ };
19
+ const parseType = (deviceId) => {
20
+ const id = deviceId.toUpperCase();
21
+ if (id.startsWith('USB\\') || id.startsWith('FTDIBUS\\')) {
22
+ return 'usb';
23
+ }
24
+ if (id.startsWith('BTHENUM') || id.startsWith('BTHLE')) {
25
+ return 'bluetooth';
26
+ }
27
+ if (id.startsWith('PCI\\')) {
28
+ return 'pci';
29
+ }
30
+ if (id.startsWith('ACPI\\')) {
31
+ return 'onboard';
32
+ }
33
+ if (id.startsWith('ROOT\\') || id.startsWith('SW\\') || id.startsWith('UMB\\')) {
34
+ return 'virtual';
35
+ }
36
+ return 'unknown';
37
+ };
38
+ const parseSerialPorts = (devices) => {
39
+ const result = [];
40
+ for (const device of devices) {
41
+ const name = (device.Name || '').trim();
42
+ const port = /\((COM\d+)\)/.exec(name);
43
+ if (!port?.[1]) {
44
+ continue;
45
+ }
46
+ const deviceId = device.DeviceID || device.PNPDeviceID || '';
47
+ const type = parseType(deviceId);
48
+ result.push({
49
+ ...(0, common_1.cloneObj)(defaults_1.initSerialPortResult),
50
+ device: port[1],
51
+ name: name.replace(/\s*\(COM\d+\)\s*$/, '') || port[1],
52
+ manufacturer: (device.Manufacturer || '').trim() || null,
53
+ serialNumber: type === 'usb' ? parseSerial(deviceId) : null,
54
+ vendorId: matchId(deviceId, 'VID'),
55
+ productId: matchId(deviceId, 'PID'),
56
+ pnpId: deviceId || null,
57
+ type
58
+ });
59
+ }
60
+ return result;
61
+ };
62
+ exports.parseSerialPorts = parseSerialPorts;
63
+ const serialPorts = async () => {
64
+ await (0, common_1.nextTick)();
65
+ try {
66
+ const result = await windows_1.ps.exec(`@(Get-CimInstance Win32_PnPEntity -Filter "Name LIKE '%(COM%'" | Select-Object Name,DeviceID,Manufacturer) | ConvertTo-Json -Depth 3`);
67
+ return (0, exports.parseSerialPorts)((0, windows_1.psArray)(result));
68
+ }
69
+ catch {
70
+ return [];
71
+ }
72
+ };
73
+ exports.serialPorts = serialPorts;
@@ -36,6 +36,7 @@ const services = async (srv) => {
36
36
  name: srvName,
37
37
  running: started.toLowerCase() === 'true',
38
38
  startmode: startMode,
39
+ lastChanged: null,
39
40
  pids: [pid],
40
41
  cpu: 0,
41
42
  mem: 0
@@ -54,6 +55,7 @@ const services = async (srv) => {
54
55
  name: srvName,
55
56
  running: false,
56
57
  startmode: '',
58
+ lastChanged: null,
57
59
  pids: [],
58
60
  cpu: 0,
59
61
  mem: 0
@@ -68,6 +70,7 @@ const services = async (srv) => {
68
70
  name: srvName,
69
71
  running: false,
70
72
  startmode: '',
73
+ lastChanged: null,
71
74
  pids: [],
72
75
  cpu: 0,
73
76
  mem: 0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "systeminformation",
3
- "version": "6.0.0-beta.0",
3
+ "version": "6.0.0-beta.10",
4
4
  "description": "Advanced, lightweight system and OS information library",
5
5
  "license": "MIT",
6
6
  "author": "Sebastian Hildebrandt <hildebrandt@plus-innovations.com> (https://plus-innovations.com)",