systeminformation 6.0.0-beta.11 → 6.0.0-beta.13
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 +17 -7
- package/dist/bsd/network-stats.js +2 -1
- package/dist/common/defaults.js +7 -1
- package/dist/common/filesys.d.ts +19 -0
- package/dist/common/filesys.js +167 -2
- package/dist/common/mappings.d.ts +0 -3
- package/dist/common/mappings.js +1 -13
- package/dist/common/types.d.ts +11 -0
- package/dist/common/windows.d.ts +4 -0
- package/dist/common/windows.js +57 -1
- package/dist/cpu-current-load.d.ts +1 -0
- package/dist/cpu-current-load.js +26 -2
- package/dist/darwin/displays.d.ts +1 -0
- package/dist/darwin/displays.js +30 -1
- package/dist/darwin/index.d.ts +1 -0
- package/dist/darwin/index.js +4 -2
- package/dist/darwin/network-interfaces.d.ts +3 -0
- package/dist/darwin/network-interfaces.js +78 -3
- package/dist/darwin/network-stats.js +3 -2
- package/dist/darwin/process-focused.d.ts +3 -0
- package/dist/darwin/process-focused.js +26 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/linux/block-devices.js +3 -1
- package/dist/linux/displays.d.ts +8 -0
- package/dist/linux/displays.js +112 -3
- package/dist/linux/index.d.ts +1 -0
- package/dist/linux/index.js +4 -2
- package/dist/linux/network-interfaces.d.ts +1 -0
- package/dist/linux/network-interfaces.js +69 -2
- package/dist/linux/process-focused.d.ts +4 -0
- package/dist/linux/process-focused.js +32 -0
- package/dist/linux/process-load.js +2 -1
- package/dist/linux/services.js +5 -4
- package/dist/process-focused.d.ts +1 -0
- package/dist/process-focused.js +17 -0
- package/dist/windows/audio.d.ts +29 -0
- package/dist/windows/audio.js +151 -11
- package/dist/windows/displays.d.ts +5 -0
- package/dist/windows/displays.js +59 -5
- package/dist/windows/gpu.js +3 -2
- package/dist/windows/index.d.ts +1 -0
- package/dist/windows/index.js +3 -1
- package/dist/windows/network-interfaces.js +14 -1
- package/dist/windows/process-focused.d.ts +3 -0
- package/dist/windows/process-focused.js +36 -0
- package/dist/windows/processes.d.ts +1 -0
- package/dist/windows/processes.js +37 -15
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -373,6 +373,7 @@ On Windows, `si.displays()` reports physical monitors: in duplicate/mirror mode
|
|
|
373
373
|
| | [0].model | X | | X | X | | graphics controller model |
|
|
374
374
|
| | [0].deviceId | | | X | | | device ID |
|
|
375
375
|
| | [0].bus | X | | X | X | | on which bus (e.g. PCIe) |
|
|
376
|
+
| | [0].busAddress | X | | | X | | PCI bus address, e.g. '01:00.0' |
|
|
376
377
|
| | [0].vram | X | | X | X | | VRAM size (in MB) |
|
|
377
378
|
| | [0].vramDynamic | X | | X | X | | true if dynamically allocated ram |
|
|
378
379
|
| | [0].external | | | X | | | is external GPU |
|
|
@@ -406,6 +407,9 @@ On Windows, `si.displays()` reports physical monitors: in duplicate/mirror mode
|
|
|
406
407
|
| | [0].workAreaPositionY | X | | X | X | | working area position Y |
|
|
407
408
|
| | [0].currentRefreshRate | X | | X | X | | current screen refresh rate |
|
|
408
409
|
| | [0].scale | | | | X | | DPI scaling factor, e.g. 1.5 |
|
|
410
|
+
| | [0].powerState | X | | | X | | 'on', 'standby', 'suspend', 'off' |
|
|
411
|
+
| | [0].gpu | | | X | X | | GPU model driving this display |
|
|
412
|
+
| | [0].gpuBusAddress | X | | | X | | PCI addr, joins gpu().busAddress |
|
|
409
413
|
|
|
410
414
|
#### 7. Operating System
|
|
411
415
|
|
|
@@ -461,7 +465,7 @@ On Windows, `si.displays()` reports physical monitors: in duplicate/mirror mode
|
|
|
461
465
|
| Function | Result object | Linux | BSD | Mac | Win | Sun | Comments |
|
|
462
466
|
| -------------------------------- | ----------------- | ----- | --- | --- | --- | --- | --------------------------------------------------------------------------------------- |
|
|
463
467
|
| si.currentLoad() | {...} | X | | X | X | X | CPU-Load |
|
|
464
|
-
| | avgLoad | X | | X |
|
|
468
|
+
| | avgLoad | X | | X | X | X | average load<br>(Windows: approximated, see docs) |
|
|
465
469
|
| | currentLoad | X | | X | X | X | CPU load in % |
|
|
466
470
|
| | currentLoadUser | X | | X | X | X | CPU load user in % |
|
|
467
471
|
| | currentLoadSystem | X | | X | X | X | CPU load system in % |
|
|
@@ -515,6 +519,10 @@ On Windows, `si.displays()` reports physical monitors: in duplicate/mirror mode
|
|
|
515
519
|
| | [0].pids | X | X | X | X | | pids |
|
|
516
520
|
| | [0].cpu | X | X | X | | | process % CPU |
|
|
517
521
|
| | [0].mem | X | X | X | | | process % MEM |
|
|
522
|
+
| si.processFocused() | {...} | X | | X | X | | process owning the currently focused window (X11 only on Linux); null if not detectable |
|
|
523
|
+
| | pid | X | | X | X | | PID of the focused process |
|
|
524
|
+
| | name | X | | X | X | | name of the focused process |
|
|
525
|
+
| | path | X | | X | X | | path of the focused process |
|
|
518
526
|
|
|
519
527
|
#### 9. File System
|
|
520
528
|
|
|
@@ -539,7 +547,7 @@ On Windows, `si.displays()` reports physical monitors: in duplicate/mirror mode
|
|
|
539
547
|
| | [0].smartStatus | X | | X | X | | S.M.A.R.T Status (see Known Issues) |
|
|
540
548
|
| | [0].temperature | X | | | | | S.M.A.R.T temperature |
|
|
541
549
|
| | [0].smartData | X | | | X | | full S.M.A.R.T data from smartctl<br>requires at least smartmontools 7.0 |
|
|
542
|
-
| si.blockDevices() | [{...}] | X | | X | X | | returns array of disks, partitions,<br>raids and roms
|
|
550
|
+
| si.blockDevices() | [{...}] | X | | X | X | | returns array of disks, partitions,<br>raids, pools and roms |
|
|
543
551
|
| | [0].name | X | | X | X | | name |
|
|
544
552
|
| | [0].type | X | | X | X | | type |
|
|
545
553
|
| | [0].fstype | X | | X | X | | file system type (e.g. ext4) |
|
|
@@ -552,7 +560,7 @@ On Windows, `si.displays()` reports physical monitors: in duplicate/mirror mode
|
|
|
552
560
|
| | [0].serial | X | | | X | | serial |
|
|
553
561
|
| | [0].removable | X | | X | X | | serial |
|
|
554
562
|
| | [0].protocol | X | | X | | | protocol (SATA, PCI-Express, ...) |
|
|
555
|
-
| | [0].group | X | | | | |
|
|
563
|
+
| | [0].group | X | | | | | raid / pool member (e.g. md1, ZFS pool,<br>btrfs label) |
|
|
556
564
|
| | [0].device | X | | X | X | | physical device mapped to (e.g. /dev/sda) |
|
|
557
565
|
| si.disksIO() | {...} | X | | X | X | | current transfer stats |
|
|
558
566
|
| | rIO | X | | X | X | | read IOs on all mounted drives |
|
|
@@ -674,11 +682,10 @@ On Windows, `si.displays()` reports physical monitors: in duplicate/mirror mode
|
|
|
674
682
|
| | [0].revision | X | | | | | revision |
|
|
675
683
|
| | [0].driver | X | | | | | driver |
|
|
676
684
|
| | [0].default | | | X | X | | is default |
|
|
677
|
-
| | [0].channel | X | | X |
|
|
685
|
+
| | [0].channel | X | | X | X | | channel e.g. USB, HDMI, ... |
|
|
678
686
|
| | [0].type | X | | X | X | | type e.g. Speaker |
|
|
679
|
-
| | [0].in |
|
|
680
|
-
| | [0].out |
|
|
681
|
-
| | [0].interfaceType | X | | X | X | | interface type (PCIe, USB, HDMI, ...) |
|
|
687
|
+
| | [0].in | X | | X | X | | is input channel |
|
|
688
|
+
| | [0].out | X | | X | X | | is output channel |
|
|
682
689
|
| | [0].status | X | | X | X | | status (e.g. active) |
|
|
683
690
|
|
|
684
691
|
#### 12. Network related functions
|
|
@@ -688,11 +695,14 @@ On Windows, `si.displays()` reports physical monitors: in duplicate/mirror mode
|
|
|
688
695
|
| si.networkInterfaces() | [{...}] | X | X | X | X | X | array of network interfaces<br>With the 'default' parameter it returns<br>only the default interface |
|
|
689
696
|
| | [0].iface | X | X | X | X | X | interface |
|
|
690
697
|
| | [0].ifaceName | X | X | X | X | X | interface name (differs on Windows) |
|
|
698
|
+
| | [0].vendor | X | | X | X | | network adapter vendor (not available for every adapter) |
|
|
699
|
+
| | [0].model | X | | X | X | | network adapter model (not available for every adapter) |
|
|
691
700
|
| | [0].default | X | X | X | X | X | true if this is the default interface |
|
|
692
701
|
| | [0].ip4 | X | X | X | X | X | ip4 address |
|
|
693
702
|
| | [0].ip4subnet | X | X | X | X | X | ip4 subnet mask |
|
|
694
703
|
| | [0].ip6 | X | X | X | X | X | ip6 address |
|
|
695
704
|
| | [0].ip6subnet | X | X | X | X | X | ip6 subnet mask |
|
|
705
|
+
| | [0].gateway | X | X | X | X | | default gateway of this interface |
|
|
696
706
|
| | [0].mac | X | X | X | X | X | MAC address |
|
|
697
707
|
| | [0].internal | X | X | X | X | X | true if internal interface |
|
|
698
708
|
| | [0].virtual | X | X | X | X | X | true if virtual interface |
|
|
@@ -7,6 +7,7 @@ const security_1 = require("../common/security");
|
|
|
7
7
|
const defaults_1 = require("../common/defaults");
|
|
8
8
|
const darwin_1 = require("../darwin");
|
|
9
9
|
const network_1 = require("../common/network");
|
|
10
|
+
const EXEC_OPTS = { timeout: 5000 };
|
|
10
11
|
const _network = {};
|
|
11
12
|
const networkStatsSingle = async (iface) => {
|
|
12
13
|
const defaults = { ...defaults_1.initNetworkSpeed, iface };
|
|
@@ -18,7 +19,7 @@ const networkStatsSingle = async (iface) => {
|
|
|
18
19
|
let rx_errors = 0;
|
|
19
20
|
let tx_dropped = 0;
|
|
20
21
|
let tx_errors = 0;
|
|
21
|
-
const stdout = await (0, exec_1.execSecure)('netstat', ['-ibndI', iface]);
|
|
22
|
+
const stdout = await (0, exec_1.execSecure)('netstat', ['-ibndI', iface], EXEC_OPTS);
|
|
22
23
|
if (stdout) {
|
|
23
24
|
const lines = stdout.split('\n');
|
|
24
25
|
for (let i = 1; i < lines.length; i++) {
|
package/dist/common/defaults.js
CHANGED
|
@@ -251,7 +251,10 @@ exports.initDisplay = {
|
|
|
251
251
|
workAreaPositionX: null,
|
|
252
252
|
workAreaPositionY: null,
|
|
253
253
|
currentRefreshRate: null,
|
|
254
|
-
scale: null
|
|
254
|
+
scale: null,
|
|
255
|
+
powerState: '',
|
|
256
|
+
gpu: '',
|
|
257
|
+
gpuBusAddress: ''
|
|
255
258
|
};
|
|
256
259
|
exports.initProcesses = {
|
|
257
260
|
all: 0,
|
|
@@ -264,11 +267,14 @@ exports.initProcesses = {
|
|
|
264
267
|
exports.initNetworkInterface = {
|
|
265
268
|
iface: '',
|
|
266
269
|
ifaceName: '',
|
|
270
|
+
vendor: '',
|
|
271
|
+
model: '',
|
|
267
272
|
default: false,
|
|
268
273
|
ip4: '',
|
|
269
274
|
ip4subnet: '',
|
|
270
275
|
ip6: '',
|
|
271
276
|
ip6subnet: '',
|
|
277
|
+
gateway: '',
|
|
272
278
|
mac: '',
|
|
273
279
|
internal: true,
|
|
274
280
|
virtual: false,
|
package/dist/common/filesys.d.ts
CHANGED
|
@@ -19,3 +19,22 @@ export declare const parseLinuxBlk: (lines: string[]) => FsBlockDevicesData[];
|
|
|
19
19
|
export declare const raidMatchLinux: (data: FsBlockDevicesData[]) => Promise<FsBlockDevicesData[]>;
|
|
20
20
|
export declare const matchDevicesLinux: (data: FsBlockDevicesData[]) => FsBlockDevicesData[];
|
|
21
21
|
export declare const matchDevicesWin: (data: FsBlockDevicesData[], diskDrives: string[]) => FsBlockDevicesData[];
|
|
22
|
+
export type PoolInfoLinux = {
|
|
23
|
+
name: string;
|
|
24
|
+
type: string;
|
|
25
|
+
fsType: string;
|
|
26
|
+
size: number;
|
|
27
|
+
uuid: string;
|
|
28
|
+
mount: string;
|
|
29
|
+
members: string[];
|
|
30
|
+
};
|
|
31
|
+
export declare const parseZpoolStatus: (stdout: string) => Map<string, {
|
|
32
|
+
type: string;
|
|
33
|
+
members: string[];
|
|
34
|
+
}>;
|
|
35
|
+
export declare const parseZpoolList: (stdout: string) => Map<string, number>;
|
|
36
|
+
export declare const btrfsProfileFromEntries: (entries: string[]) => string;
|
|
37
|
+
export declare const applyPoolsLinux: (data: FsBlockDevicesData[], pools: PoolInfoLinux[]) => FsBlockDevicesData[];
|
|
38
|
+
export declare const parseZfsMountpoints: (content: string) => Map<string, string>;
|
|
39
|
+
export declare const zfsPoolsLinux: (data: FsBlockDevicesData[]) => Promise<PoolInfoLinux[]>;
|
|
40
|
+
export declare const btrfsPoolsLinux: (data: FsBlockDevicesData[]) => Promise<PoolInfoLinux[]>;
|
package/dist/common/filesys.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.matchDevicesWin = exports.matchDevicesLinux = exports.raidMatchLinux = exports.parseLinuxBlk = exports.blkStdoutToObject = exports.calcDiskIO = exports._disk_io = exports.calcFsSpeed = exports._fs_speed = exports.smartMonToolsInstalled = exports.zfsDatasets = void 0;
|
|
3
|
+
exports.btrfsPoolsLinux = exports.zfsPoolsLinux = exports.parseZfsMountpoints = exports.applyPoolsLinux = exports.btrfsProfileFromEntries = exports.parseZpoolList = exports.parseZpoolStatus = exports.matchDevicesWin = exports.matchDevicesLinux = exports.raidMatchLinux = exports.parseLinuxBlk = exports.blkStdoutToObject = exports.calcDiskIO = exports._disk_io = exports.calcFsSpeed = exports._fs_speed = exports.smartMonToolsInstalled = exports.zfsDatasets = void 0;
|
|
4
|
+
const promises_1 = require("node:fs/promises");
|
|
4
5
|
const index_1 = require("./index");
|
|
5
6
|
const const_1 = require("./const");
|
|
6
7
|
const defaults_1 = require("./defaults");
|
|
7
8
|
const exec_1 = require("./exec");
|
|
9
|
+
const security_1 = require("./security");
|
|
8
10
|
let _smartMonToolsInstalled = null;
|
|
9
11
|
const zfsDatasets = async () => {
|
|
10
12
|
const byMount = new Map();
|
|
@@ -235,7 +237,10 @@ const raidMatchLinux = async (data) => {
|
|
|
235
237
|
try {
|
|
236
238
|
for (const element of data) {
|
|
237
239
|
if (element.type.startsWith('raid')) {
|
|
238
|
-
|
|
240
|
+
if (!(0, security_1.isSafePathSegment)(element.name)) {
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
243
|
+
const stdout = await (0, exec_1.execSecure)('mdadm', ['--export', '--detail', `/dev/${element.name}`], { timeout: 5000 });
|
|
239
244
|
const lines = stdout.split('\n');
|
|
240
245
|
const mdData = decodeMdabmData(lines);
|
|
241
246
|
element.label = mdData.label;
|
|
@@ -311,3 +316,163 @@ const matchDevicesWin = (data, diskDrives) => {
|
|
|
311
316
|
return data;
|
|
312
317
|
};
|
|
313
318
|
exports.matchDevicesWin = matchDevicesWin;
|
|
319
|
+
const ZFS_VDEV_TYPES = ['mirror', 'raidz', 'draid'];
|
|
320
|
+
const parseZpoolStatus = (stdout) => {
|
|
321
|
+
const result = new Map();
|
|
322
|
+
let pool = '';
|
|
323
|
+
let inConfig = false;
|
|
324
|
+
for (const line of stdout.split('\n')) {
|
|
325
|
+
const trimmed = line.trim();
|
|
326
|
+
if (trimmed.startsWith('pool:')) {
|
|
327
|
+
pool = trimmed.substring(5).trim();
|
|
328
|
+
inConfig = false;
|
|
329
|
+
continue;
|
|
330
|
+
}
|
|
331
|
+
if (!pool) {
|
|
332
|
+
continue;
|
|
333
|
+
}
|
|
334
|
+
if (trimmed === 'config:') {
|
|
335
|
+
inConfig = true;
|
|
336
|
+
result.set(pool, { type: 'stripe', members: [] });
|
|
337
|
+
continue;
|
|
338
|
+
}
|
|
339
|
+
if (!inConfig || !trimmed || trimmed.startsWith('errors:')) {
|
|
340
|
+
inConfig = inConfig && !trimmed.startsWith('errors:');
|
|
341
|
+
continue;
|
|
342
|
+
}
|
|
343
|
+
const entry = result.get(pool);
|
|
344
|
+
const token = trimmed.split(/\s+/)[0];
|
|
345
|
+
if (!entry || token === 'NAME' || token === pool) {
|
|
346
|
+
continue;
|
|
347
|
+
}
|
|
348
|
+
if (token.startsWith('/')) {
|
|
349
|
+
entry.members.push(token.split('/').pop() || '');
|
|
350
|
+
}
|
|
351
|
+
else if (entry.type === 'stripe' && !entry.members.length && ZFS_VDEV_TYPES.some((type) => token.startsWith(type))) {
|
|
352
|
+
entry.type = token.replace(/-\d+$/, '');
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
return result;
|
|
356
|
+
};
|
|
357
|
+
exports.parseZpoolStatus = parseZpoolStatus;
|
|
358
|
+
const parseZpoolList = (stdout) => {
|
|
359
|
+
const result = new Map();
|
|
360
|
+
for (const line of stdout.split('\n')) {
|
|
361
|
+
const parts = line.split('\t');
|
|
362
|
+
if (parts.length < 2 || !parts[0].trim()) {
|
|
363
|
+
continue;
|
|
364
|
+
}
|
|
365
|
+
result.set(parts[0].trim(), (0, index_1.toInt)(parts[1]));
|
|
366
|
+
}
|
|
367
|
+
return result;
|
|
368
|
+
};
|
|
369
|
+
exports.parseZpoolList = parseZpoolList;
|
|
370
|
+
const BTRFS_PROFILES = ['raid1c4', 'raid1c3', 'raid10', 'raid0', 'raid5', 'raid6', 'raid1', 'dup', 'single'];
|
|
371
|
+
const btrfsProfileFromEntries = (entries) => BTRFS_PROFILES.find((profile) => entries.includes(profile)) || '';
|
|
372
|
+
exports.btrfsProfileFromEntries = btrfsProfileFromEntries;
|
|
373
|
+
const applyPoolsLinux = (data, pools) => {
|
|
374
|
+
const defaults = (0, index_1.cloneObj)(defaults_1.initFsBlockDevice);
|
|
375
|
+
const result = [...data];
|
|
376
|
+
for (const pool of pools) {
|
|
377
|
+
const members = result.filter((element) => pool.members.includes(element.name));
|
|
378
|
+
if (!members.length) {
|
|
379
|
+
continue;
|
|
380
|
+
}
|
|
381
|
+
for (const member of members) {
|
|
382
|
+
member.group = pool.name;
|
|
383
|
+
}
|
|
384
|
+
result.push({
|
|
385
|
+
...defaults,
|
|
386
|
+
name: pool.name,
|
|
387
|
+
type: pool.type,
|
|
388
|
+
fsType: pool.fsType,
|
|
389
|
+
mount: pool.mount,
|
|
390
|
+
size: pool.size,
|
|
391
|
+
uuid: pool.uuid
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
return result;
|
|
395
|
+
};
|
|
396
|
+
exports.applyPoolsLinux = applyPoolsLinux;
|
|
397
|
+
const parseZfsMountpoints = (content) => {
|
|
398
|
+
const result = new Map();
|
|
399
|
+
for (const line of content.split('\n')) {
|
|
400
|
+
const parts = line.split(' ');
|
|
401
|
+
if (parts.length < 3 || parts[2] !== 'zfs' || parts[0].includes('/')) {
|
|
402
|
+
continue;
|
|
403
|
+
}
|
|
404
|
+
result.set(parts[0], parts[1].replace(/\\(\d{3})/g, (_, code) => String.fromCharCode(parseInt(code, 8))));
|
|
405
|
+
}
|
|
406
|
+
return result;
|
|
407
|
+
};
|
|
408
|
+
exports.parseZfsMountpoints = parseZfsMountpoints;
|
|
409
|
+
const zfsPoolsLinux = async (data) => {
|
|
410
|
+
const result = [];
|
|
411
|
+
if (!data.some((element) => element.fsType === 'zfs_member')) {
|
|
412
|
+
return result;
|
|
413
|
+
}
|
|
414
|
+
try {
|
|
415
|
+
const status = (0, exports.parseZpoolStatus)(await (0, exec_1.execSecure)('zpool', ['status', '-PL'], { timeout: 5000 }));
|
|
416
|
+
if (!status.size) {
|
|
417
|
+
return result;
|
|
418
|
+
}
|
|
419
|
+
const sizes = (0, exports.parseZpoolList)(await (0, exec_1.execSecure)('zpool', ['list', '-Hp', '-o', 'name,size'], { timeout: 5000 }));
|
|
420
|
+
const mountpoints = (0, exports.parseZfsMountpoints)(await (0, promises_1.readFile)('/proc/mounts', 'utf8').catch(() => ''));
|
|
421
|
+
for (const [name, info] of status) {
|
|
422
|
+
const members = data.filter((element) => info.members.includes(element.name));
|
|
423
|
+
result.push({
|
|
424
|
+
name,
|
|
425
|
+
type: info.type,
|
|
426
|
+
fsType: 'zfs',
|
|
427
|
+
size: sizes.get(name) || members.reduce((sum, element) => sum + element.size, 0),
|
|
428
|
+
uuid: '',
|
|
429
|
+
mount: mountpoints.get(name) || '',
|
|
430
|
+
members: info.members
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
catch { }
|
|
435
|
+
return result;
|
|
436
|
+
};
|
|
437
|
+
exports.zfsPoolsLinux = zfsPoolsLinux;
|
|
438
|
+
const BTRFS_SYSFS = '/sys/fs/btrfs';
|
|
439
|
+
const btrfsPoolsLinux = async (data) => {
|
|
440
|
+
const result = [];
|
|
441
|
+
let fsids = [];
|
|
442
|
+
try {
|
|
443
|
+
fsids = (await (0, promises_1.readdir)(BTRFS_SYSFS)).filter(security_1.isSafePathSegment);
|
|
444
|
+
}
|
|
445
|
+
catch {
|
|
446
|
+
return result;
|
|
447
|
+
}
|
|
448
|
+
for (const fsid of fsids) {
|
|
449
|
+
let devices = [];
|
|
450
|
+
try {
|
|
451
|
+
devices = await (0, promises_1.readdir)(`${BTRFS_SYSFS}/${fsid}/devices`);
|
|
452
|
+
}
|
|
453
|
+
catch {
|
|
454
|
+
continue;
|
|
455
|
+
}
|
|
456
|
+
if (devices.length < 2) {
|
|
457
|
+
continue;
|
|
458
|
+
}
|
|
459
|
+
let profile = '';
|
|
460
|
+
try {
|
|
461
|
+
profile = (0, exports.btrfsProfileFromEntries)(await (0, promises_1.readdir)(`${BTRFS_SYSFS}/${fsid}/allocation/data`));
|
|
462
|
+
}
|
|
463
|
+
catch { }
|
|
464
|
+
const label = (await (0, promises_1.readFile)(`${BTRFS_SYSFS}/${fsid}/label`, 'utf8').catch(() => '')).trim();
|
|
465
|
+
const members = data.filter((element) => devices.includes(element.name));
|
|
466
|
+
result.push({
|
|
467
|
+
name: label || fsid,
|
|
468
|
+
type: profile || 'btrfs',
|
|
469
|
+
fsType: 'btrfs',
|
|
470
|
+
size: members.reduce((sum, element) => sum + element.size, 0),
|
|
471
|
+
uuid: fsid,
|
|
472
|
+
mount: members.find((element) => element.mount)?.mount || '',
|
|
473
|
+
members: devices
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
return result;
|
|
477
|
+
};
|
|
478
|
+
exports.btrfsPoolsLinux = btrfsPoolsLinux;
|
|
@@ -40,9 +40,6 @@ export declare const graphicsModelToVendor: (model: string) => string;
|
|
|
40
40
|
export declare const graphicsIdToVendor: (id: string) => any;
|
|
41
41
|
export declare const graphicsVendorToId: (str: string) => string;
|
|
42
42
|
export declare const graphicsMetalVersion: (id: string) => any;
|
|
43
|
-
export declare const winProcessStatus: {
|
|
44
|
-
[index: string]: any;
|
|
45
|
-
};
|
|
46
43
|
export declare const getAppleModel: (key: string) => {
|
|
47
44
|
key: string;
|
|
48
45
|
model: string;
|
package/dist/common/mappings.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseBluetoothVendor = exports.bluetoothVendors = exports.getAppleChassisType = exports.getAppleModel = exports.
|
|
3
|
+
exports.parseBluetoothVendor = exports.bluetoothVendors = exports.getAppleChassisType = exports.getAppleModel = exports.graphicsMetalVersion = exports.graphicsVendorToId = exports.graphicsIdToVendor = exports.graphicsModelToVendor = exports.graphicsVideoTypes = exports.diskVendorFromModel = exports.chassisTypes = exports.wifiFrequencies = exports.socketTypes = exports.cpuBrandManufacturer = exports.getAMDSpeed = exports.cpuManufacturer = exports.getSocketTypesByName = exports.winPrinterStatus = exports.raspberryClockSpeed = exports.getMemManufacturer = exports.JEDEV_RAM_manufacturers = exports.getWindowsRelease = exports.getLogoFile = exports.wifiVendor = exports.usbWindowsType = exports.usbDarwinType = exports.usbLinuxType = exports.manufacturedApple = exports.bluetoothManufacturer = exports.bluetoothTypeLabel = exports.audioWindowsStatus = exports.audioDarwinChannelLabel = exports.audioTypeLabel = void 0;
|
|
4
4
|
const const_1 = require("./const");
|
|
5
5
|
const speaker = 'Speaker';
|
|
6
6
|
const microphone = 'Microphone';
|
|
@@ -1674,18 +1674,6 @@ const graphicsMetalVersion = (id) => {
|
|
|
1674
1674
|
return families[id] || (version ? version[1] : '');
|
|
1675
1675
|
};
|
|
1676
1676
|
exports.graphicsMetalVersion = graphicsMetalVersion;
|
|
1677
|
-
exports.winProcessStatus = {
|
|
1678
|
-
'0': 'unknown',
|
|
1679
|
-
'1': 'other',
|
|
1680
|
-
'2': 'ready',
|
|
1681
|
-
'3': 'running',
|
|
1682
|
-
'4': 'blocked',
|
|
1683
|
-
'5': 'suspended blocked',
|
|
1684
|
-
'6': 'suspended ready',
|
|
1685
|
-
'7': 'terminated',
|
|
1686
|
-
'8': 'stopped',
|
|
1687
|
-
'9': 'growing'
|
|
1688
|
-
};
|
|
1689
1677
|
const getAppleModel = (key) => {
|
|
1690
1678
|
const appleModelIds = [
|
|
1691
1679
|
{
|
package/dist/common/types.d.ts
CHANGED
|
@@ -851,6 +851,9 @@ export type DisplayData = {
|
|
|
851
851
|
workAreaPositionY: number | null;
|
|
852
852
|
currentRefreshRate: number | null;
|
|
853
853
|
scale: number | null;
|
|
854
|
+
powerState: string;
|
|
855
|
+
gpu: string;
|
|
856
|
+
gpuBusAddress: string;
|
|
854
857
|
};
|
|
855
858
|
export type GpuNvidiaData = {
|
|
856
859
|
driverVersion: string;
|
|
@@ -933,6 +936,11 @@ export type ProcessesData = {
|
|
|
933
936
|
unknown: number;
|
|
934
937
|
list: ProcessesProcessData[];
|
|
935
938
|
};
|
|
939
|
+
export type ProcessFocusedData = {
|
|
940
|
+
pid: number;
|
|
941
|
+
name: string;
|
|
942
|
+
path: string;
|
|
943
|
+
};
|
|
936
944
|
export type ProcessLoadData = {
|
|
937
945
|
proc: string;
|
|
938
946
|
pid: number | null;
|
|
@@ -943,11 +951,14 @@ export type ProcessLoadData = {
|
|
|
943
951
|
export type NetworkInterfacesData = {
|
|
944
952
|
iface: string;
|
|
945
953
|
ifaceName: string;
|
|
954
|
+
vendor: string;
|
|
955
|
+
model: string;
|
|
946
956
|
default: boolean;
|
|
947
957
|
ip4: string;
|
|
948
958
|
ip4subnet: string;
|
|
949
959
|
ip6: string;
|
|
950
960
|
ip6subnet: string;
|
|
961
|
+
gateway: string;
|
|
951
962
|
mac: string;
|
|
952
963
|
internal: boolean;
|
|
953
964
|
virtual: boolean;
|
package/dist/common/windows.d.ts
CHANGED
|
@@ -55,4 +55,8 @@ declare class PowerShellPool {
|
|
|
55
55
|
}
|
|
56
56
|
export declare const psArray: (value: any) => any[];
|
|
57
57
|
export declare const ps: PowerShellPool;
|
|
58
|
+
export declare const parseWindowsLocationInfo: (value: string) => string;
|
|
59
|
+
export declare const parseWindowsPnpLocations: (stdout: any) => Map<string, string>;
|
|
60
|
+
export declare const matchPnpLocation: (deviceId: string, locations: Map<string, string>) => string;
|
|
61
|
+
export declare const windowsPciBusAddresses: () => Promise<Map<string, string>>;
|
|
58
62
|
export {};
|
package/dist/common/windows.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ps = exports.psArray = void 0;
|
|
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");
|
|
5
6
|
const files_1 = require("../common/files");
|
|
6
7
|
const const_1 = require("./const");
|
|
7
8
|
const WINDIR = process.env.WINDIR || String.raw `C:\Windows`;
|
|
@@ -290,3 +291,58 @@ exports.ps = new PowerShellPool({ size: 4 });
|
|
|
290
291
|
if (const_1.WINDOWS) {
|
|
291
292
|
process.on('exit', () => exports.ps.stop());
|
|
292
293
|
}
|
|
294
|
+
const parseWindowsLocationInfo = (value) => {
|
|
295
|
+
const text = String(value ?? '').trim();
|
|
296
|
+
if (!/pci/i.test(text)) {
|
|
297
|
+
return '';
|
|
298
|
+
}
|
|
299
|
+
const numbers = text.match(/\d+/g);
|
|
300
|
+
if (!numbers || numbers.length !== 3) {
|
|
301
|
+
return '';
|
|
302
|
+
}
|
|
303
|
+
const [bus, device, fn] = numbers.map((part) => parseInt(part, 10));
|
|
304
|
+
if ([bus, device, fn].some((part) => Number.isNaN(part))) {
|
|
305
|
+
return '';
|
|
306
|
+
}
|
|
307
|
+
return `${bus.toString(16).padStart(2, '0')}:${device.toString(16).padStart(2, '0')}.${fn.toString(16)}`;
|
|
308
|
+
};
|
|
309
|
+
exports.parseWindowsLocationInfo = parseWindowsLocationInfo;
|
|
310
|
+
const parseWindowsPnpLocations = (stdout) => {
|
|
311
|
+
const result = new Map();
|
|
312
|
+
for (const line of String(stdout ?? '').split('\n')) {
|
|
313
|
+
const separator = line.indexOf('|');
|
|
314
|
+
if (separator < 1) {
|
|
315
|
+
continue;
|
|
316
|
+
}
|
|
317
|
+
const busAddress = (0, exports.parseWindowsLocationInfo)(line.substring(separator + 1));
|
|
318
|
+
if (busAddress) {
|
|
319
|
+
result.set(line.substring(0, separator).trim().toLowerCase(), busAddress);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
return result;
|
|
323
|
+
};
|
|
324
|
+
exports.parseWindowsPnpLocations = parseWindowsPnpLocations;
|
|
325
|
+
const matchPnpLocation = (deviceId, locations) => {
|
|
326
|
+
const id = String(deviceId ?? '').trim().toLowerCase();
|
|
327
|
+
if (!id) {
|
|
328
|
+
return '';
|
|
329
|
+
}
|
|
330
|
+
const exact = locations.get(id);
|
|
331
|
+
if (exact) {
|
|
332
|
+
return exact;
|
|
333
|
+
}
|
|
334
|
+
const candidates = [...locations].filter(([instanceId]) => instanceId.startsWith(`${id}\\`));
|
|
335
|
+
return candidates.length === 1 ? candidates[0][1] : '';
|
|
336
|
+
};
|
|
337
|
+
exports.matchPnpLocation = matchPnpLocation;
|
|
338
|
+
const PS_PNP_DISPLAY_LOCATIONS = 'Get-PnpDevice -Class Display -PresentOnly -ErrorAction SilentlyContinue | ForEach-Object { ' +
|
|
339
|
+
"$l = ($_ | Get-PnpDeviceProperty -KeyName DEVPKEY_Device_LocationInfo -ErrorAction SilentlyContinue).Data; \"$($_.InstanceId)|$l\" }";
|
|
340
|
+
const windowsPciBusAddresses = async () => {
|
|
341
|
+
try {
|
|
342
|
+
return (0, exports.parseWindowsPnpLocations)(await (0, exec_1.shareInflight)('pnpDisplayLocations', () => exports.ps.exec(PS_PNP_DISPLAY_LOCATIONS)));
|
|
343
|
+
}
|
|
344
|
+
catch {
|
|
345
|
+
return new Map();
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
exports.windowsPciBusAddresses = windowsPciBusAddresses;
|
package/dist/cpu-current-load.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.currentLoad = void 0;
|
|
3
|
+
exports.currentLoad = exports.avgLoadEwma = void 0;
|
|
4
4
|
const node_os_1 = require("node:os");
|
|
5
5
|
const common_1 = require("./common");
|
|
6
6
|
const const_1 = require("./common/const");
|
|
@@ -39,10 +39,24 @@ let _current_cpu = {
|
|
|
39
39
|
};
|
|
40
40
|
const _cpus = [];
|
|
41
41
|
let _corecount = 0;
|
|
42
|
+
const AVG_LOAD_PERIODS = [60, 300, 900];
|
|
43
|
+
let _avgLoadEwma = [0, 0, 0];
|
|
44
|
+
let _avgLoadEwmaMs = null;
|
|
45
|
+
const avgLoadEwma = (previous, busyCores, seconds) => {
|
|
46
|
+
if (!previous || seconds <= 0) {
|
|
47
|
+
return [busyCores, busyCores, busyCores];
|
|
48
|
+
}
|
|
49
|
+
return AVG_LOAD_PERIODS.map((period, i) => {
|
|
50
|
+
const decay = Math.exp(-seconds / period);
|
|
51
|
+
return (previous[i] || 0) * decay + busyCores * (1 - decay);
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
exports.avgLoadEwma = avgLoadEwma;
|
|
55
|
+
const avgLoadFromEwma = (cores) => (cores ? parseFloat((Math.max(..._avgLoadEwma) / cores).toFixed(2)) : 0);
|
|
42
56
|
const currentLoad = async () => {
|
|
43
57
|
await (0, common_1.nextTick)();
|
|
44
58
|
const loads = (0, node_os_1.loadavg)().map((x) => x / (0, node_os_1.cpus)().length);
|
|
45
|
-
|
|
59
|
+
let avgLoad = parseFloat(Math.max(...loads).toFixed(2));
|
|
46
60
|
let result = {
|
|
47
61
|
avgLoad: 0,
|
|
48
62
|
currentLoad: 0,
|
|
@@ -165,6 +179,13 @@ const currentLoad = async () => {
|
|
|
165
179
|
const totalTick = totalUser + totalSystem + totalNice + totalIrq + totalSteal + totalGuest + totalIdle + totalIowait;
|
|
166
180
|
const totalLoad = totalUser + totalSystem + totalNice + totalIrq + totalSteal + totalGuest;
|
|
167
181
|
const currentTick = totalTick - _current_cpu.tick || 1;
|
|
182
|
+
if (const_1.WINDOWS) {
|
|
183
|
+
const busyCores = ((totalLoad - _current_cpu.load) / currentTick) * _corecount;
|
|
184
|
+
const seconds = _avgLoadEwmaMs === null ? 0 : (_current_cpu.ms - _avgLoadEwmaMs) / 1000;
|
|
185
|
+
_avgLoadEwma = (0, exports.avgLoadEwma)(_avgLoadEwmaMs === null ? null : _avgLoadEwma, busyCores, seconds);
|
|
186
|
+
_avgLoadEwmaMs = _current_cpu.ms;
|
|
187
|
+
avgLoad = avgLoadFromEwma(_corecount);
|
|
188
|
+
}
|
|
168
189
|
result = {
|
|
169
190
|
avgLoad: avgLoad,
|
|
170
191
|
currentLoad: ((totalLoad - _current_cpu.load) / currentTick) * 100,
|
|
@@ -220,6 +241,9 @@ const currentLoad = async () => {
|
|
|
220
241
|
};
|
|
221
242
|
}
|
|
222
243
|
else {
|
|
244
|
+
if (const_1.WINDOWS) {
|
|
245
|
+
avgLoad = avgLoadFromEwma(_corecount);
|
|
246
|
+
}
|
|
223
247
|
const cores = [];
|
|
224
248
|
for (let i = 0; i < _corecount; i++) {
|
|
225
249
|
cores[i] = {};
|
package/dist/darwin/displays.js
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.displays = void 0;
|
|
3
|
+
exports.displays = exports.parseIoregPowerState = void 0;
|
|
4
4
|
const common_1 = require("../common");
|
|
5
5
|
const darwin_1 = require("../common/darwin");
|
|
6
6
|
const exec_1 = require("../common/exec");
|
|
7
|
+
const EXEC_OPTS = { timeout: 5000 };
|
|
7
8
|
const mappings_1 = require("../common/mappings");
|
|
8
9
|
const parseDisplaysDarwin = (graphicsArr) => {
|
|
9
10
|
const displays = [];
|
|
10
11
|
try {
|
|
11
12
|
graphicsArr.forEach((item) => {
|
|
12
13
|
if (item.spdisplays_ndrvs && item.spdisplays_ndrvs.length) {
|
|
14
|
+
const gpu = item['sppci_model'] || item['_name'] || '';
|
|
13
15
|
item.spdisplays_ndrvs.forEach((displayItem) => {
|
|
14
16
|
const connectionType = displayItem['spdisplays_connection_type'] || '';
|
|
15
17
|
const currentResolutionParts = (displayItem['_spdisplays_resolution'] || '').split('@');
|
|
@@ -42,6 +44,9 @@ const parseDisplaysDarwin = (graphicsArr) => {
|
|
|
42
44
|
workAreaResolutionY: null,
|
|
43
45
|
workAreaPositionX: null,
|
|
44
46
|
workAreaPositionY: null,
|
|
47
|
+
powerState: '',
|
|
48
|
+
gpu,
|
|
49
|
+
gpuBusAddress: '',
|
|
45
50
|
currentRefreshRate: currentResolutionParts.length > 1 ? parseInt(currentResolutionParts[1], 10) : null,
|
|
46
51
|
scale: null
|
|
47
52
|
});
|
|
@@ -116,6 +121,26 @@ const getWorkAreaDarwin = async (displays) => {
|
|
|
116
121
|
catch { }
|
|
117
122
|
return displays;
|
|
118
123
|
};
|
|
124
|
+
const parseIoregPowerState = (stdout) => {
|
|
125
|
+
const match = stdout.match(/"MaxPowerState"=(\d+)[^}]*"CurrentPowerState"=(\d+)/);
|
|
126
|
+
if (!match) {
|
|
127
|
+
return '';
|
|
128
|
+
}
|
|
129
|
+
const max = (0, common_1.toInt)(match[1]);
|
|
130
|
+
const current = (0, common_1.toInt)(match[2]);
|
|
131
|
+
if (!max) {
|
|
132
|
+
return '';
|
|
133
|
+
}
|
|
134
|
+
if (current >= max) {
|
|
135
|
+
return 'on';
|
|
136
|
+
}
|
|
137
|
+
if (!current) {
|
|
138
|
+
return 'off';
|
|
139
|
+
}
|
|
140
|
+
return current === max - 1 ? 'standby' : 'suspend';
|
|
141
|
+
};
|
|
142
|
+
exports.parseIoregPowerState = parseIoregPowerState;
|
|
143
|
+
const getPowerStateDarwin = async () => (0, exports.parseIoregPowerState)(await (0, exec_1.execSecure)('ioreg', ['-n', 'IODisplayWrangler', '-r', '-d', '1'], EXEC_OPTS));
|
|
119
144
|
const displays = async () => {
|
|
120
145
|
await (0, common_1.nextTick)();
|
|
121
146
|
let result = [];
|
|
@@ -124,6 +149,10 @@ const displays = async () => {
|
|
|
124
149
|
result = parseDisplaysDarwin((0, darwin_1.plistParser)(stdout));
|
|
125
150
|
result = await getDisplayPositionDarwin(result);
|
|
126
151
|
result = await getWorkAreaDarwin(result);
|
|
152
|
+
const powerState = await getPowerStateDarwin();
|
|
153
|
+
for (const display of result) {
|
|
154
|
+
display.powerState = powerState;
|
|
155
|
+
}
|
|
127
156
|
}
|
|
128
157
|
catch { }
|
|
129
158
|
return result;
|
package/dist/darwin/index.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ export { pci } from './pci';
|
|
|
40
40
|
export { printer } from './printer';
|
|
41
41
|
export { processes } from '../linux/processes';
|
|
42
42
|
export { processLoad } from '../linux/process-load';
|
|
43
|
+
export { processFocused } from './process-focused';
|
|
43
44
|
export { services } from '../linux/services';
|
|
44
45
|
export { shell } from '../shell';
|
|
45
46
|
export { software } from './software';
|