systeminformation 6.0.0-beta.24 → 6.0.0-beta.25
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.
- package/README.md +47 -5
- package/dist/bsd/index.d.ts +2 -0
- package/dist/bsd/index.js +5 -1
- package/dist/common/defaults.js +15 -4
- package/dist/common/disk-speed.d.ts +20 -0
- package/dist/common/disk-speed.js +142 -0
- package/dist/common/filesys.d.ts +1 -1
- package/dist/common/filesys.js +24 -4
- package/dist/common/mappings.d.ts +1 -1
- package/dist/common/mappings.js +14 -4
- package/dist/common/types.d.ts +32 -0
- package/dist/common/windows.d.ts +1 -0
- package/dist/common/windows.js +19 -5
- package/dist/cpu-current-load.js +45 -0
- package/dist/cpu-current-speed.js +6 -0
- package/dist/darwin/cpu-current-speed.d.ts +2 -0
- package/dist/darwin/cpu-current-speed.js +30 -0
- package/dist/darwin/cpu-temperature.js +7 -13
- package/dist/darwin/disk-speed.d.ts +2 -0
- package/dist/darwin/disk-speed.js +18 -0
- package/dist/darwin/disks-io.js +3 -1
- package/dist/darwin/fans.js +11 -13
- package/dist/darwin/gpu.d.ts +1 -1
- package/dist/darwin/gpu.js +4 -4
- package/dist/darwin/index.d.ts +2 -0
- package/dist/darwin/index.js +6 -2
- package/dist/darwin/network-interfaces.js +14 -4
- package/dist/darwin/network-routes.d.ts +3 -0
- package/dist/darwin/network-routes.js +74 -0
- package/dist/disk-speed.d.ts +1 -0
- package/dist/disk-speed.js +17 -0
- package/dist/get.js +5 -5
- package/dist/index.d.ts +11 -8
- package/dist/index.js +28 -21
- package/dist/linux/block-devices.d.ts +1 -1
- package/dist/linux/block-devices.js +21 -5
- package/dist/linux/cpu-topology.d.ts +2 -0
- package/dist/linux/cpu-topology.js +15 -0
- package/dist/linux/disk-speed.d.ts +2 -0
- package/dist/linux/disk-speed.js +16 -0
- package/dist/linux/disks-io.d.ts +1 -1
- package/dist/linux/disks-io.js +18 -7
- package/dist/linux/index.d.ts +2 -0
- package/dist/linux/index.js +6 -2
- package/dist/linux/mem.js +20 -1
- package/dist/linux/network-interfaces.js +18 -7
- package/dist/linux/network-routes.d.ts +4 -0
- package/dist/linux/network-routes.js +69 -0
- package/dist/linux/os-info.js +32 -4
- package/dist/linux/pci.d.ts +1 -1
- package/dist/linux/pci.js +4 -3
- package/dist/network-routes.d.ts +1 -0
- package/dist/network-routes.js +17 -0
- package/dist/powershell.d.ts +2 -0
- package/dist/powershell.js +15 -0
- package/dist/windows/block-devices.js +6 -1
- package/dist/windows/cpu-topology.d.ts +3 -0
- package/dist/windows/cpu-topology.js +90 -0
- package/dist/windows/disk-speed.d.ts +6 -0
- package/dist/windows/disk-speed.js +73 -0
- package/dist/windows/disks-io.js +3 -1
- package/dist/windows/index.d.ts +2 -0
- package/dist/windows/index.js +6 -2
- package/dist/windows/network-interfaces.js +6 -3
- package/dist/windows/network-routes.d.ts +3 -0
- package/dist/windows/network-routes.js +41 -0
- package/package.json +1 -1
package/dist/common/windows.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.windowsPciBusAddresses = exports.matchPnpLocation = exports.parseWindowsPnpLocations = exports.parseWindowsLocationInfo = exports.ps = exports.psArray = void 0;
|
|
4
4
|
const node_child_process_1 = require("node:child_process");
|
|
5
|
-
const exec_1 = require("./exec");
|
|
6
5
|
const files_1 = require("../common/files");
|
|
7
6
|
const const_1 = require("./const");
|
|
7
|
+
const exec_1 = require("./exec");
|
|
8
8
|
const JOB_TIMEOUT_MS = 60000;
|
|
9
9
|
let _powerShell = '';
|
|
10
10
|
const pickPowerShellExecutable = async () => {
|
|
@@ -243,6 +243,7 @@ class PowerShellPool {
|
|
|
243
243
|
workers;
|
|
244
244
|
_rr;
|
|
245
245
|
_started;
|
|
246
|
+
_generation;
|
|
246
247
|
constructor({ size = 2, env = { LANG: 'en_US.UTF-8' } } = {}) {
|
|
247
248
|
this.size = Math.max(1, Math.trunc(size));
|
|
248
249
|
this.env = env;
|
|
@@ -250,18 +251,24 @@ class PowerShellPool {
|
|
|
250
251
|
this._rr = 0;
|
|
251
252
|
this.exe = '';
|
|
252
253
|
this._started = null;
|
|
254
|
+
this._generation = 0;
|
|
253
255
|
}
|
|
254
256
|
start() {
|
|
255
257
|
if (!this._started) {
|
|
258
|
+
const generation = ++this._generation;
|
|
256
259
|
this._started = (async () => {
|
|
257
|
-
|
|
260
|
+
const exe = await pickPowerShellExecutable();
|
|
261
|
+
if (generation !== this._generation)
|
|
262
|
+
return;
|
|
263
|
+
this.exe = exe;
|
|
258
264
|
for (let i = 0; i < this.size; i++) {
|
|
259
265
|
const w = new PowerShellWorker({ exe: this.exe, env: this.env });
|
|
260
266
|
w.start();
|
|
261
267
|
this.workers.push(w);
|
|
262
268
|
}
|
|
263
269
|
})().catch((err) => {
|
|
264
|
-
this.
|
|
270
|
+
if (generation === this._generation)
|
|
271
|
+
this._started = null;
|
|
265
272
|
throw err;
|
|
266
273
|
});
|
|
267
274
|
}
|
|
@@ -269,6 +276,10 @@ class PowerShellPool {
|
|
|
269
276
|
}
|
|
270
277
|
async exec(script) {
|
|
271
278
|
await this.start();
|
|
279
|
+
if (!this.workers.length)
|
|
280
|
+
await this.start();
|
|
281
|
+
if (!this.workers.length)
|
|
282
|
+
throw new Error('PowerShell pool not available');
|
|
272
283
|
const idx = this._rr++ % this.workers.length;
|
|
273
284
|
let w = this.workers[idx];
|
|
274
285
|
if (w.dead) {
|
|
@@ -279,6 +290,7 @@ class PowerShellPool {
|
|
|
279
290
|
return w.exec(script);
|
|
280
291
|
}
|
|
281
292
|
async stop() {
|
|
293
|
+
this._generation++;
|
|
282
294
|
for (const w of this.workers)
|
|
283
295
|
w.stop();
|
|
284
296
|
this.workers = [];
|
|
@@ -323,7 +335,9 @@ const parseWindowsPnpLocations = (stdout) => {
|
|
|
323
335
|
};
|
|
324
336
|
exports.parseWindowsPnpLocations = parseWindowsPnpLocations;
|
|
325
337
|
const matchPnpLocation = (deviceId, locations) => {
|
|
326
|
-
const id = String(deviceId ?? '')
|
|
338
|
+
const id = String(deviceId ?? '')
|
|
339
|
+
.trim()
|
|
340
|
+
.toLowerCase();
|
|
327
341
|
if (!id) {
|
|
328
342
|
return '';
|
|
329
343
|
}
|
|
@@ -336,7 +350,7 @@ const matchPnpLocation = (deviceId, locations) => {
|
|
|
336
350
|
};
|
|
337
351
|
exports.matchPnpLocation = matchPnpLocation;
|
|
338
352
|
const PS_PNP_DISPLAY_LOCATIONS = 'Get-PnpDevice -Class Display -PresentOnly -ErrorAction SilentlyContinue | ForEach-Object { ' +
|
|
339
|
-
|
|
353
|
+
'$l = ($_ | Get-PnpDeviceProperty -KeyName DEVPKEY_Device_LocationInfo -ErrorAction SilentlyContinue).Data; "$($_.InstanceId)|$l" }';
|
|
340
354
|
const windowsPciBusAddresses = async () => {
|
|
341
355
|
try {
|
|
342
356
|
return (0, exports.parseWindowsPnpLocations)(await (0, exec_1.shareInflight)('pnpDisplayLocations', () => exports.ps.exec(PS_PNP_DISPLAY_LOCATIONS)));
|
package/dist/cpu-current-load.js
CHANGED
|
@@ -53,6 +53,46 @@ const avgLoadEwma = (previous, busyCores, seconds) => {
|
|
|
53
53
|
};
|
|
54
54
|
exports.avgLoadEwma = avgLoadEwma;
|
|
55
55
|
const avgLoadFromEwma = (cores) => (cores ? parseFloat((Math.max(..._avgLoadEwma) / cores).toFixed(2)) : 0);
|
|
56
|
+
const TOPOLOGY_TRIES = 3;
|
|
57
|
+
let _topology = [];
|
|
58
|
+
let _topologyRead = null;
|
|
59
|
+
let _topologyTries = 0;
|
|
60
|
+
let _topologyTriesCount = -1;
|
|
61
|
+
const readCpuTopology = async () => {
|
|
62
|
+
switch (true) {
|
|
63
|
+
case const_1.LINUX:
|
|
64
|
+
return (await import('./linux/cpu-topology.js')).cpuTopology();
|
|
65
|
+
case const_1.WINDOWS:
|
|
66
|
+
return (await import('./windows/cpu-topology.js')).cpuTopology();
|
|
67
|
+
case const_1.DARWIN:
|
|
68
|
+
return (0, node_os_1.arch)() === 'arm64' ? (0, node_os_1.cpus)().map((_, i) => ({ coreId: i, socketId: 0 })) : [];
|
|
69
|
+
default:
|
|
70
|
+
return [];
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
const cpuTopology = async (count) => {
|
|
74
|
+
if (_topology.length !== count) {
|
|
75
|
+
if (_topologyTriesCount !== count) {
|
|
76
|
+
_topologyTriesCount = count;
|
|
77
|
+
_topologyTries = 0;
|
|
78
|
+
}
|
|
79
|
+
if (_topologyTries < TOPOLOGY_TRIES || _topologyRead) {
|
|
80
|
+
if (!_topologyRead) {
|
|
81
|
+
_topologyTries++;
|
|
82
|
+
_topologyRead = readCpuTopology()
|
|
83
|
+
.catch(() => [])
|
|
84
|
+
.finally(() => {
|
|
85
|
+
_topologyRead = null;
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
const topology = await _topologyRead;
|
|
89
|
+
if (topology.length === count) {
|
|
90
|
+
_topology = topology;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return _topology.length === count ? _topology : [];
|
|
95
|
+
};
|
|
56
96
|
const currentLoad = async () => {
|
|
57
97
|
await (0, common_1.nextTick)();
|
|
58
98
|
const loads = (0, node_os_1.loadavg)().map((x) => x / (0, node_os_1.cpus)().length);
|
|
@@ -290,6 +330,11 @@ const currentLoad = async () => {
|
|
|
290
330
|
cpus: cores
|
|
291
331
|
};
|
|
292
332
|
}
|
|
333
|
+
const topology = await cpuTopology(result.cpus.length);
|
|
334
|
+
result.cpus.forEach((core, i) => {
|
|
335
|
+
core.coreId = topology[i]?.coreId ?? null;
|
|
336
|
+
core.socketId = topology[i]?.socketId ?? null;
|
|
337
|
+
});
|
|
293
338
|
return result;
|
|
294
339
|
};
|
|
295
340
|
exports.currentLoad = currentLoad;
|
|
@@ -71,6 +71,12 @@ const getCpuCurrentSpeed = async () => {
|
|
|
71
71
|
exports.getCpuCurrentSpeed = getCpuCurrentSpeed;
|
|
72
72
|
const cpuCurrentSpeed = async () => {
|
|
73
73
|
await (0, common_1.nextTick)();
|
|
74
|
+
if (const_1.DARWIN && (0, node_os_1.arch)() === 'arm64') {
|
|
75
|
+
const appleSilicon = await (await import('./darwin/cpu-current-speed.js')).appleSiliconSpeed();
|
|
76
|
+
if (appleSilicon) {
|
|
77
|
+
return appleSilicon;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
74
80
|
let result = await (0, exports.getCpuCurrentSpeed)();
|
|
75
81
|
if (result.avg === 0 && (0, cpu_1.getCpuSpeed)() !== 0) {
|
|
76
82
|
const currCpuSpeed = (0, cpu_1.getCpuSpeed)();
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.appleSiliconSpeed = void 0;
|
|
4
|
+
const round2 = (value) => Math.round(value * 100) / 100;
|
|
5
|
+
const appleSiliconSpeed = async () => {
|
|
6
|
+
try {
|
|
7
|
+
const smc = require('macos-smc');
|
|
8
|
+
if (typeof smc.frequencies !== 'function') {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
const res = await smc.frequencies();
|
|
12
|
+
const cores = (res?.cpu?.cores || [])
|
|
13
|
+
.map((core) => (typeof core?.mhz === 'number' ? core.mhz : core?.minMhz))
|
|
14
|
+
.filter((mhz) => typeof mhz === 'number' && mhz > 0)
|
|
15
|
+
.map((mhz) => round2(mhz / 1000));
|
|
16
|
+
if (!cores.length) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
min: Math.min(...cores),
|
|
21
|
+
max: Math.max(...cores),
|
|
22
|
+
avg: round2(cores.reduce((sum, speed) => sum + speed, 0) / cores.length),
|
|
23
|
+
cores
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
exports.appleSiliconSpeed = appleSiliconSpeed;
|
|
@@ -23,19 +23,13 @@ const cpuTemperature = async () => {
|
|
|
23
23
|
}
|
|
24
24
|
catch { }
|
|
25
25
|
try {
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
if (
|
|
29
|
-
|
|
30
|
-
result.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
result.chipset = Math.round(res.soc * 100) / 100;
|
|
34
|
-
}
|
|
35
|
-
if (res && res.cpuDieTemps && res.cpuDieTemps.length) {
|
|
36
|
-
for (const temp of res.cpuDieTemps) {
|
|
37
|
-
result.cores.push(Math.round(temp * 100) / 100);
|
|
38
|
-
}
|
|
26
|
+
const smc = require('macos-smc');
|
|
27
|
+
const cpu = smc.temperatures()?.cpu;
|
|
28
|
+
if (typeof cpu?.max === 'number') {
|
|
29
|
+
const round2 = (value) => Math.round(value * 100) / 100;
|
|
30
|
+
result.main = round2(typeof cpu.avg === 'number' ? cpu.avg : cpu.max);
|
|
31
|
+
result.max = round2(cpu.max);
|
|
32
|
+
result.cores = (cpu.sensors || []).map((sensor) => round2(sensor.value));
|
|
39
33
|
}
|
|
40
34
|
}
|
|
41
35
|
catch { }
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.diskSpeed = void 0;
|
|
4
|
+
const disk_speed_1 = require("../common/disk-speed");
|
|
5
|
+
const noCache = (fd) => {
|
|
6
|
+
try {
|
|
7
|
+
const smc = require('macos-smc');
|
|
8
|
+
return typeof smc.noCache === 'function' && smc.noCache(fd) === true;
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
const diskSpeed = (path, sizeMB) => (0, disk_speed_1.runDiskSpeed)(path, sizeMB, {
|
|
15
|
+
prepareWrite: noCache,
|
|
16
|
+
readUncached: (file, bytes) => (0, disk_speed_1.readFileTimed)(file, bytes, noCache)
|
|
17
|
+
});
|
|
18
|
+
exports.diskSpeed = diskSpeed;
|
package/dist/darwin/disks-io.js
CHANGED
|
@@ -49,7 +49,9 @@ const disksIO = async () => {
|
|
|
49
49
|
tWaitTime: filesys_1._disk_io.tWaitTimeDelta,
|
|
50
50
|
rWaitPercent: filesys_1._disk_io.rWaitPercent,
|
|
51
51
|
wWaitPercent: filesys_1._disk_io.wWaitPercent,
|
|
52
|
-
tWaitPercent: filesys_1._disk_io.tWaitPercent
|
|
52
|
+
tWaitPercent: filesys_1._disk_io.tWaitPercent,
|
|
53
|
+
busyPercent: filesys_1._disk_io.busyPercent,
|
|
54
|
+
idlePercent: filesys_1._disk_io.idlePercent
|
|
53
55
|
};
|
|
54
56
|
}
|
|
55
57
|
};
|
package/dist/darwin/fans.js
CHANGED
|
@@ -6,20 +6,18 @@ const fans = async () => {
|
|
|
6
6
|
await (0, common_1.nextTick)();
|
|
7
7
|
const result = [];
|
|
8
8
|
try {
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
source: 'SMC'
|
|
20
|
-
});
|
|
9
|
+
const smc = require('macos-smc');
|
|
10
|
+
const res = smc.fans();
|
|
11
|
+
if (Array.isArray(res)) {
|
|
12
|
+
res.forEach((fan, index) => {
|
|
13
|
+
result.push({
|
|
14
|
+
id: `fan${typeof fan?.id === 'number' ? fan.id : index}`,
|
|
15
|
+
label: null,
|
|
16
|
+
rpm: typeof fan?.rpm === 'number' ? Math.round(fan.rpm) : null,
|
|
17
|
+
pwm: typeof fan?.percent === 'number' ? Math.round(fan.percent) : null,
|
|
18
|
+
source: 'SMC'
|
|
21
19
|
});
|
|
22
|
-
}
|
|
20
|
+
});
|
|
23
21
|
}
|
|
24
22
|
}
|
|
25
23
|
catch { }
|
package/dist/darwin/gpu.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { GpuData } from '../common/types';
|
|
1
|
+
import type { GpuData } from '../common/types';
|
|
2
2
|
export declare const gpu: () => Promise<GpuData[]>;
|
package/dist/darwin/gpu.js
CHANGED
|
@@ -37,12 +37,12 @@ const gpu = async () => {
|
|
|
37
37
|
const { stdout } = await (0, exec_1.shareInflight)('SPDisplaysDataType', () => (0, exec_1.exec)('system_profiler -xml -detailLevel full SPDisplaysDataType'));
|
|
38
38
|
result = parseControllersDarwin((0, darwin_1.plistParser)(stdout));
|
|
39
39
|
try {
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
40
|
+
const smc = require('macos-smc');
|
|
41
|
+
const gpuMax = smc.temperatures()?.gpu?.max;
|
|
42
|
+
if (typeof gpuMax === 'number') {
|
|
43
43
|
for (const controller of result) {
|
|
44
44
|
if (controller.bus === 'Built-In') {
|
|
45
|
-
controller.temperatureGpu = Math.round(
|
|
45
|
+
controller.temperatureGpu = Math.round(gpuMax * 100) / 100;
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
}
|
package/dist/darwin/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export { cpuTemperature } from './cpu-temperature';
|
|
|
14
14
|
export { fans } from './fans';
|
|
15
15
|
export { currentLoad } from '../cpu-current-load';
|
|
16
16
|
export { diskLayout } from './disk-layout';
|
|
17
|
+
export { diskSpeed } from './disk-speed';
|
|
17
18
|
export { disksIO } from './disks-io';
|
|
18
19
|
export { displays } from './displays';
|
|
19
20
|
export { dockerInfo, dockerImages, dockerContainers, dockerContainerStats, dockerContainerProcesses, dockerVolumes, dockerAll } from '../docker';
|
|
@@ -32,6 +33,7 @@ export { networkConnections } from './network-connections';
|
|
|
32
33
|
export { networkGatewayDefault } from './network-gateway-default';
|
|
33
34
|
export { networkInterfaceDefault } from './network-interface-default';
|
|
34
35
|
export { networkInterfaces } from './network-interfaces';
|
|
36
|
+
export { networkRoutes } from './network-routes';
|
|
35
37
|
export { networkStats } from './network-stats';
|
|
36
38
|
export { npm } from './npm';
|
|
37
39
|
export { npu } from './npu';
|
package/dist/darwin/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.wifiNetworks = exports.wifiInterfaces = exports.wifiConnections = exports.versions = exports.version = exports.vboxInfo = exports.uuid = exports.users = exports.usb = exports.serialPorts = exports.time = exports.thunderbolt = exports.system = exports.software = exports.shell = void 0;
|
|
3
|
+
exports.processLoad = exports.processes = exports.printer = exports.pci = exports.osInfo = exports.npu = exports.npm = exports.networkStats = exports.networkRoutes = exports.networkInterfaces = exports.networkInterfaceDefault = exports.networkGatewayDefault = exports.networkConnections = exports.mouse = exports.memLayout = exports.mem = exports.keyboard = exports.inetLatency = exports.inetChecksite = exports.gpu = exports.fullLoad = exports.fsStats = exports.fsSize = exports.fsOpenFiles = exports.dockerAll = exports.dockerVolumes = exports.dockerContainerProcesses = exports.dockerContainerStats = exports.dockerContainers = exports.dockerImages = exports.dockerInfo = exports.displays = exports.disksIO = exports.diskSpeed = exports.diskLayout = exports.currentLoad = exports.fans = exports.cpuTemperature = exports.cpuFlags = exports.cpuCurrentSpeed = exports.cpuCache = exports.cpu = exports.chassis = exports.camera = exports.bluetoothDevices = exports.blockDevices = exports.bios = exports.battery = exports.baseboard = exports.audio = void 0;
|
|
4
|
+
exports.wifiNetworks = exports.wifiInterfaces = exports.wifiConnections = exports.versions = exports.version = exports.vboxInfo = exports.uuid = exports.users = exports.usb = exports.serialPorts = exports.time = exports.thunderbolt = exports.system = exports.software = exports.shell = exports.services = exports.processFocused = void 0;
|
|
5
5
|
var audio_1 = require("./audio");
|
|
6
6
|
Object.defineProperty(exports, "audio", { enumerable: true, get: function () { return audio_1.audio; } });
|
|
7
7
|
var baseboard_1 = require("./baseboard");
|
|
@@ -34,6 +34,8 @@ var cpu_current_load_1 = require("../cpu-current-load");
|
|
|
34
34
|
Object.defineProperty(exports, "currentLoad", { enumerable: true, get: function () { return cpu_current_load_1.currentLoad; } });
|
|
35
35
|
var disk_layout_1 = require("./disk-layout");
|
|
36
36
|
Object.defineProperty(exports, "diskLayout", { enumerable: true, get: function () { return disk_layout_1.diskLayout; } });
|
|
37
|
+
var disk_speed_1 = require("./disk-speed");
|
|
38
|
+
Object.defineProperty(exports, "diskSpeed", { enumerable: true, get: function () { return disk_speed_1.diskSpeed; } });
|
|
37
39
|
var disks_io_1 = require("./disks-io");
|
|
38
40
|
Object.defineProperty(exports, "disksIO", { enumerable: true, get: function () { return disks_io_1.disksIO; } });
|
|
39
41
|
var displays_1 = require("./displays");
|
|
@@ -76,6 +78,8 @@ var network_interface_default_1 = require("./network-interface-default");
|
|
|
76
78
|
Object.defineProperty(exports, "networkInterfaceDefault", { enumerable: true, get: function () { return network_interface_default_1.networkInterfaceDefault; } });
|
|
77
79
|
var network_interfaces_1 = require("./network-interfaces");
|
|
78
80
|
Object.defineProperty(exports, "networkInterfaces", { enumerable: true, get: function () { return network_interfaces_1.networkInterfaces; } });
|
|
81
|
+
var network_routes_1 = require("./network-routes");
|
|
82
|
+
Object.defineProperty(exports, "networkRoutes", { enumerable: true, get: function () { return network_routes_1.networkRoutes; } });
|
|
79
83
|
var network_stats_1 = require("./network-stats");
|
|
80
84
|
Object.defineProperty(exports, "networkStats", { enumerable: true, get: function () { return network_stats_1.networkStats; } });
|
|
81
85
|
var npm_1 = require("./npm");
|
|
@@ -41,7 +41,8 @@ const parseLinesDarwinNics = (sections) => {
|
|
|
41
41
|
type: '',
|
|
42
42
|
operstate: '',
|
|
43
43
|
duplex: '',
|
|
44
|
-
internal: false
|
|
44
|
+
internal: false,
|
|
45
|
+
bridgeMembers: []
|
|
45
46
|
};
|
|
46
47
|
const first = section[0];
|
|
47
48
|
nic.iface = first.split(':')[0].trim();
|
|
@@ -61,6 +62,9 @@ const parseLinesDarwinNics = (sections) => {
|
|
|
61
62
|
if (line.trim().startsWith('inet ') && !nic.ip4) {
|
|
62
63
|
nic.ip4 = line.split('inet ')[1].toLowerCase().split(' ')[0];
|
|
63
64
|
}
|
|
65
|
+
if (line.trim().startsWith('member: ')) {
|
|
66
|
+
nic.bridgeMembers.push(line.trim().split(/\s+/)[1]);
|
|
67
|
+
}
|
|
64
68
|
});
|
|
65
69
|
let speed = (0, common_1.getValue)(section, 'link rate');
|
|
66
70
|
nic.speed = speed ? parseFloat(speed) : null;
|
|
@@ -109,7 +113,12 @@ const parseBsdGateways = (stdout) => {
|
|
|
109
113
|
if (parts[0] !== 'default' || parts.length < 3 || !parts[1].includes('.')) {
|
|
110
114
|
continue;
|
|
111
115
|
}
|
|
112
|
-
const iface = ifaceColumn > 0
|
|
116
|
+
const iface = ifaceColumn > 0
|
|
117
|
+
? parts[ifaceColumn]
|
|
118
|
+
: parts
|
|
119
|
+
.slice(2)
|
|
120
|
+
.reverse()
|
|
121
|
+
.find((part) => /^[a-z][a-z0-9]*\d$/.test(part));
|
|
113
122
|
if (iface && !result[iface]) {
|
|
114
123
|
result[iface] = parts[1];
|
|
115
124
|
}
|
|
@@ -189,7 +198,7 @@ const networkInterfaces = async (defaultString = '', rescan = true) => {
|
|
|
189
198
|
return (0, network_1.filterDefaultInterface)(_networkInterfaces, defaultString);
|
|
190
199
|
}
|
|
191
200
|
_interfaces = (0, index_1.cloneObj)(interfaces);
|
|
192
|
-
|
|
201
|
+
const result = [];
|
|
193
202
|
try {
|
|
194
203
|
const [nics, defaultInterface, gateways, vendors] = await Promise.all([getBsdNics(), (0, network_interface_default_1.networkInterfaceDefault)(), getBsdGateways(), getBsdNicVendors()]);
|
|
195
204
|
for (const nic of nics) {
|
|
@@ -260,7 +269,8 @@ const networkInterfaces = async (defaultString = '', rescan = true) => {
|
|
|
260
269
|
dnsSuffix: '',
|
|
261
270
|
ieee8021xAuth: '',
|
|
262
271
|
ieee8021xState: '',
|
|
263
|
-
carrierChanges: 0
|
|
272
|
+
carrierChanges: 0,
|
|
273
|
+
bridgeMembers: nic.bridgeMembers
|
|
264
274
|
});
|
|
265
275
|
}
|
|
266
276
|
_networkInterfaces = result;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.networkRoutes = exports.parseNetstatRoutes = void 0;
|
|
4
|
+
const common_1 = require("../common");
|
|
5
|
+
const exec_1 = require("../common/exec");
|
|
6
|
+
const EXEC_OPTS = { timeout: 5000, maxBuffer: 1024 * 1024 * 16 };
|
|
7
|
+
const ipv4Cidr = (dest, host) => {
|
|
8
|
+
if (dest === 'default') {
|
|
9
|
+
return '0.0.0.0/0';
|
|
10
|
+
}
|
|
11
|
+
const [addr = '', prefix] = dest.split('/');
|
|
12
|
+
const octets = addr.split('.');
|
|
13
|
+
const bits = prefix ?? (host ? '32' : String(octets.length * 8));
|
|
14
|
+
while (octets.length < 4) {
|
|
15
|
+
octets.push('0');
|
|
16
|
+
}
|
|
17
|
+
return `${octets.join('.')}/${bits}`;
|
|
18
|
+
};
|
|
19
|
+
const ipv6Cidr = (dest) => {
|
|
20
|
+
if (dest === 'default') {
|
|
21
|
+
return '::/0';
|
|
22
|
+
}
|
|
23
|
+
const value = dest.replace(/%[^/]*/, '');
|
|
24
|
+
return value.includes('/') ? value : `${value}/128`;
|
|
25
|
+
};
|
|
26
|
+
const parseNetstatRoutes = (stdout) => {
|
|
27
|
+
const result = [];
|
|
28
|
+
let family = '';
|
|
29
|
+
let gatewayCol = -1;
|
|
30
|
+
let flagsCol = -1;
|
|
31
|
+
let ifaceCol = -1;
|
|
32
|
+
for (const line of stdout.split('\n')) {
|
|
33
|
+
const parts = line.trim().split(/\s+/);
|
|
34
|
+
if (/^Internet6?:$/.test(parts[0] || '')) {
|
|
35
|
+
family = parts[0] === 'Internet6:' ? 'IPv6' : 'IPv4';
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
if (parts[0] === 'Destination') {
|
|
39
|
+
gatewayCol = parts.indexOf('Gateway');
|
|
40
|
+
flagsCol = parts.indexOf('Flags');
|
|
41
|
+
ifaceCol = parts.findIndex((part) => /^(netif|interface|iface)$/i.test(part));
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (!family || gatewayCol < 0 || flagsCol < 0 || ifaceCol < 0 || parts.length <= ifaceCol) {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
const flags = parts[flagsCol] || '';
|
|
48
|
+
if (!flags.startsWith('U') || flags.includes('L')) {
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
const dest = parts[0] || '';
|
|
52
|
+
const gateway = (parts[gatewayCol] || '').replace(/%.*$/, '');
|
|
53
|
+
result.push({
|
|
54
|
+
destination: family === 'IPv6' ? ipv6Cidr(dest) : ipv4Cidr(dest, flags.includes('H')),
|
|
55
|
+
gateway: gateway.startsWith('link#') ? '' : gateway,
|
|
56
|
+
iface: parts[ifaceCol] || '',
|
|
57
|
+
metric: null,
|
|
58
|
+
family
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return result;
|
|
62
|
+
};
|
|
63
|
+
exports.parseNetstatRoutes = parseNetstatRoutes;
|
|
64
|
+
const networkRoutes = async () => {
|
|
65
|
+
await (0, common_1.nextTick)();
|
|
66
|
+
try {
|
|
67
|
+
const { stdout } = await (0, exec_1.execFile)('netstat', ['-rn'], EXEC_OPTS);
|
|
68
|
+
return (0, exports.parseNetstatRoutes)(stdout.toString());
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return [];
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
exports.networkRoutes = networkRoutes;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const diskSpeed: (path?: string, sizeMB?: number) => Promise<import("./common/types").DiskSpeedData | null>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.diskSpeed = void 0;
|
|
4
|
+
const const_1 = require("./common/const");
|
|
5
|
+
const diskSpeed = async (path, sizeMB) => {
|
|
6
|
+
switch (true) {
|
|
7
|
+
case const_1.LINUX || const_1.FREEBSD || const_1.NETBSD || const_1.OPENBSD:
|
|
8
|
+
return (await import('./linux/disk-speed.js')).diskSpeed(path, sizeMB);
|
|
9
|
+
case const_1.DARWIN:
|
|
10
|
+
return (await import('./darwin/disk-speed.js')).diskSpeed(path, sizeMB);
|
|
11
|
+
case const_1.WINDOWS:
|
|
12
|
+
return (await import('./windows/disk-speed.js')).diskSpeed(path, sizeMB);
|
|
13
|
+
default:
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
exports.diskSpeed = diskSpeed;
|
package/dist/get.js
CHANGED
|
@@ -36,14 +36,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.get = void 0;
|
|
37
37
|
const common_1 = require("./common");
|
|
38
38
|
const functions = __importStar(require("./index"));
|
|
39
|
-
const blocked = ['get', 'observe', 'getStaticData', 'getDynamicData', 'getAllData'];
|
|
39
|
+
const blocked = ['get', 'observe', 'getStaticData', 'getDynamicData', 'getAllData', 'powerShellStart', 'powerShellRelease', 'diskSpeed'];
|
|
40
40
|
const pickKeys = (element, keyList) => {
|
|
41
41
|
if (keyList.length === 1 && (keyList[0] === '*' || keyList[0] === 'all')) {
|
|
42
42
|
return element;
|
|
43
43
|
}
|
|
44
44
|
const partial = {};
|
|
45
45
|
keyList.forEach((k) => {
|
|
46
|
-
if (Object.
|
|
46
|
+
if (Object.hasOwn(element, k)) {
|
|
47
47
|
partial[k] = element[k];
|
|
48
48
|
}
|
|
49
49
|
});
|
|
@@ -73,7 +73,7 @@ const pickResult = (data, value) => {
|
|
|
73
73
|
if (filterParts.length === 2) {
|
|
74
74
|
const filterKey = filterParts[0].trim();
|
|
75
75
|
const filterValue = filterParts[1].trim();
|
|
76
|
-
if (Object.
|
|
76
|
+
if (Object.hasOwn(partialRes, filterKey)) {
|
|
77
77
|
const val = partialRes[filterKey];
|
|
78
78
|
if (typeof val === 'number') {
|
|
79
79
|
if (val === parseFloat(filterValue)) {
|
|
@@ -98,7 +98,7 @@ const pickResult = (data, value) => {
|
|
|
98
98
|
const get = async (valueObject) => {
|
|
99
99
|
await (0, common_1.nextTick)();
|
|
100
100
|
const lib = functions;
|
|
101
|
-
const isGettable = (key) => Object.
|
|
101
|
+
const isGettable = (key) => Object.hasOwn(lib, key) && typeof lib[key] === 'function' && typeof (valueObject || {})[key] === 'string' && blocked.indexOf(key) < 0;
|
|
102
102
|
const keys = Object.keys(valueObject || {}).filter(isGettable);
|
|
103
103
|
const data = await Promise.all(keys.map((func) => {
|
|
104
104
|
const value = valueObject[func];
|
|
@@ -114,7 +114,7 @@ const get = async (valueObject) => {
|
|
|
114
114
|
keys.forEach((key, i) => {
|
|
115
115
|
result[key] = pickResult(data[i], valueObject[key]);
|
|
116
116
|
});
|
|
117
|
-
if (Object.
|
|
117
|
+
if (Object.hasOwn(valueObject || {}, 'graphics')) {
|
|
118
118
|
result.graphics = 'graphics() was removed in v6 - use gpu and displays instead';
|
|
119
119
|
}
|
|
120
120
|
return result;
|
package/dist/index.d.ts
CHANGED
|
@@ -8,21 +8,22 @@ export { camera } from './camera';
|
|
|
8
8
|
export { chassis } from './chassis';
|
|
9
9
|
export { cpu } from './cpu';
|
|
10
10
|
export { cpuCache } from './cpu-cache';
|
|
11
|
+
export { currentLoad } from './cpu-current-load';
|
|
11
12
|
export { cpuCurrentSpeed } from './cpu-current-speed';
|
|
12
13
|
export { cpuFlags } from './cpu-flags';
|
|
14
|
+
export { fullLoad } from './cpu-full-load';
|
|
13
15
|
export { cpuTemperature } from './cpu-temperature';
|
|
14
|
-
export { fans } from './fans';
|
|
15
|
-
export { currentLoad } from './cpu-current-load';
|
|
16
16
|
export { diskLayout } from './disk-layout';
|
|
17
|
+
export { diskSpeed } from './disk-speed';
|
|
17
18
|
export { disksIO } from './disks-io';
|
|
18
19
|
export { displays } from './displays';
|
|
19
|
-
export {
|
|
20
|
+
export { dockerAll, dockerContainerProcesses, dockerContainerStats, dockerContainers, dockerImages, dockerInfo, dockerVolumes } from './docker';
|
|
21
|
+
export { fans } from './fans';
|
|
20
22
|
export { fsOpenFiles } from './fs-open-files';
|
|
21
23
|
export { fsSize } from './fs-size';
|
|
22
24
|
export { fsStats } from './fs-stats';
|
|
23
|
-
export { fullLoad } from './cpu-full-load';
|
|
24
25
|
export { get } from './get';
|
|
25
|
-
export {
|
|
26
|
+
export { getAllData, getDynamicData, getStaticData } from './get-data';
|
|
26
27
|
export { gpu } from './gpu';
|
|
27
28
|
export { inetChecksite } from './inet-checksite';
|
|
28
29
|
export { inetLatency } from './inet-latency';
|
|
@@ -35,16 +36,18 @@ export { networkConnections } from './network-connections';
|
|
|
35
36
|
export { networkGatewayDefault } from './network-gateway-default';
|
|
36
37
|
export { networkInterfaceDefault } from './network-interface-default';
|
|
37
38
|
export { networkInterfaces } from './network-interfaces';
|
|
39
|
+
export { networkRoutes } from './network-routes';
|
|
38
40
|
export { networkStats } from './network-stats';
|
|
39
41
|
export { npm } from './npm';
|
|
40
42
|
export { npu } from './npu';
|
|
41
43
|
export { observe } from './observe';
|
|
42
44
|
export { osInfo } from './os-info';
|
|
43
45
|
export { pci } from './pci';
|
|
46
|
+
export { powerShellRelease, powerShellStart } from './powershell';
|
|
44
47
|
export { printer } from './printer';
|
|
45
|
-
export { processes } from './processes';
|
|
46
|
-
export { processLoad } from './process-load';
|
|
47
48
|
export { processFocused } from './process-focused';
|
|
49
|
+
export { processLoad } from './process-load';
|
|
50
|
+
export { processes } from './processes';
|
|
48
51
|
export { serialPorts } from './serial-ports';
|
|
49
52
|
export { services } from './services';
|
|
50
53
|
export { shell } from './shell';
|
|
@@ -55,9 +58,9 @@ export { time } from './time';
|
|
|
55
58
|
export { usb } from './usb';
|
|
56
59
|
export { users } from './users';
|
|
57
60
|
export { uuid } from './uuid';
|
|
58
|
-
export { vboxInfo } from './virtualbox';
|
|
59
61
|
export { version } from './version';
|
|
60
62
|
export { versions } from './versions';
|
|
63
|
+
export { vboxInfo } from './virtualbox';
|
|
61
64
|
export { wifiConnections } from './wifi-connections';
|
|
62
65
|
export { wifiInterfaces } from './wifi-interfaces';
|
|
63
66
|
export { wifiNetworks } from './wifi-networks';
|