systeminformation 6.0.0-beta.1 → 6.0.0-beta.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/README.md +41 -7
  2. package/dist/bsd/network-stats.js +2 -2
  3. package/dist/common/darwin.d.ts +2 -0
  4. package/dist/common/darwin.js +17 -1
  5. package/dist/common/defaults.d.ts +2 -1
  6. package/dist/common/defaults.js +21 -5
  7. package/dist/common/exec.js +1 -1
  8. package/dist/common/files.d.ts +9 -0
  9. package/dist/common/files.js +67 -3
  10. package/dist/common/filesys.d.ts +10 -0
  11. package/dist/common/filesys.js +41 -10
  12. package/dist/common/host.js +55 -3
  13. package/dist/common/mappings.js +2 -1
  14. package/dist/common/network.js +4 -4
  15. package/dist/common/nvidia.d.ts +1 -1
  16. package/dist/common/nvidia.js +4 -5
  17. package/dist/common/parse.d.ts +4 -6
  18. package/dist/common/parse.js +24 -69
  19. package/dist/common/security.d.ts +1 -0
  20. package/dist/common/security.js +3 -1
  21. package/dist/common/types.d.ts +33 -5
  22. package/dist/cpu-current-load.js +28 -6
  23. package/dist/cpu-current-speed.js +5 -3
  24. package/dist/darwin/battery.d.ts +1 -1
  25. package/dist/darwin/battery.js +15 -5
  26. package/dist/darwin/camera.js +3 -3
  27. package/dist/darwin/disk-layout.js +16 -12
  28. package/dist/darwin/disks-io.js +3 -3
  29. package/dist/darwin/displays.js +34 -1
  30. package/dist/darwin/fans.d.ts +2 -0
  31. package/dist/darwin/fans.js +28 -0
  32. package/dist/darwin/gpu.js +1 -1
  33. package/dist/darwin/index.d.ts +2 -0
  34. package/dist/darwin/index.js +6 -2
  35. package/dist/darwin/keyboard.js +4 -4
  36. package/dist/darwin/mouse.js +4 -4
  37. package/dist/darwin/network-interfaces.js +5 -10
  38. package/dist/darwin/network-stats.js +5 -5
  39. package/dist/darwin/serial-ports.d.ts +2 -0
  40. package/dist/darwin/serial-ports.js +94 -0
  41. package/dist/fans.d.ts +1 -0
  42. package/dist/fans.js +17 -0
  43. package/dist/get-data.d.ts +4 -0
  44. package/dist/get-data.js +6 -2
  45. package/dist/index.d.ts +2 -0
  46. package/dist/index.js +6 -2
  47. package/dist/linux/audio.js +59 -0
  48. package/dist/linux/baseboard.js +9 -20
  49. package/dist/linux/bios.js +6 -15
  50. package/dist/linux/camera.js +2 -1
  51. package/dist/linux/chassis.js +4 -10
  52. package/dist/linux/cpu-temperature.js +34 -19
  53. package/dist/linux/cpu.js +3 -1
  54. package/dist/linux/disk-layout.js +7 -10
  55. package/dist/linux/disks-io.js +9 -9
  56. package/dist/linux/displays.js +40 -2
  57. package/dist/linux/fans.d.ts +2 -0
  58. package/dist/linux/fans.js +92 -0
  59. package/dist/linux/fs-size.js +160 -34
  60. package/dist/linux/fs-stats.js +6 -9
  61. package/dist/linux/gpu.js +15 -15
  62. package/dist/linux/index.d.ts +2 -0
  63. package/dist/linux/index.js +6 -2
  64. package/dist/linux/mem-layout.js +2 -2
  65. package/dist/linux/network-interfaces.js +36 -39
  66. package/dist/linux/network-stats.js +8 -36
  67. package/dist/linux/npu.js +2 -1
  68. package/dist/linux/os-info.js +19 -4
  69. package/dist/linux/printer.js +4 -4
  70. package/dist/linux/process-load.js +9 -12
  71. package/dist/linux/processes.js +89 -80
  72. package/dist/linux/serial-ports.d.ts +2 -0
  73. package/dist/linux/serial-ports.js +102 -0
  74. package/dist/linux/services.js +179 -47
  75. package/dist/linux/system.js +1 -7
  76. package/dist/linux/uuid.js +4 -10
  77. package/dist/serial-ports.d.ts +1 -0
  78. package/dist/serial-ports.js +17 -0
  79. package/dist/versions.js +32 -77
  80. package/dist/windows/disk-layout.js +3 -0
  81. package/dist/windows/disks-io.js +3 -3
  82. package/dist/windows/displays.js +43 -12
  83. package/dist/windows/fans.d.ts +2 -0
  84. package/dist/windows/fans.js +71 -0
  85. package/dist/windows/index.d.ts +2 -0
  86. package/dist/windows/index.js +6 -2
  87. package/dist/windows/network-interfaces.js +20 -29
  88. package/dist/windows/network-stats.js +4 -2
  89. package/dist/windows/process-load.js +7 -5
  90. package/dist/windows/processes.js +17 -11
  91. package/dist/windows/serial-ports.d.ts +3 -0
  92. package/dist/windows/serial-ports.js +73 -0
  93. package/dist/windows/services.js +3 -0
  94. package/package.json +1 -1
@@ -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;
@@ -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.1",
3
+ "version": "6.0.0-beta.11",
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)",