systeminformation 6.0.0-beta.13 → 6.0.0-beta.15
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 +7 -2
- package/dist/bsd/mem.js +8 -3
- package/dist/bsd/network-stats.d.ts +1 -1
- package/dist/bsd/network-stats.js +11 -5
- package/dist/bsd/os-info.d.ts +1 -0
- package/dist/common/defaults.js +9 -1
- package/dist/common/filesys.d.ts +1 -0
- package/dist/common/filesys.js +23 -2
- package/dist/common/network.d.ts +13 -1
- package/dist/common/network.js +15 -21
- package/dist/common/security.d.ts +1 -0
- package/dist/common/security.js +10 -1
- package/dist/common/types.d.ts +9 -0
- package/dist/darwin/network-stats.d.ts +1 -1
- package/dist/darwin/network-stats.js +8 -2
- package/dist/darwin/os-info.d.ts +2 -0
- package/dist/darwin/os-info.js +24 -2
- package/dist/linux/cpu-temperature.js +1 -1
- package/dist/linux/fs-size.d.ts +1 -1
- package/dist/linux/fs-size.js +6 -5
- package/dist/linux/gpu.d.ts +1 -0
- package/dist/linux/gpu.js +66 -1
- package/dist/linux/mem-layout.js +1 -5
- package/dist/linux/mem.d.ts +1 -0
- package/dist/linux/mem.js +21 -1
- package/dist/linux/network-stats.d.ts +1 -1
- package/dist/linux/network-stats.js +9 -7
- package/dist/linux/os-info.js +37 -1
- package/dist/windows/fs-size.js +1 -4
- package/dist/windows/network-stats.js +16 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -314,12 +314,12 @@ Full function reference with examples can be found at [https://systeminformation
|
|
|
314
314
|
| | total | X | X | X | X | X | total memory in bytes |
|
|
315
315
|
| | free | X | X | X | X | X | not used in bytes |
|
|
316
316
|
| | used | X | X | X | X | X | used (incl. buffers/cache) |
|
|
317
|
-
| | active | X | X | X | X | X | used actively (excl. buffers/cache)
|
|
317
|
+
| | active | X | X | X | X | X | used actively (excl. buffers/cache and ZFS ARC) |
|
|
318
318
|
| | buffcache | X | X | X | | X | used by buffers+cache |
|
|
319
319
|
| | buffers | X | | | | | used by buffers |
|
|
320
320
|
| | cached | X | | | | | used by cache |
|
|
321
321
|
| | slab | X | | | | | used by slab |
|
|
322
|
-
| | available | X | X | X | X | X | potentially available (total - active) |
|
|
322
|
+
| | available | X | X | X | X | X | potentially available (total - active), incl. reclaimable ZFS ARC |
|
|
323
323
|
| | swaptotal | X | X | X | X | X | |
|
|
324
324
|
| | swapused | X | X | X | X | X | |
|
|
325
325
|
| | swapfree | X | X | X | X | X | |
|
|
@@ -365,6 +365,8 @@ In v6 the former `graphics()` function was split into `si.gpu()` (graphics contr
|
|
|
365
365
|
|
|
366
366
|
On Windows, `si.displays()` reports physical monitors: in duplicate/mirror mode each mirrored monitor gets its own entry (sharing the resolution and position of the mirrored screen).
|
|
367
367
|
|
|
368
|
+
On Linux, `si.gpu()` also covers the integrated GPU of NVIDIA Tegra / Jetson boards. It is a device tree platform device rather than a PCI one, so `model`, `utilizationGpu`, `temperatureGpu` and `clockCore` are read from the Tegra sysfs nodes - neither `tegrastats` nor `jtop` is required. Its memory is shared with the system, so `vram` is `null` and `vramDynamic` is `true`.
|
|
369
|
+
|
|
368
370
|
| Function | Result object | Linux | BSD | Mac | Win | Sun | Comments |
|
|
369
371
|
| ------------- | ---------------------- | ----- | --- | --- | --- | --- | --------------------------------- |
|
|
370
372
|
| si.gpu() | [{...}] | X | | X | X | | array of graphics controllers |
|
|
@@ -434,6 +436,7 @@ On Windows, `si.displays()` reports physical monitors: in duplicate/mirror mode
|
|
|
434
436
|
| | remoteSession | | | | X | | runs in remote session (win only) |
|
|
435
437
|
| | installDate | X | | X | X | | OS installation date (Date object or null) |
|
|
436
438
|
| | displayServer | X | X | X | X | X | display server e.g. wayland, x11, quartz, dwm, surfaceflinger or '' (headless) |
|
|
439
|
+
| | security | X | | X | | | mandatory access control / system integrity (module, enabled, mode, policy) |
|
|
437
440
|
| si.uuid() | {...} | X | X | X | X | X | object of several UUIDs |
|
|
438
441
|
| | os | X | X | X | X | | os specific UUID |
|
|
439
442
|
| | hardware | X | X | X | X | | hardware specific UUID |
|
|
@@ -722,9 +725,11 @@ On Windows, `si.displays()` reports physical monitors: in duplicate/mirror mode
|
|
|
722
725
|
| | [0].iface | X | X | X | X | | interface |
|
|
723
726
|
| | [0].operstate | X | X | X | X | | up / down |
|
|
724
727
|
| | [0].rx_bytes | X | X | X | X | | received bytes overall |
|
|
728
|
+
| | [0].rx_packets | X | X | X | X | | received packets overall |
|
|
725
729
|
| | [0].rx_dropped | X | X | X | X | | received dropped overall |
|
|
726
730
|
| | [0].rx_errors | X | X | X | X | | received errors overall |
|
|
727
731
|
| | [0].tx_bytes | X | X | X | X | | transferred bytes overall |
|
|
732
|
+
| | [0].tx_packets | X | X | X | X | | transferred packets overall |
|
|
728
733
|
| | [0].tx_dropped | X | X | X | X | | transferred dropped overall |
|
|
729
734
|
| | [0].tx_errors | X | X | X | X | | transferred errors overall |
|
|
730
735
|
| | [0].rx_sec | X | X | X | X | | received bytes / second (* see notes) |
|
package/dist/bsd/mem.js
CHANGED
|
@@ -8,7 +8,7 @@ const mem = async () => {
|
|
|
8
8
|
await (0, common_1.nextTick)();
|
|
9
9
|
const defaults = (0, common_1.cloneObj)(defaults_1.initMemData);
|
|
10
10
|
try {
|
|
11
|
-
const { stdout } = await (0, exec_1.execSave)('/sbin/sysctl -i hw.realmem hw.physmem vm.stats.vm.v_page_count vm.stats.vm.v_wire_count vm.stats.vm.v_active_count vm.stats.vm.v_inactive_count vm.stats.vm.v_cache_count vm.stats.vm.v_free_count vm.stats.vm.v_page_size');
|
|
11
|
+
const { stdout } = await (0, exec_1.execSave)('/sbin/sysctl -i hw.realmem hw.physmem vm.stats.vm.v_page_count vm.stats.vm.v_wire_count vm.stats.vm.v_active_count vm.stats.vm.v_inactive_count vm.stats.vm.v_cache_count vm.stats.vm.v_free_count vm.stats.vm.v_page_size kstat.zfs.misc.arcstats.size kstat.zfs.misc.arcstats.c_min');
|
|
12
12
|
const lines = stdout.toString().split('\n');
|
|
13
13
|
const pagesize = parseInt((0, common_1.getValue)(lines, 'vm.stats.vm.v_page_size'), 10);
|
|
14
14
|
const inactive = parseInt((0, common_1.getValue)(lines, 'vm.stats.vm.v_inactive_count'), 10) * pagesize;
|
|
@@ -19,13 +19,18 @@ const mem = async () => {
|
|
|
19
19
|
if (isNaN(total)) {
|
|
20
20
|
total = parseInt((0, common_1.getValue)(lines, 'hw.physmem'), 10);
|
|
21
21
|
}
|
|
22
|
+
const arcSize = parseInt((0, common_1.getValue)(lines, 'kstat.zfs.misc.arcstats.size'), 10) || 0;
|
|
23
|
+
const arcMin = parseInt((0, common_1.getValue)(lines, 'kstat.zfs.misc.arcstats.c_min'), 10) || 0;
|
|
24
|
+
const arc = Math.max(arcSize - arcMin, 0);
|
|
25
|
+
const available = Math.min(total, buffcache + free + arc);
|
|
22
26
|
return {
|
|
23
27
|
...defaults,
|
|
24
28
|
total,
|
|
25
29
|
free,
|
|
30
|
+
used: total - free,
|
|
26
31
|
buffcache,
|
|
27
|
-
available
|
|
28
|
-
active: total -
|
|
32
|
+
available,
|
|
33
|
+
active: total - available,
|
|
29
34
|
swaptotal: 0,
|
|
30
35
|
swapfree: 0,
|
|
31
36
|
swapused: 0
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { NetworkStatsData } from '../common/types';
|
|
1
|
+
import type { NetworkStatsData } from '../common/types';
|
|
2
2
|
export declare const networkStats: (interfaces: string) => Promise<NetworkStatsData[]>;
|
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.networkStats = void 0;
|
|
4
|
-
const exec_1 = require("../common/exec");
|
|
5
4
|
const common_1 = require("../common");
|
|
6
|
-
const security_1 = require("../common/security");
|
|
7
5
|
const defaults_1 = require("../common/defaults");
|
|
8
|
-
const
|
|
6
|
+
const exec_1 = require("../common/exec");
|
|
9
7
|
const network_1 = require("../common/network");
|
|
8
|
+
const security_1 = require("../common/security");
|
|
9
|
+
const darwin_1 = require("../darwin");
|
|
10
10
|
const EXEC_OPTS = { timeout: 5000 };
|
|
11
|
-
const _network =
|
|
11
|
+
const _network = Object.create(null);
|
|
12
12
|
const networkStatsSingle = async (iface) => {
|
|
13
13
|
const defaults = { ...defaults_1.initNetworkSpeed, iface };
|
|
14
14
|
if (!_network[iface] || (_network[iface] && !_network[iface].ms) || (_network[iface] && _network[iface].ms && Date.now() - _network[iface].ms >= 500)) {
|
|
15
15
|
let operstate = 'unknown';
|
|
16
16
|
let rx_bytes = 0;
|
|
17
17
|
let tx_bytes = 0;
|
|
18
|
+
let rx_packets = 0;
|
|
19
|
+
let tx_packets = 0;
|
|
18
20
|
let rx_dropped = 0;
|
|
19
21
|
let rx_errors = 0;
|
|
20
22
|
let tx_dropped = 0;
|
|
@@ -26,6 +28,8 @@ const networkStatsSingle = async (iface) => {
|
|
|
26
28
|
const line = lines[i].replace(/ +/g, ' ').split(' ');
|
|
27
29
|
if (line && line[0] && line[7] && line[10]) {
|
|
28
30
|
rx_bytes = rx_bytes + (0, common_1.toInt)(line[7]);
|
|
31
|
+
rx_packets = rx_packets + (0, common_1.toInt)(line[4]);
|
|
32
|
+
tx_packets = tx_packets + (0, common_1.toInt)(line[8]);
|
|
29
33
|
if (line[6].trim() !== '-') {
|
|
30
34
|
rx_dropped = rx_dropped + (0, common_1.toInt)(line[6]);
|
|
31
35
|
}
|
|
@@ -42,7 +46,7 @@ const networkStatsSingle = async (iface) => {
|
|
|
42
46
|
operstate = 'up';
|
|
43
47
|
}
|
|
44
48
|
}
|
|
45
|
-
return (0, network_1.calcNetworkSpeed)(iface, rx_bytes, tx_bytes, rx_dropped, rx_errors, tx_dropped, tx_errors, operstate, _network);
|
|
49
|
+
return (0, network_1.calcNetworkSpeed)({ iface, rx_bytes, tx_bytes, rx_packets, tx_packets, rx_dropped, rx_errors, tx_dropped, tx_errors, operstate }, _network);
|
|
46
50
|
}
|
|
47
51
|
return defaults;
|
|
48
52
|
}
|
|
@@ -51,6 +55,8 @@ const networkStatsSingle = async (iface) => {
|
|
|
51
55
|
...defaults,
|
|
52
56
|
rx_bytes: _network[iface].rx_bytes,
|
|
53
57
|
tx_bytes: _network[iface].tx_bytes,
|
|
58
|
+
rx_packets: _network[iface].rx_packets,
|
|
59
|
+
tx_packets: _network[iface].tx_packets,
|
|
54
60
|
rx_sec: _network[iface].rx_sec,
|
|
55
61
|
tx_sec: _network[iface].tx_sec,
|
|
56
62
|
rx_dropped: _network[iface].rx_dropped,
|
package/dist/bsd/os-info.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export declare const osInfo: () => Promise<import("../common/types").OsData | {
|
|
|
18
18
|
installDate: Date | null;
|
|
19
19
|
awake: boolean;
|
|
20
20
|
hwAcceleration: string[];
|
|
21
|
+
security: import("../common/types").OsSecurityData;
|
|
21
22
|
hypervizor?: boolean;
|
|
22
23
|
remoteSession?: boolean;
|
|
23
24
|
hypervisor?: boolean;
|
package/dist/common/defaults.js
CHANGED
|
@@ -135,7 +135,13 @@ const initOsInfo = async () => {
|
|
|
135
135
|
lastUpdate: null,
|
|
136
136
|
displayServer: '',
|
|
137
137
|
awake: true,
|
|
138
|
-
hwAcceleration: await (0, acceleration_1.hwAcceleration)()
|
|
138
|
+
hwAcceleration: await (0, acceleration_1.hwAcceleration)(),
|
|
139
|
+
security: {
|
|
140
|
+
module: '',
|
|
141
|
+
enabled: false,
|
|
142
|
+
mode: '',
|
|
143
|
+
policy: ''
|
|
144
|
+
}
|
|
139
145
|
};
|
|
140
146
|
};
|
|
141
147
|
exports.initOsInfo = initOsInfo;
|
|
@@ -315,9 +321,11 @@ exports.initNetworkSpeed = {
|
|
|
315
321
|
iface: '',
|
|
316
322
|
operstate: '',
|
|
317
323
|
rx_bytes: 0,
|
|
324
|
+
rx_packets: 0,
|
|
318
325
|
rx_dropped: 0,
|
|
319
326
|
rx_errors: 0,
|
|
320
327
|
tx_bytes: 0,
|
|
328
|
+
tx_packets: 0,
|
|
321
329
|
tx_dropped: 0,
|
|
322
330
|
tx_errors: 0,
|
|
323
331
|
rx_sec: null,
|
package/dist/common/filesys.d.ts
CHANGED
|
@@ -34,6 +34,7 @@ export declare const parseZpoolStatus: (stdout: string) => Map<string, {
|
|
|
34
34
|
}>;
|
|
35
35
|
export declare const parseZpoolList: (stdout: string) => Map<string, number>;
|
|
36
36
|
export declare const btrfsProfileFromEntries: (entries: string[]) => string;
|
|
37
|
+
export declare const btrfsUsableSize: (profile: string, sizes: number[]) => number;
|
|
37
38
|
export declare const applyPoolsLinux: (data: FsBlockDevicesData[], pools: PoolInfoLinux[]) => FsBlockDevicesData[];
|
|
38
39
|
export declare const parseZfsMountpoints: (content: string) => Map<string, string>;
|
|
39
40
|
export declare const zfsPoolsLinux: (data: FsBlockDevicesData[]) => Promise<PoolInfoLinux[]>;
|
package/dist/common/filesys.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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;
|
|
3
|
+
exports.btrfsPoolsLinux = exports.zfsPoolsLinux = exports.parseZfsMountpoints = exports.applyPoolsLinux = exports.btrfsUsableSize = 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
4
|
const promises_1 = require("node:fs/promises");
|
|
5
5
|
const index_1 = require("./index");
|
|
6
6
|
const const_1 = require("./const");
|
|
@@ -370,6 +370,27 @@ exports.parseZpoolList = parseZpoolList;
|
|
|
370
370
|
const BTRFS_PROFILES = ['raid1c4', 'raid1c3', 'raid10', 'raid0', 'raid5', 'raid6', 'raid1', 'dup', 'single'];
|
|
371
371
|
const btrfsProfileFromEntries = (entries) => BTRFS_PROFILES.find((profile) => entries.includes(profile)) || '';
|
|
372
372
|
exports.btrfsProfileFromEntries = btrfsProfileFromEntries;
|
|
373
|
+
const btrfsUsableSize = (profile, sizes) => {
|
|
374
|
+
const sum = sizes.reduce((total, size) => total + size, 0);
|
|
375
|
+
const largest = [...sizes].sort((a, b) => b - a);
|
|
376
|
+
switch (profile) {
|
|
377
|
+
case 'dup':
|
|
378
|
+
case 'raid1':
|
|
379
|
+
case 'raid10':
|
|
380
|
+
return Math.floor(sum / 2);
|
|
381
|
+
case 'raid1c3':
|
|
382
|
+
return Math.floor(sum / 3);
|
|
383
|
+
case 'raid1c4':
|
|
384
|
+
return Math.floor(sum / 4);
|
|
385
|
+
case 'raid5':
|
|
386
|
+
return sizes.length > 1 ? sum - (largest[0] || 0) : sum;
|
|
387
|
+
case 'raid6':
|
|
388
|
+
return sizes.length > 2 ? sum - (largest[0] || 0) - (largest[1] || 0) : sum;
|
|
389
|
+
default:
|
|
390
|
+
return sum;
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
exports.btrfsUsableSize = btrfsUsableSize;
|
|
373
394
|
const applyPoolsLinux = (data, pools) => {
|
|
374
395
|
const defaults = (0, index_1.cloneObj)(defaults_1.initFsBlockDevice);
|
|
375
396
|
const result = [...data];
|
|
@@ -467,7 +488,7 @@ const btrfsPoolsLinux = async (data) => {
|
|
|
467
488
|
name: label || fsid,
|
|
468
489
|
type: profile || 'btrfs',
|
|
469
490
|
fsType: 'btrfs',
|
|
470
|
-
size: members.reduce((sum, element) => sum + element.size, 0),
|
|
491
|
+
size: members.length === devices.length ? (0, exports.btrfsUsableSize)(profile, members.map((element) => element.size)) : members.reduce((sum, element) => sum + element.size, 0),
|
|
471
492
|
uuid: fsid,
|
|
472
493
|
mount: members.find((element) => element.mount)?.mount || '',
|
|
473
494
|
members: devices
|
package/dist/common/network.d.ts
CHANGED
|
@@ -5,4 +5,16 @@ export declare const wifiFrequencyFromChannel: (channel: number) => any;
|
|
|
5
5
|
export declare const wifiChannelFromFrequencies: (frequency: number) => number;
|
|
6
6
|
export declare const getFirstExternalNetworkInterface: (interfaces: any) => string;
|
|
7
7
|
export declare const testVirtualNic: (iface: string, ifaceName: string, mac: string) => boolean;
|
|
8
|
-
export
|
|
8
|
+
export type NetworkCounters = {
|
|
9
|
+
iface: string;
|
|
10
|
+
rx_bytes: number;
|
|
11
|
+
tx_bytes: number;
|
|
12
|
+
rx_packets: number;
|
|
13
|
+
tx_packets: number;
|
|
14
|
+
rx_dropped: number;
|
|
15
|
+
rx_errors: number;
|
|
16
|
+
tx_dropped: number;
|
|
17
|
+
tx_errors: number;
|
|
18
|
+
operstate: string;
|
|
19
|
+
};
|
|
20
|
+
export declare const calcNetworkSpeed: (counters: NetworkCounters, _network: any) => NetworkStatsData;
|
package/dist/common/network.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.calcNetworkSpeed = exports.testVirtualNic = exports.getFirstExternalNetworkInterface = exports.wifiChannelFromFrequencies = exports.wifiFrequencyFromChannel = exports.wifiQualityFromDB = exports.wifiDBFromQuality = void 0;
|
|
4
|
-
const defaults_1 = require("./defaults");
|
|
5
4
|
const index_1 = require("./index");
|
|
6
5
|
const mappings_1 = require("./mappings");
|
|
7
6
|
const wifiDBFromQuality = (quality) => {
|
|
@@ -104,8 +103,8 @@ const testVirtualNic = (iface, ifaceName, mac) => {
|
|
|
104
103
|
}
|
|
105
104
|
};
|
|
106
105
|
exports.testVirtualNic = testVirtualNic;
|
|
107
|
-
const calcNetworkSpeed = (
|
|
108
|
-
const
|
|
106
|
+
const calcNetworkSpeed = (counters, _network) => {
|
|
107
|
+
const { iface, rx_bytes, tx_bytes, rx_packets, tx_packets, rx_dropped, rx_errors, tx_dropped, tx_errors, operstate } = counters;
|
|
109
108
|
let rx_sec = null;
|
|
110
109
|
let tx_sec = null;
|
|
111
110
|
let rx_bytes_intervall = 0;
|
|
@@ -117,41 +116,36 @@ const calcNetworkSpeed = (iface, rx_bytes, tx_bytes, rx_dropped, rx_errors, tx_d
|
|
|
117
116
|
tx_bytes_intervall = tx_bytes - _network[iface].tx_bytes;
|
|
118
117
|
rx_sec = rx_bytes_intervall >= 0 ? rx_bytes_intervall / (ms / 1000) : 0;
|
|
119
118
|
tx_sec = tx_bytes_intervall >= 0 ? tx_bytes_intervall / (ms / 1000) : 0;
|
|
120
|
-
_network[iface].rx_bytes = rx_bytes;
|
|
121
|
-
_network[iface].tx_bytes = tx_bytes;
|
|
122
119
|
_network[iface].rx_sec = rx_sec;
|
|
123
120
|
_network[iface].tx_sec = tx_sec;
|
|
124
|
-
_network[iface].rx_dropped = rx_dropped;
|
|
125
|
-
_network[iface].rx_errors = rx_errors;
|
|
126
|
-
_network[iface].tx_dropped = tx_dropped;
|
|
127
|
-
_network[iface].tx_errors = tx_errors;
|
|
128
|
-
_network[iface].ms = Date.now();
|
|
129
|
-
_network[iface].last_ms = result.ms;
|
|
130
|
-
_network[iface].operstate = operstate;
|
|
131
121
|
}
|
|
132
122
|
else {
|
|
133
123
|
if (!_network[iface]) {
|
|
134
124
|
_network[iface] = {};
|
|
135
125
|
}
|
|
136
|
-
_network[iface].rx_bytes = rx_bytes;
|
|
137
|
-
_network[iface].tx_bytes = tx_bytes;
|
|
138
126
|
_network[iface].rx_sec = null;
|
|
139
127
|
_network[iface].tx_sec = null;
|
|
140
|
-
_network[iface].rx_dropped = rx_dropped;
|
|
141
|
-
_network[iface].rx_errors = rx_errors;
|
|
142
|
-
_network[iface].tx_dropped = tx_dropped;
|
|
143
|
-
_network[iface].tx_errors = tx_errors;
|
|
144
|
-
_network[iface].ms = Date.now();
|
|
145
|
-
_network[iface].last_ms = 0;
|
|
146
|
-
_network[iface].operstate = operstate;
|
|
147
128
|
}
|
|
129
|
+
_network[iface].last_ms = ms;
|
|
130
|
+
_network[iface].rx_bytes = rx_bytes;
|
|
131
|
+
_network[iface].tx_bytes = tx_bytes;
|
|
132
|
+
_network[iface].rx_packets = rx_packets;
|
|
133
|
+
_network[iface].tx_packets = tx_packets;
|
|
134
|
+
_network[iface].rx_dropped = rx_dropped;
|
|
135
|
+
_network[iface].rx_errors = rx_errors;
|
|
136
|
+
_network[iface].tx_dropped = tx_dropped;
|
|
137
|
+
_network[iface].tx_errors = tx_errors;
|
|
138
|
+
_network[iface].ms = Date.now();
|
|
139
|
+
_network[iface].operstate = operstate;
|
|
148
140
|
return {
|
|
149
141
|
iface,
|
|
150
142
|
operstate,
|
|
151
143
|
rx_bytes,
|
|
144
|
+
rx_packets,
|
|
152
145
|
rx_dropped,
|
|
153
146
|
rx_errors,
|
|
154
147
|
tx_bytes,
|
|
148
|
+
tx_packets,
|
|
155
149
|
tx_dropped,
|
|
156
150
|
tx_errors,
|
|
157
151
|
rx_sec,
|
|
@@ -23,6 +23,7 @@ export declare const stringStartWith: (searchString: string, position?: number)
|
|
|
23
23
|
export declare const mathMin: (...values: number[]) => number;
|
|
24
24
|
export declare const sanitizeShellString: (str: string, strict?: any) => string;
|
|
25
25
|
export declare const isSafePathSegment: (segment: string) => boolean;
|
|
26
|
+
export declare const sanitizeDriveLetter: (str: string) => string;
|
|
26
27
|
export declare const sanitizeContainerID: (str: string) => string;
|
|
27
28
|
export declare const sanitizeImageID: (str: string) => string;
|
|
28
29
|
export declare const isPrototypePolluted: () => boolean;
|
package/dist/common/security.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sanitizeString = exports.sanitizeInterfacesString = exports.sanitizeServiceString = exports.sanitizeUrl = exports.isPrototypePolluted = exports.sanitizeImageID = exports.sanitizeContainerID = exports.isSafePathSegment = exports.sanitizeShellString = exports.mathMin = exports.stringStartWith = exports.stringSplit = exports.stringTrim = exports.stringSubstring = exports.stringSubstr = exports.stringToString = exports.stringToLower = exports.stringReplace = void 0;
|
|
3
|
+
exports.sanitizeString = exports.sanitizeInterfacesString = exports.sanitizeServiceString = exports.sanitizeUrl = exports.isPrototypePolluted = exports.sanitizeImageID = exports.sanitizeContainerID = exports.sanitizeDriveLetter = exports.isSafePathSegment = exports.sanitizeShellString = exports.mathMin = exports.stringStartWith = exports.stringSplit = exports.stringTrim = exports.stringSubstring = exports.stringSubstr = exports.stringToString = exports.stringToLower = exports.stringReplace = void 0;
|
|
4
4
|
exports.stringReplace = new String().replace;
|
|
5
5
|
exports.stringToLower = new String().toLowerCase;
|
|
6
6
|
exports.stringToString = new String().toString;
|
|
@@ -58,6 +58,15 @@ const sanitizeShellString = (str, strict) => {
|
|
|
58
58
|
exports.sanitizeShellString = sanitizeShellString;
|
|
59
59
|
const isSafePathSegment = (segment) => !!segment && segment.indexOf('/') === -1 && segment.indexOf('\0') === -1 && segment !== '.' && segment !== '..';
|
|
60
60
|
exports.isSafePathSegment = isSafePathSegment;
|
|
61
|
+
const sanitizeDriveLetter = (str) => {
|
|
62
|
+
const value = String(str || '');
|
|
63
|
+
if (value.length > 2000) {
|
|
64
|
+
return '';
|
|
65
|
+
}
|
|
66
|
+
const match = /^\s*([a-zA-Z]):?[\\/]?\s*$/.exec(value);
|
|
67
|
+
return match ? `${match[1]}:` : '';
|
|
68
|
+
};
|
|
69
|
+
exports.sanitizeDriveLetter = sanitizeDriveLetter;
|
|
61
70
|
const sanitizeContainerID = (str) => {
|
|
62
71
|
const s = String(str || '')
|
|
63
72
|
.substring(0, 2000)
|
package/dist/common/types.d.ts
CHANGED
|
@@ -464,6 +464,12 @@ export type MemLayoutData = {
|
|
|
464
464
|
voltageMin: number | null;
|
|
465
465
|
voltageMax: number | null;
|
|
466
466
|
};
|
|
467
|
+
export type OsSecurityData = {
|
|
468
|
+
module: string;
|
|
469
|
+
enabled: boolean;
|
|
470
|
+
mode: string;
|
|
471
|
+
policy: string;
|
|
472
|
+
};
|
|
467
473
|
export type OsData = {
|
|
468
474
|
platform: string;
|
|
469
475
|
distro: string;
|
|
@@ -484,6 +490,7 @@ export type OsData = {
|
|
|
484
490
|
displayServer: string;
|
|
485
491
|
awake: boolean;
|
|
486
492
|
hwAcceleration: string[];
|
|
493
|
+
security: OsSecurityData;
|
|
487
494
|
hypervizor?: boolean;
|
|
488
495
|
remoteSession?: boolean;
|
|
489
496
|
hypervisor?: boolean;
|
|
@@ -977,9 +984,11 @@ export type NetworkStatsData = {
|
|
|
977
984
|
iface: string;
|
|
978
985
|
operstate: string;
|
|
979
986
|
rx_bytes: number;
|
|
987
|
+
rx_packets: number;
|
|
980
988
|
rx_dropped: number;
|
|
981
989
|
rx_errors: number;
|
|
982
990
|
tx_bytes: number;
|
|
991
|
+
tx_packets: number;
|
|
983
992
|
tx_dropped: number;
|
|
984
993
|
tx_errors: number;
|
|
985
994
|
rx_sec: number | null;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { NetworkStatsData } from '../common/types';
|
|
1
|
+
import type { NetworkStatsData } from '../common/types';
|
|
2
2
|
export declare const networkStats: (interfaces: string) => Promise<NetworkStatsData[]>;
|
|
@@ -8,7 +8,7 @@ const network_1 = require("../common/network");
|
|
|
8
8
|
const security_1 = require("../common/security");
|
|
9
9
|
const darwin_1 = require("../darwin");
|
|
10
10
|
const EXEC_OPTS = { timeout: 5000 };
|
|
11
|
-
const _network =
|
|
11
|
+
const _network = Object.create(null);
|
|
12
12
|
const networkStatsSingle = async (iface) => {
|
|
13
13
|
await (0, common_1.nextTick)();
|
|
14
14
|
const defaults = { ...defaults_1.initNetworkSpeed, iface };
|
|
@@ -16,6 +16,8 @@ const networkStatsSingle = async (iface) => {
|
|
|
16
16
|
let operstate = 'unknown';
|
|
17
17
|
let rx_bytes = 0;
|
|
18
18
|
let tx_bytes = 0;
|
|
19
|
+
let rx_packets = 0;
|
|
20
|
+
let tx_packets = 0;
|
|
19
21
|
let rx_dropped = 0;
|
|
20
22
|
let rx_errors = 0;
|
|
21
23
|
let tx_dropped = 0;
|
|
@@ -31,12 +33,14 @@ const networkStatsSingle = async (iface) => {
|
|
|
31
33
|
const stats = lines[1].replace(/ +/g, ' ').split(' ');
|
|
32
34
|
const offset = stats.length > 11 ? 1 : 0;
|
|
33
35
|
rx_bytes = (0, common_1.toInt)(stats[offset + 5]);
|
|
36
|
+
rx_packets = (0, common_1.toInt)(stats[offset + 3]);
|
|
34
37
|
rx_dropped = (0, common_1.toInt)(stats[offset + 10]);
|
|
35
38
|
rx_errors = (0, common_1.toInt)(stats[offset + 4]);
|
|
36
39
|
tx_bytes = (0, common_1.toInt)(stats[offset + 8]);
|
|
40
|
+
tx_packets = (0, common_1.toInt)(stats[offset + 6]);
|
|
37
41
|
tx_dropped = (0, common_1.toInt)(stats[offset + 10]);
|
|
38
42
|
tx_errors = (0, common_1.toInt)(stats[offset + 7]);
|
|
39
|
-
return (0, network_1.calcNetworkSpeed)(iface, rx_bytes, tx_bytes, rx_dropped, rx_errors, tx_dropped, tx_errors, operstate, _network);
|
|
43
|
+
return (0, network_1.calcNetworkSpeed)({ iface, rx_bytes, tx_bytes, rx_packets, tx_packets, rx_dropped, rx_errors, tx_dropped, tx_errors, operstate }, _network);
|
|
40
44
|
}
|
|
41
45
|
}
|
|
42
46
|
return defaults;
|
|
@@ -46,6 +50,8 @@ const networkStatsSingle = async (iface) => {
|
|
|
46
50
|
...defaults,
|
|
47
51
|
rx_bytes: _network[iface].rx_bytes,
|
|
48
52
|
tx_bytes: _network[iface].tx_bytes,
|
|
53
|
+
rx_packets: _network[iface].rx_packets,
|
|
54
|
+
tx_packets: _network[iface].tx_packets,
|
|
49
55
|
rx_sec: _network[iface].rx_sec,
|
|
50
56
|
tx_sec: _network[iface].tx_sec,
|
|
51
57
|
rx_dropped: _network[iface].rx_dropped,
|
package/dist/darwin/os-info.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
import type { OsSecurityData } from '../common/types';
|
|
1
2
|
export declare const parseLastUpdate: (stdout: string) => Date | null;
|
|
3
|
+
export declare const parseSip: (stdout: string) => OsSecurityData;
|
|
2
4
|
export declare const osInfo: () => Promise<import("../common/types").OsData>;
|
package/dist/darwin/os-info.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.osInfo = exports.parseLastUpdate = void 0;
|
|
3
|
+
exports.osInfo = exports.parseSip = exports.parseLastUpdate = void 0;
|
|
4
4
|
const common_1 = require("../common");
|
|
5
5
|
const codepage_1 = require("../common/codepage");
|
|
6
6
|
const defaults_1 = require("../common/defaults");
|
|
@@ -110,6 +110,27 @@ const getCodename = (release) => {
|
|
|
110
110
|
}
|
|
111
111
|
return codename;
|
|
112
112
|
};
|
|
113
|
+
const parseSip = (stdout) => {
|
|
114
|
+
const status = (stdout.toString().split(':')[1] || '').trim().toLowerCase();
|
|
115
|
+
if (!status) {
|
|
116
|
+
return { module: '', enabled: false, mode: '', policy: '' };
|
|
117
|
+
}
|
|
118
|
+
if (status.includes('custom')) {
|
|
119
|
+
return { module: 'sip', enabled: false, mode: 'custom', policy: '' };
|
|
120
|
+
}
|
|
121
|
+
const enabled = status.startsWith('enabled');
|
|
122
|
+
return {
|
|
123
|
+
module: 'sip',
|
|
124
|
+
enabled,
|
|
125
|
+
mode: enabled ? 'enforcing' : status.startsWith('disabled') ? 'disabled' : 'custom',
|
|
126
|
+
policy: ''
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
exports.parseSip = parseSip;
|
|
130
|
+
const getSecurity = async () => {
|
|
131
|
+
const { stdout } = await (0, exec_1.execSave)('csrutil status');
|
|
132
|
+
return (0, exports.parseSip)(stdout);
|
|
133
|
+
};
|
|
113
134
|
const osInfo = async () => {
|
|
114
135
|
await (0, common_1.nextTick)();
|
|
115
136
|
const defaults = await (0, defaults_1.initOsInfo)();
|
|
@@ -131,7 +152,8 @@ const osInfo = async () => {
|
|
|
131
152
|
installDate: await getInstallDate(),
|
|
132
153
|
lastUpdate: await getLastUpdate(),
|
|
133
154
|
displayServer: await getDisplayServer(),
|
|
134
|
-
awake: await getAwake()
|
|
155
|
+
awake: await getAwake(),
|
|
156
|
+
security: await getSecurity()
|
|
135
157
|
};
|
|
136
158
|
}
|
|
137
159
|
catch { }
|
|
@@ -43,7 +43,7 @@ const cpuTemperature = async () => {
|
|
|
43
43
|
if (line.startsWith('pch') && temp) {
|
|
44
44
|
result.chipset = Math.round(Number.parseInt(temp, 10) / 100) / 10;
|
|
45
45
|
}
|
|
46
|
-
if (cpuThermal === null && line.indexOf('cpu') !== -1 && temp) {
|
|
46
|
+
if (cpuThermal === null && line.toLowerCase().indexOf('cpu') !== -1 && temp) {
|
|
47
47
|
cpuThermal = Math.round(parseInt(temp, 10) / 100) / 10;
|
|
48
48
|
}
|
|
49
49
|
}
|
package/dist/linux/fs-size.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { FsSizeData } from '../common/types';
|
|
1
|
+
import type { FsSizeData } from '../common/types';
|
|
2
2
|
export declare const fsSize: (drives: string[]) => Promise<FsSizeData[]>;
|
package/dist/linux/fs-size.js
CHANGED
|
@@ -9,7 +9,7 @@ const files_1 = require("../common/files");
|
|
|
9
9
|
const filesys_1 = require("../common/filesys");
|
|
10
10
|
let macOsDisks = [];
|
|
11
11
|
let macOsFsTypes = new Map();
|
|
12
|
-
let osMounts =
|
|
12
|
+
let osMounts = Object.create(null);
|
|
13
13
|
const macOsFsType = (fs) => {
|
|
14
14
|
const type = macOsFsTypes.get(fs);
|
|
15
15
|
if (!type) {
|
|
@@ -67,9 +67,9 @@ const parseNixFsSize = (lines) => {
|
|
|
67
67
|
const fsType = withType ? match[2] : macOsFsType(fs);
|
|
68
68
|
const mount = (withType ? match[6] : match[5]).trim();
|
|
69
69
|
if (fs.startsWith('/') || mount === '/' || fs.indexOf('/') > 0 || fs.indexOf(':') === 1 || (!const_1.DARWIN && !isLinuxTmpFs(fsType))) {
|
|
70
|
-
const size = (0, common_1.toInt)(match[withType ? 3 : 2]) * 1024;
|
|
71
70
|
const used = (0, common_1.toInt)(match[withType ? 4 : 3]) * 1024;
|
|
72
71
|
const available = (0, common_1.toInt)(match[withType ? 5 : 4]) * 1024;
|
|
72
|
+
const size = fsType === 'btrfs' ? used + available : (0, common_1.toInt)(match[withType ? 3 : 2]) * 1024;
|
|
73
73
|
const use = parseFloat((100.0 * (used / (used + available))).toFixed(2));
|
|
74
74
|
const rw = osMounts && Object.keys(osMounts).length > 0 ? osMounts[fs] || false : null;
|
|
75
75
|
if (!data.find((el) => el.fs === fs && el.type === fsType && el.mount === mount)) {
|
|
@@ -143,12 +143,13 @@ const linuxFsSize = async (drives) => {
|
|
|
143
143
|
}
|
|
144
144
|
try {
|
|
145
145
|
const [stats, { dev }] = await Promise.all([(0, promises_1.statfs)(mount), (0, promises_1.stat)(mount)]);
|
|
146
|
-
const
|
|
147
|
-
if (!
|
|
146
|
+
const rawSize = stats.blocks * stats.bsize;
|
|
147
|
+
if (!rawSize) {
|
|
148
148
|
continue;
|
|
149
149
|
}
|
|
150
150
|
const used = (stats.blocks - stats.bfree) * stats.bsize;
|
|
151
151
|
const available = stats.bavail * stats.bsize;
|
|
152
|
+
const size = type === 'btrfs' ? used + available : rawSize;
|
|
152
153
|
const item = {
|
|
153
154
|
dev,
|
|
154
155
|
entry: {
|
|
@@ -219,7 +220,7 @@ const fsSize = async (drives) => {
|
|
|
219
220
|
let lines = [];
|
|
220
221
|
macOsDisks = [];
|
|
221
222
|
macOsFsTypes = new Map();
|
|
222
|
-
osMounts =
|
|
223
|
+
osMounts = Object.create(null);
|
|
223
224
|
if (const_1.DARWIN) {
|
|
224
225
|
cmd = 'df -kP';
|
|
225
226
|
try {
|
package/dist/linux/gpu.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ type DrmMetrics = {
|
|
|
10
10
|
clockCore: number | null;
|
|
11
11
|
};
|
|
12
12
|
export declare const drmDevices: (drmPath?: string) => Promise<DrmMetrics[]>;
|
|
13
|
+
export declare const tegraDevice: (root?: string) => Promise<GpuData | null>;
|
|
13
14
|
export declare const mergeControllerDrm: (controller: GpuData, drm?: DrmMetrics) => GpuData;
|
|
14
15
|
export declare const gpu: () => Promise<GpuData[]>;
|
|
15
16
|
export {};
|
package/dist/linux/gpu.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.gpu = exports.mergeControllerDrm = exports.drmDevices = void 0;
|
|
3
|
+
exports.gpu = exports.mergeControllerDrm = exports.tegraDevice = exports.drmDevices = void 0;
|
|
4
4
|
const promises_1 = require("fs/promises");
|
|
5
5
|
const common_1 = require("../common");
|
|
6
6
|
const const_1 = require("../common/const");
|
|
@@ -77,6 +77,65 @@ const drmDevices = async (drmPath = '/sys/class/drm') => {
|
|
|
77
77
|
return devices;
|
|
78
78
|
};
|
|
79
79
|
exports.drmDevices = drmDevices;
|
|
80
|
+
const readDeviceTree = async (file) => (await (0, files_1.readSysfs)(file)).replace(/\0/g, '\n').trim();
|
|
81
|
+
const tegraClock = async (root) => {
|
|
82
|
+
let nodes = [];
|
|
83
|
+
try {
|
|
84
|
+
nodes = (await (0, promises_1.readdir)(`${root}/sys/class/devfreq`)).filter(security_1.isSafePathSegment);
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
const gpuNodes = nodes.filter((node) => /\.(gpu|gm20b|gp10b|gv11b|ga10b)$/.test(node)).sort();
|
|
90
|
+
return await readSysfsNumber(gpuNodes.map((node) => `${root}/sys/class/devfreq/${node}/cur_freq`), 1000000, true);
|
|
91
|
+
};
|
|
92
|
+
const tegraTemperature = async (root) => {
|
|
93
|
+
let zones = [];
|
|
94
|
+
try {
|
|
95
|
+
zones = (await (0, promises_1.readdir)(`${root}/sys/class/thermal`)).filter((zone) => zone.startsWith('thermal_zone') && (0, security_1.isSafePathSegment)(zone)).sort();
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
for (const zone of zones) {
|
|
101
|
+
if ((await (0, files_1.readSysfs)(`${root}/sys/class/thermal/${zone}/type`)).toLowerCase().startsWith('gpu')) {
|
|
102
|
+
return await readSysfsNumber([`${root}/sys/class/thermal/${zone}/temp`], 1000);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return null;
|
|
106
|
+
};
|
|
107
|
+
const tegraSoc = (compatible) => {
|
|
108
|
+
const match = /nvidia,(tegra\d+)/.exec(compatible);
|
|
109
|
+
return match ? match[1].charAt(0).toUpperCase() + match[1].slice(1) : '';
|
|
110
|
+
};
|
|
111
|
+
const tegraDevice = async (root = '') => {
|
|
112
|
+
const compatible = (await readDeviceTree(`${root}/proc/device-tree/compatible`)).toLowerCase();
|
|
113
|
+
if (!compatible.includes('nvidia,tegra')) {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
const model = (await readDeviceTree(`${root}/proc/device-tree/model`)) || tegraSoc(compatible);
|
|
117
|
+
const load = await readSysfsNumber([`${root}/sys/devices/platform/gpu.0/load`, `${root}/sys/devices/gpu.0/load`]);
|
|
118
|
+
const temperatureGpu = await tegraTemperature(root);
|
|
119
|
+
const clockCore = await tegraClock(root);
|
|
120
|
+
const result = {
|
|
121
|
+
vendor: 'NVIDIA',
|
|
122
|
+
model: model || 'Tegra',
|
|
123
|
+
bus: '',
|
|
124
|
+
vram: null,
|
|
125
|
+
vramDynamic: true
|
|
126
|
+
};
|
|
127
|
+
if (load !== null) {
|
|
128
|
+
result.utilizationGpu = Math.min(100, Math.round(load) / 10);
|
|
129
|
+
}
|
|
130
|
+
if (temperatureGpu !== null) {
|
|
131
|
+
result.temperatureGpu = temperatureGpu;
|
|
132
|
+
}
|
|
133
|
+
if (clockCore !== null) {
|
|
134
|
+
result.clockCore = clockCore;
|
|
135
|
+
}
|
|
136
|
+
return result;
|
|
137
|
+
};
|
|
138
|
+
exports.tegraDevice = tegraDevice;
|
|
80
139
|
const mergeControllerDrm = (controller, drm) => {
|
|
81
140
|
if (!drm) {
|
|
82
141
|
return controller;
|
|
@@ -376,6 +435,12 @@ const gpu = async () => {
|
|
|
376
435
|
catch { }
|
|
377
436
|
}
|
|
378
437
|
catch { }
|
|
438
|
+
if (!result.length) {
|
|
439
|
+
const tegra = await (0, exports.tegraDevice)();
|
|
440
|
+
if (tegra) {
|
|
441
|
+
result.push(tegra);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
379
444
|
}
|
|
380
445
|
catch { }
|
|
381
446
|
return result;
|
package/dist/linux/mem-layout.js
CHANGED
|
@@ -31,11 +31,7 @@ const memLayout = async () => {
|
|
|
31
31
|
channel: null,
|
|
32
32
|
type: (0, common_1.getValue)(lines, 'Type:'),
|
|
33
33
|
ecc: dataWidth && totalWidth ? totalWidth > dataWidth : false,
|
|
34
|
-
clockSpeed: (0, common_1.getValue)(lines, 'Configured Clock Speed:')
|
|
35
|
-
? parseInt((0, common_1.getValue)(lines, 'Configured Clock Speed:'), 10)
|
|
36
|
-
: (0, common_1.getValue)(lines, 'Speed:')
|
|
37
|
-
? parseInt((0, common_1.getValue)(lines, 'Speed:'), 10)
|
|
38
|
-
: null,
|
|
34
|
+
clockSpeed: (0, common_1.toInt)((0, common_1.getValue)(lines, 'Configured Memory Speed:')) || (0, common_1.toInt)((0, common_1.getValue)(lines, 'Configured Clock Speed:')) || (0, common_1.toInt)((0, common_1.getValue)(lines, 'Speed:')) || null,
|
|
39
35
|
formFactor: (0, common_1.getValue)(lines, 'Form Factor:'),
|
|
40
36
|
manufacturer: (0, mappings_1.getMemManufacturer)((0, common_1.getValue)(lines, 'Manufacturer:')),
|
|
41
37
|
partNum: (0, common_1.getValue)(lines, 'Part Number:'),
|
package/dist/linux/mem.d.ts
CHANGED
package/dist/linux/mem.js
CHANGED
|
@@ -1,10 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mem = void 0;
|
|
3
|
+
exports.mem = exports.parseArcstats = void 0;
|
|
4
4
|
const promises_1 = require("node:fs/promises");
|
|
5
5
|
const node_os_1 = require("node:os");
|
|
6
6
|
const common_1 = require("../common");
|
|
7
7
|
const defaults_1 = require("../common/defaults");
|
|
8
|
+
const files_1 = require("../common/files");
|
|
9
|
+
const parseArcstats = (lines) => {
|
|
10
|
+
let size = 0;
|
|
11
|
+
let cMin = 0;
|
|
12
|
+
for (const line of lines) {
|
|
13
|
+
const parts = line.trim().split(/\s+/);
|
|
14
|
+
if (parts.length < 3) {
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
if (parts[0] === 'size') {
|
|
18
|
+
size = (0, common_1.toInt)(parts[2]);
|
|
19
|
+
}
|
|
20
|
+
else if (parts[0] === 'c_min') {
|
|
21
|
+
cMin = (0, common_1.toInt)(parts[2]);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return Math.max(size - cMin, 0);
|
|
25
|
+
};
|
|
26
|
+
exports.parseArcstats = parseArcstats;
|
|
8
27
|
const mem = async () => {
|
|
9
28
|
await (0, common_1.nextTick)();
|
|
10
29
|
const defaults = (0, common_1.cloneObj)(defaults_1.initMemData);
|
|
@@ -25,6 +44,7 @@ const mem = async () => {
|
|
|
25
44
|
const buffcache = buffers + cached + slab;
|
|
26
45
|
let available = (0, common_1.toInt)((0, common_1.getValue)(lines, 'memavailable'));
|
|
27
46
|
available = available ? available * 1024 : free + buffcache;
|
|
47
|
+
available = Math.min(total, available + (0, exports.parseArcstats)(await (0, files_1.readFileLines)('/proc/spl/kstat/zfs/arcstats')));
|
|
28
48
|
const active = total - available;
|
|
29
49
|
let swaptotal = (0, common_1.toInt)((0, common_1.getValue)(lines, 'swaptotal'));
|
|
30
50
|
swaptotal = swaptotal ? swaptotal * 1024 : 0;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { NetworkStatsData } from '../common/types';
|
|
1
|
+
import type { NetworkStatsData } from '../common/types';
|
|
2
2
|
export declare const networkStats: (interfaces?: string) => Promise<NetworkStatsData[]>;
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.networkStats = void 0;
|
|
4
|
-
const files_1 = require("../common/files");
|
|
5
4
|
const common_1 = require("../common");
|
|
6
|
-
const security_1 = require("../common/security");
|
|
7
5
|
const defaults_1 = require("../common/defaults");
|
|
8
|
-
const
|
|
6
|
+
const files_1 = require("../common/files");
|
|
9
7
|
const network_1 = require("../common/network");
|
|
10
|
-
const
|
|
8
|
+
const security_1 = require("../common/security");
|
|
9
|
+
const index_1 = require("./index");
|
|
10
|
+
const _network = Object.create(null);
|
|
11
11
|
const networkStatsSingle = async (iface) => {
|
|
12
12
|
await (0, common_1.nextTick)();
|
|
13
13
|
const defaults = { ...defaults_1.initNetworkSpeed, iface };
|
|
14
14
|
if (!_network[iface] || (_network[iface] && !_network[iface].ms) || (_network[iface] && _network[iface].ms && Date.now() - _network[iface].ms >= 500)) {
|
|
15
15
|
const dir = '/sys/class/net/' + iface;
|
|
16
16
|
if ((0, security_1.isSafePathSegment)(iface) && (await (0, files_1.fileExists)(dir))) {
|
|
17
|
-
const [operstate, rx_bytes, tx_bytes, rx_dropped, rx_errors, tx_dropped, tx_errors] = await Promise.all([
|
|
17
|
+
const [operstate, rx_bytes, tx_bytes, rx_packets, tx_packets, rx_dropped, rx_errors, tx_dropped, tx_errors] = await Promise.all([
|
|
18
18
|
(0, files_1.readSysfs)(dir + '/operstate'),
|
|
19
|
-
...['rx_bytes', 'tx_bytes', 'rx_dropped', 'rx_errors', 'tx_dropped', 'tx_errors'].map(async (f) => (0, common_1.toInt)(await (0, files_1.readSysfs)(dir + '/statistics/' + f)))
|
|
19
|
+
...['rx_bytes', 'tx_bytes', 'rx_packets', 'tx_packets', 'rx_dropped', 'rx_errors', 'tx_dropped', 'tx_errors'].map(async (f) => (0, common_1.toInt)(await (0, files_1.readSysfs)(dir + '/statistics/' + f)))
|
|
20
20
|
]);
|
|
21
|
-
return (0, network_1.calcNetworkSpeed)(iface, rx_bytes, tx_bytes, rx_dropped, rx_errors, tx_dropped, tx_errors, operstate, _network);
|
|
21
|
+
return (0, network_1.calcNetworkSpeed)({ iface, rx_bytes, tx_bytes, rx_packets, tx_packets, rx_dropped, rx_errors, tx_dropped, tx_errors, operstate }, _network);
|
|
22
22
|
}
|
|
23
23
|
return defaults;
|
|
24
24
|
}
|
|
@@ -27,6 +27,8 @@ const networkStatsSingle = async (iface) => {
|
|
|
27
27
|
...defaults,
|
|
28
28
|
rx_bytes: _network[iface].rx_bytes,
|
|
29
29
|
tx_bytes: _network[iface].tx_bytes,
|
|
30
|
+
rx_packets: _network[iface].rx_packets,
|
|
31
|
+
tx_packets: _network[iface].tx_packets,
|
|
30
32
|
rx_sec: _network[iface].rx_sec,
|
|
31
33
|
tx_sec: _network[iface].tx_sec,
|
|
32
34
|
rx_dropped: _network[iface].rx_dropped,
|
package/dist/linux/os-info.js
CHANGED
|
@@ -69,6 +69,41 @@ const linuxIsUefi = async () => {
|
|
|
69
69
|
return stdout.split('\n').length > 0 && stdout.indexOf('EFI') >= 0;
|
|
70
70
|
}
|
|
71
71
|
};
|
|
72
|
+
const getSecurity = async () => {
|
|
73
|
+
const enforce = await (0, files_1.readSysfs)('/sys/fs/selinux/enforce');
|
|
74
|
+
if (enforce === '0' || enforce === '1') {
|
|
75
|
+
const config = await (0, files_1.readFileLines)('/etc/selinux/config');
|
|
76
|
+
const policy = config.find((line) => line.trim().startsWith('SELINUXTYPE='));
|
|
77
|
+
return {
|
|
78
|
+
module: 'selinux',
|
|
79
|
+
enabled: true,
|
|
80
|
+
mode: enforce === '1' ? 'enforcing' : 'permissive',
|
|
81
|
+
policy: policy ? policy.split('=')[1].trim() : ''
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
const apparmor = await (0, files_1.readSysfs)('/sys/module/apparmor/parameters/enabled');
|
|
85
|
+
if (apparmor) {
|
|
86
|
+
const enabled = apparmor.toUpperCase() === 'Y';
|
|
87
|
+
const mode = await (0, files_1.readSysfs)('/sys/module/apparmor/parameters/mode');
|
|
88
|
+
return {
|
|
89
|
+
module: 'apparmor',
|
|
90
|
+
enabled,
|
|
91
|
+
mode: enabled ? mode || 'enforce' : 'disabled',
|
|
92
|
+
policy: ''
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
const config = await (0, files_1.readFileLines)('/etc/selinux/config');
|
|
96
|
+
const configured = config.find((line) => line.trim().startsWith('SELINUX='));
|
|
97
|
+
if (configured) {
|
|
98
|
+
return {
|
|
99
|
+
module: 'selinux',
|
|
100
|
+
enabled: false,
|
|
101
|
+
mode: 'disabled',
|
|
102
|
+
policy: ''
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
return { module: '', enabled: false, mode: '', policy: '' };
|
|
106
|
+
};
|
|
72
107
|
const parseOsInfo = async (stdout, defaults) => {
|
|
73
108
|
const release = {};
|
|
74
109
|
const lines = stdout.toString().split('\n');
|
|
@@ -100,7 +135,8 @@ const parseOsInfo = async (stdout, defaults) => {
|
|
|
100
135
|
serial: (await (0, uuid_1.uuid)()).os,
|
|
101
136
|
installDate: await getInstallDate(),
|
|
102
137
|
lastUpdate: await getLastUpdate(),
|
|
103
|
-
displayServer: await getDisplayServer()
|
|
138
|
+
displayServer: await getDisplayServer(),
|
|
139
|
+
security: await getSecurity()
|
|
104
140
|
};
|
|
105
141
|
};
|
|
106
142
|
const osInfo = async () => {
|
package/dist/windows/fs-size.js
CHANGED
|
@@ -33,10 +33,7 @@ const fsSize = async (drives) => {
|
|
|
33
33
|
await (0, common_1.nextTick)();
|
|
34
34
|
let data = [];
|
|
35
35
|
try {
|
|
36
|
-
const conditions = drives
|
|
37
|
-
.map((drive) => (drive ? (0, security_1.sanitizeShellString)(drive, true) : ''))
|
|
38
|
-
.filter((drive) => drive !== '')
|
|
39
|
-
.map((drive) => `$_.Caption -eq '${drive}'`);
|
|
36
|
+
const conditions = drives.filter((drive) => !!drive).map((drive) => `$_.Caption -eq '${(0, security_1.sanitizeDriveLetter)(drive)}'`);
|
|
40
37
|
const filter = conditions.length ? ` | where { ${conditions.join(' -or ')} }` : '';
|
|
41
38
|
const stdout = await windows_1.ps.exec(`Get-CimInstance Win32_logicaldisk | select Access,Caption,FileSystem,FreeSpace,Size${filter} | fl`);
|
|
42
39
|
data = parseFsSize(String(stdout));
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.networkStats = void 0;
|
|
4
|
-
const index_1 = require("./index");
|
|
5
4
|
const common_1 = require("../common");
|
|
6
5
|
const defaults_1 = require("../common/defaults");
|
|
7
6
|
const network_1 = require("../common/network");
|
|
8
7
|
const security_1 = require("../common/security");
|
|
9
8
|
const windows_1 = require("../common/windows");
|
|
10
|
-
const
|
|
9
|
+
const index_1 = require("./index");
|
|
10
|
+
const _network = Object.create(null);
|
|
11
11
|
const parseLinesWindowsPerfData = (sections) => {
|
|
12
12
|
const perfData = [];
|
|
13
13
|
for (const i in sections) {
|
|
@@ -20,9 +20,11 @@ const parseLinesWindowsPerfData = (sections) => {
|
|
|
20
20
|
.replace(/#|\//g, '_')
|
|
21
21
|
.toLowerCase(),
|
|
22
22
|
rx_bytes: (0, common_1.toInt)((0, common_1.getValue)(lines, 'ReceivedBytes', ':')),
|
|
23
|
+
rx_packets: (0, common_1.toInt)((0, common_1.getValue)(lines, 'ReceivedUnicastPackets', ':')) + (0, common_1.toInt)((0, common_1.getValue)(lines, 'ReceivedMulticastPackets', ':')) + (0, common_1.toInt)((0, common_1.getValue)(lines, 'ReceivedBroadcastPackets', ':')),
|
|
23
24
|
rx_errors: (0, common_1.toInt)((0, common_1.getValue)(lines, 'ReceivedPacketErrors', ':')),
|
|
24
25
|
rx_dropped: (0, common_1.toInt)((0, common_1.getValue)(lines, 'ReceivedDiscardedPackets', ':')),
|
|
25
26
|
tx_bytes: (0, common_1.toInt)((0, common_1.getValue)(lines, 'SentBytes', ':')),
|
|
27
|
+
tx_packets: (0, common_1.toInt)((0, common_1.getValue)(lines, 'SentUnicastPackets', ':')) + (0, common_1.toInt)((0, common_1.getValue)(lines, 'SentMulticastPackets', ':')) + (0, common_1.toInt)((0, common_1.getValue)(lines, 'SentBroadcastPackets', ':')),
|
|
26
28
|
tx_errors: (0, common_1.toInt)((0, common_1.getValue)(lines, 'OutboundPacketErrors', ':')),
|
|
27
29
|
tx_dropped: (0, common_1.toInt)((0, common_1.getValue)(lines, 'OutboundDiscardedPackets', ':'))
|
|
28
30
|
});
|
|
@@ -37,6 +39,8 @@ const networkStatsSingle = async (iface) => {
|
|
|
37
39
|
let operstate = 'unknown';
|
|
38
40
|
let rx_bytes = 0;
|
|
39
41
|
let tx_bytes = 0;
|
|
42
|
+
let rx_packets = 0;
|
|
43
|
+
let tx_packets = 0;
|
|
40
44
|
let rx_dropped = 0;
|
|
41
45
|
let rx_errors = 0;
|
|
42
46
|
let tx_dropped = 0;
|
|
@@ -45,7 +49,7 @@ const networkStatsSingle = async (iface) => {
|
|
|
45
49
|
let ifaceName = iface;
|
|
46
50
|
let found = false;
|
|
47
51
|
try {
|
|
48
|
-
const stdout = String((await windows_1.ps.exec('Get-NetAdapterStatistics | select Name,InterfaceDescription,ReceivedBytes,ReceivedPacketErrors,ReceivedDiscardedPackets,SentBytes,OutboundPacketErrors,OutboundDiscardedPackets | fl')) || '');
|
|
52
|
+
const stdout = String((await windows_1.ps.exec('Get-NetAdapterStatistics | select Name,InterfaceDescription,ReceivedBytes,ReceivedUnicastPackets,ReceivedMulticastPackets,ReceivedBroadcastPackets,ReceivedPacketErrors,ReceivedDiscardedPackets,SentBytes,SentUnicastPackets,SentMulticastPackets,SentBroadcastPackets,OutboundPacketErrors,OutboundDiscardedPackets | fl')) || '');
|
|
49
53
|
if (stdout) {
|
|
50
54
|
const psections = stdout.split(/\n\s*\n/);
|
|
51
55
|
perfData = parseLinesWindowsPerfData(psections);
|
|
@@ -77,9 +81,11 @@ const networkStatsSingle = async (iface) => {
|
|
|
77
81
|
found = true;
|
|
78
82
|
ifaceName = det.iface;
|
|
79
83
|
rx_bytes = detail.rx_bytes;
|
|
84
|
+
rx_packets = detail.rx_packets;
|
|
80
85
|
rx_dropped = detail.rx_dropped;
|
|
81
86
|
rx_errors = detail.rx_errors;
|
|
82
87
|
tx_bytes = detail.tx_bytes;
|
|
88
|
+
tx_packets = detail.tx_packets;
|
|
83
89
|
tx_dropped = detail.tx_dropped;
|
|
84
90
|
tx_errors = detail.tx_errors;
|
|
85
91
|
operstate = det.operstate;
|
|
@@ -87,7 +93,11 @@ const networkStatsSingle = async (iface) => {
|
|
|
87
93
|
});
|
|
88
94
|
});
|
|
89
95
|
if (found) {
|
|
90
|
-
|
|
96
|
+
const stats = (0, network_1.calcNetworkSpeed)({ iface: ifaceName, rx_bytes, tx_bytes, rx_packets, tx_packets, rx_dropped, rx_errors, tx_dropped, tx_errors, operstate }, _network);
|
|
97
|
+
if (ifaceName !== iface) {
|
|
98
|
+
_network[iface] = _network[ifaceName];
|
|
99
|
+
}
|
|
100
|
+
return stats;
|
|
91
101
|
}
|
|
92
102
|
return defaults;
|
|
93
103
|
}
|
|
@@ -96,6 +106,8 @@ const networkStatsSingle = async (iface) => {
|
|
|
96
106
|
...defaults,
|
|
97
107
|
rx_bytes: _network[iface].rx_bytes,
|
|
98
108
|
tx_bytes: _network[iface].tx_bytes,
|
|
109
|
+
rx_packets: _network[iface].rx_packets,
|
|
110
|
+
tx_packets: _network[iface].tx_packets,
|
|
99
111
|
rx_sec: _network[iface].rx_sec,
|
|
100
112
|
tx_sec: _network[iface].tx_sec,
|
|
101
113
|
rx_dropped: _network[iface].rx_dropped,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "systeminformation",
|
|
3
|
-
"version": "6.0.0-beta.
|
|
3
|
+
"version": "6.0.0-beta.15",
|
|
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)",
|