systeminformation 6.0.0-beta.2 → 6.0.0-beta.21
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 +67 -18
- package/dist/bsd/mem.js +8 -3
- package/dist/bsd/network-stats.d.ts +1 -1
- package/dist/bsd/network-stats.js +14 -7
- package/dist/bsd/os-info.d.ts +1 -0
- package/dist/common/darwin.d.ts +2 -0
- package/dist/common/darwin.js +17 -1
- package/dist/common/defaults.d.ts +2 -1
- package/dist/common/defaults.js +36 -6
- package/dist/common/exec.js +29 -13
- package/dist/common/files.d.ts +9 -0
- package/dist/common/files.js +67 -3
- package/dist/common/filesys.d.ts +30 -0
- package/dist/common/filesys.js +228 -11
- package/dist/common/host.js +55 -3
- package/dist/common/internet.js +31 -20
- package/dist/common/mappings.d.ts +0 -3
- package/dist/common/mappings.js +35 -14
- package/dist/common/network.d.ts +15 -2
- package/dist/common/network.js +18 -22
- package/dist/common/nvidia.d.ts +1 -1
- package/dist/common/nvidia.js +4 -5
- package/dist/common/parse.d.ts +4 -6
- package/dist/common/parse.js +24 -69
- package/dist/common/security.d.ts +2 -0
- package/dist/common/security.js +18 -3
- package/dist/common/types.d.ts +53 -5
- 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 +54 -8
- package/dist/cpu-current-speed.js +5 -3
- package/dist/darwin/battery.d.ts +1 -1
- package/dist/darwin/battery.js +15 -5
- package/dist/darwin/camera.js +3 -3
- package/dist/darwin/disk-layout.js +16 -12
- package/dist/darwin/disks-io.js +3 -3
- package/dist/darwin/displays.d.ts +1 -0
- package/dist/darwin/displays.js +64 -2
- package/dist/darwin/fans.d.ts +2 -0
- package/dist/darwin/fans.js +28 -0
- package/dist/darwin/gpu.js +1 -1
- package/dist/darwin/index.d.ts +3 -0
- package/dist/darwin/index.js +8 -2
- package/dist/darwin/keyboard.js +4 -4
- package/dist/darwin/mouse.js +4 -4
- package/dist/darwin/network-interfaces.d.ts +3 -0
- package/dist/darwin/network-interfaces.js +81 -14
- package/dist/darwin/network-stats.d.ts +1 -1
- package/dist/darwin/network-stats.js +14 -7
- package/dist/darwin/os-info.d.ts +2 -0
- package/dist/darwin/os-info.js +24 -2
- package/dist/darwin/process-focused.d.ts +3 -0
- package/dist/darwin/process-focused.js +26 -0
- package/dist/darwin/serial-ports.d.ts +2 -0
- package/dist/darwin/serial-ports.js +94 -0
- package/dist/darwin/users.js +1 -1
- package/dist/docker.js +4 -5
- package/dist/fans.d.ts +1 -0
- package/dist/fans.js +17 -0
- package/dist/get-data.d.ts +4 -0
- package/dist/get-data.js +6 -2
- package/dist/get.js +6 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +8 -2
- package/dist/inet-public-ip.js +2 -1
- package/dist/linux/audio.js +59 -0
- package/dist/linux/baseboard.js +9 -20
- package/dist/linux/bios.js +6 -15
- package/dist/linux/block-devices.js +3 -1
- package/dist/linux/camera.js +2 -1
- package/dist/linux/chassis.js +4 -10
- package/dist/linux/cpu-temperature.js +34 -19
- package/dist/linux/cpu.js +3 -1
- package/dist/linux/disk-layout.js +9 -12
- package/dist/linux/disks-io.js +9 -9
- package/dist/linux/displays.d.ts +8 -0
- package/dist/linux/displays.js +151 -4
- package/dist/linux/fans.d.ts +2 -0
- package/dist/linux/fans.js +92 -0
- package/dist/linux/fs-size.d.ts +1 -1
- package/dist/linux/fs-size.js +164 -37
- package/dist/linux/fs-stats.js +6 -9
- package/dist/linux/gpu.d.ts +2 -0
- package/dist/linux/gpu.js +97 -22
- package/dist/linux/index.d.ts +3 -0
- package/dist/linux/index.js +8 -2
- package/dist/linux/mem-layout.js +3 -7
- package/dist/linux/mem.d.ts +1 -0
- package/dist/linux/mem.js +21 -1
- package/dist/linux/network-interfaces.d.ts +1 -0
- package/dist/linux/network-interfaces.js +154 -113
- package/dist/linux/network-stats.d.ts +1 -1
- package/dist/linux/network-stats.js +14 -40
- package/dist/linux/npu.js +2 -1
- package/dist/linux/os-info.js +56 -5
- package/dist/linux/printer.js +4 -4
- package/dist/linux/process-focused.d.ts +4 -0
- package/dist/linux/process-focused.js +32 -0
- package/dist/linux/process-load.js +11 -13
- package/dist/linux/processes.js +89 -80
- package/dist/linux/serial-ports.d.ts +2 -0
- package/dist/linux/serial-ports.js +102 -0
- package/dist/linux/services.js +182 -49
- package/dist/linux/system.js +1 -7
- package/dist/linux/users.js +1 -1
- package/dist/linux/uuid.js +4 -10
- package/dist/linux/wifi-networks.js +2 -2
- package/dist/network-interfaces.js +1 -1
- package/dist/observe.d.ts +1 -1
- package/dist/observe.js +5 -1
- package/dist/process-focused.d.ts +1 -0
- package/dist/process-focused.js +17 -0
- package/dist/serial-ports.d.ts +1 -0
- package/dist/serial-ports.js +17 -0
- package/dist/versions.js +34 -80
- package/dist/windows/audio.d.ts +29 -0
- package/dist/windows/audio.js +151 -11
- package/dist/windows/disk-layout.js +3 -0
- package/dist/windows/disks-io.js +3 -3
- package/dist/windows/displays.d.ts +5 -0
- package/dist/windows/displays.js +101 -16
- package/dist/windows/fans.d.ts +2 -0
- package/dist/windows/fans.js +71 -0
- package/dist/windows/fs-size.js +1 -4
- package/dist/windows/gpu.js +3 -2
- package/dist/windows/index.d.ts +3 -0
- package/dist/windows/index.js +8 -2
- package/dist/windows/network-interfaces.js +36 -41
- package/dist/windows/network-stats.js +20 -6
- package/dist/windows/process-focused.d.ts +3 -0
- package/dist/windows/process-focused.js +36 -0
- package/dist/windows/process-load.js +7 -5
- package/dist/windows/processes.d.ts +1 -0
- package/dist/windows/processes.js +54 -26
- package/dist/windows/serial-ports.d.ts +3 -0
- package/dist/windows/serial-ports.js +73 -0
- package/dist/windows/services.js +4 -1
- package/package.json +1 -1
package/dist/common/files.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fileExists = exports.getFilesInPath = void 0;
|
|
3
|
+
exports.DMI_PATH = exports.readFileMax = exports.readProcStats = exports.readSysfsMany = exports.readFileLines = exports.readSysfs = exports.fileExists = exports.getFilesInPath = void 0;
|
|
4
4
|
const fs_1 = require("fs");
|
|
5
5
|
const promises_1 = require("fs/promises");
|
|
6
6
|
const path_1 = require("path");
|
|
7
|
+
const security_1 = require("./security");
|
|
7
8
|
const getFilesInPath = async (source) => {
|
|
8
9
|
const fetchedFiles = [];
|
|
9
10
|
try {
|
|
10
|
-
const files = await (0, promises_1.readdir)(source);
|
|
11
|
+
const files = (await (0, promises_1.readdir)(source)).filter(security_1.isSafePathSegment);
|
|
11
12
|
for (const file of files) {
|
|
12
13
|
try {
|
|
13
14
|
const filepath = (0, path_1.join)(source, file);
|
|
@@ -17,7 +18,7 @@ const getFilesInPath = async (source) => {
|
|
|
17
18
|
}
|
|
18
19
|
if (stats.isDirectory()) {
|
|
19
20
|
const childFiles = await (0, promises_1.readdir)(filepath);
|
|
20
|
-
files.push(...childFiles.map((f) => (0, path_1.join)(file, f)));
|
|
21
|
+
files.push(...childFiles.filter(security_1.isSafePathSegment).map((f) => (0, path_1.join)(file, f)));
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
catch { }
|
|
@@ -37,3 +38,66 @@ const fileExists = async (file) => {
|
|
|
37
38
|
}
|
|
38
39
|
};
|
|
39
40
|
exports.fileExists = fileExists;
|
|
41
|
+
const readSysfs = async (file) => {
|
|
42
|
+
try {
|
|
43
|
+
return (await (0, promises_1.readFile)(file, 'utf8')).trim();
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return '';
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
exports.readSysfs = readSysfs;
|
|
50
|
+
const readFileLines = async (file) => {
|
|
51
|
+
try {
|
|
52
|
+
return (await (0, promises_1.readFile)(file, 'utf8')).split('\n');
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return [];
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
exports.readFileLines = readFileLines;
|
|
59
|
+
const readSysfsMany = async (dir, names) => {
|
|
60
|
+
return Promise.all(names.map(async (name) => `${name}: ${await (0, exports.readSysfs)((0, path_1.join)(dir, name))}`));
|
|
61
|
+
};
|
|
62
|
+
exports.readSysfsMany = readSysfsMany;
|
|
63
|
+
const PROC_READ_BATCH = 64;
|
|
64
|
+
const readProcStats = async (pids) => {
|
|
65
|
+
const paths = [];
|
|
66
|
+
for (const pid of pids) {
|
|
67
|
+
const id = String(pid);
|
|
68
|
+
if (/^\d+$/.test(id)) {
|
|
69
|
+
paths.push(`/proc/${id}/stat`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const statLines = await (0, exports.readFileLines)('/proc/stat');
|
|
73
|
+
const procs = [];
|
|
74
|
+
for (let i = 0; i < paths.length; i += PROC_READ_BATCH) {
|
|
75
|
+
procs.push(...(await Promise.all(paths.slice(i, i + PROC_READ_BATCH).map((path) => (0, exports.readSysfs)(path)))));
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
all: statLines.find((line) => line.startsWith('cpu ')) || '',
|
|
79
|
+
procs: procs.filter((line) => line)
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
exports.readProcStats = readProcStats;
|
|
83
|
+
const readFileMax = async (file, maxBytes = 1024 * 1024) => {
|
|
84
|
+
let handle;
|
|
85
|
+
try {
|
|
86
|
+
handle = await (0, promises_1.open)(file, 'r');
|
|
87
|
+
const { size } = await handle.stat();
|
|
88
|
+
const buffer = Buffer.alloc(Math.min(size || maxBytes, maxBytes));
|
|
89
|
+
const { bytesRead } = await handle.read(buffer, 0, buffer.length, 0);
|
|
90
|
+
return buffer.toString('utf8', 0, bytesRead).trim();
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
return '';
|
|
94
|
+
}
|
|
95
|
+
finally {
|
|
96
|
+
try {
|
|
97
|
+
await handle?.close();
|
|
98
|
+
}
|
|
99
|
+
catch { }
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
exports.readFileMax = readFileMax;
|
|
103
|
+
exports.DMI_PATH = '/sys/devices/virtual/dmi/id';
|
package/dist/common/filesys.d.ts
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
import type { FsBlockDevicesData } from './types';
|
|
2
|
+
export declare const zfsDatasets: () => Promise<{
|
|
3
|
+
byMount: Map<string, {
|
|
4
|
+
used: number;
|
|
5
|
+
available: number;
|
|
6
|
+
}>;
|
|
7
|
+
byName: Map<string, {
|
|
8
|
+
used: number;
|
|
9
|
+
available: number;
|
|
10
|
+
}>;
|
|
11
|
+
}>;
|
|
2
12
|
export declare const smartMonToolsInstalled: () => Promise<boolean>;
|
|
3
13
|
export declare const _fs_speed: any;
|
|
4
14
|
export declare const calcFsSpeed: (rx: number, wx: number) => any;
|
|
@@ -9,3 +19,23 @@ export declare const parseLinuxBlk: (lines: string[]) => FsBlockDevicesData[];
|
|
|
9
19
|
export declare const raidMatchLinux: (data: FsBlockDevicesData[]) => Promise<FsBlockDevicesData[]>;
|
|
10
20
|
export declare const matchDevicesLinux: (data: FsBlockDevicesData[]) => FsBlockDevicesData[];
|
|
11
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 btrfsUsableSize: (profile: string, sizes: number[]) => number;
|
|
38
|
+
export declare const applyPoolsLinux: (data: FsBlockDevicesData[], pools: PoolInfoLinux[]) => FsBlockDevicesData[];
|
|
39
|
+
export declare const parseZfsMountpoints: (content: string) => Map<string, string>;
|
|
40
|
+
export declare const zfsPoolsLinux: (data: FsBlockDevicesData[]) => Promise<PoolInfoLinux[]>;
|
|
41
|
+
export declare const btrfsPoolsLinux: (data: FsBlockDevicesData[]) => Promise<PoolInfoLinux[]>;
|
package/dist/common/filesys.js
CHANGED
|
@@ -1,11 +1,38 @@
|
|
|
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 = 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
|
+
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;
|
|
11
|
+
const zfsDatasets = async () => {
|
|
12
|
+
const byMount = new Map();
|
|
13
|
+
const byName = new Map();
|
|
14
|
+
let stdout = '';
|
|
15
|
+
try {
|
|
16
|
+
({ stdout } = await (0, exec_1.exec)('zfs list -H -p -o name,used,avail,mountpoint', { ...const_1.execOptsLinux, timeout: 5000 }));
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return { byMount, byName };
|
|
20
|
+
}
|
|
21
|
+
for (const line of stdout.toString().split('\n')) {
|
|
22
|
+
const parts = line.split('\t');
|
|
23
|
+
if (parts.length < 4) {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
const entry = { used: (0, index_1.toInt)(parts[1]), available: (0, index_1.toInt)(parts[2]) };
|
|
27
|
+
const mount = parts[3].trim();
|
|
28
|
+
byName.set(parts[0], entry);
|
|
29
|
+
if (mount.startsWith('/') && !byMount.has(mount)) {
|
|
30
|
+
byMount.set(mount, entry);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return { byMount, byName };
|
|
34
|
+
};
|
|
35
|
+
exports.zfsDatasets = zfsDatasets;
|
|
9
36
|
const smartMonToolsInstalled = async () => {
|
|
10
37
|
if (_smartMonToolsInstalled !== null) {
|
|
11
38
|
return _smartMonToolsInstalled;
|
|
@@ -84,12 +111,12 @@ const calcDiskIO = (rIO, wIO, rWaitTime, wWaitTime, tWaitTime) => {
|
|
|
84
111
|
result.rIO_sec = (result.rIO - exports._disk_io.rIO) / (result.ms / 1000);
|
|
85
112
|
result.wIO_sec = (result.wIO - exports._disk_io.wIO) / (result.ms / 1000);
|
|
86
113
|
result.tIO_sec = result.rIO_sec + result.wIO_sec;
|
|
87
|
-
result.rWaitTime = rWaitTime;
|
|
88
|
-
result.wWaitTime = wWaitTime;
|
|
89
|
-
result.tWaitTime = tWaitTime;
|
|
90
|
-
result.rWaitPercent = (
|
|
91
|
-
result.wWaitPercent = (
|
|
92
|
-
result.tWaitPercent = (
|
|
114
|
+
result.rWaitTime = rWaitTime - exports._disk_io.rWaitTime;
|
|
115
|
+
result.wWaitTime = wWaitTime - exports._disk_io.wWaitTime;
|
|
116
|
+
result.tWaitTime = tWaitTime - exports._disk_io.tWaitTime;
|
|
117
|
+
result.rWaitPercent = (result.rWaitTime * 100) / result.ms;
|
|
118
|
+
result.wWaitPercent = (result.wWaitTime * 100) / result.ms;
|
|
119
|
+
result.tWaitPercent = (result.tWaitTime * 100) / result.ms;
|
|
93
120
|
exports._disk_io.rIO = rIO;
|
|
94
121
|
exports._disk_io.wIO = wIO;
|
|
95
122
|
exports._disk_io.rIO_sec = result.rIO_sec;
|
|
@@ -98,6 +125,9 @@ const calcDiskIO = (rIO, wIO, rWaitTime, wWaitTime, tWaitTime) => {
|
|
|
98
125
|
exports._disk_io.rWaitTime = rWaitTime;
|
|
99
126
|
exports._disk_io.wWaitTime = wWaitTime;
|
|
100
127
|
exports._disk_io.tWaitTime = tWaitTime;
|
|
128
|
+
exports._disk_io.rWaitTimeDelta = result.rWaitTime;
|
|
129
|
+
exports._disk_io.wWaitTimeDelta = result.wWaitTime;
|
|
130
|
+
exports._disk_io.tWaitTimeDelta = result.tWaitTime;
|
|
101
131
|
exports._disk_io.rWaitPercent = result.rWaitPercent;
|
|
102
132
|
exports._disk_io.wWaitPercent = result.wWaitPercent;
|
|
103
133
|
exports._disk_io.tWaitPercent = result.tWaitPercent;
|
|
@@ -108,9 +138,9 @@ const calcDiskIO = (rIO, wIO, rWaitTime, wWaitTime, tWaitTime) => {
|
|
|
108
138
|
result.rIO = rIO;
|
|
109
139
|
result.wIO = wIO;
|
|
110
140
|
result.tIO = rIO + wIO;
|
|
111
|
-
result.rWaitTime =
|
|
112
|
-
result.wWaitTime =
|
|
113
|
-
result.tWaitTime =
|
|
141
|
+
result.rWaitTime = null;
|
|
142
|
+
result.wWaitTime = null;
|
|
143
|
+
result.tWaitTime = null;
|
|
114
144
|
exports._disk_io.rIO = rIO;
|
|
115
145
|
exports._disk_io.wIO = wIO;
|
|
116
146
|
exports._disk_io.rIO_sec = null;
|
|
@@ -119,6 +149,9 @@ const calcDiskIO = (rIO, wIO, rWaitTime, wWaitTime, tWaitTime) => {
|
|
|
119
149
|
exports._disk_io.rWaitTime = rWaitTime;
|
|
120
150
|
exports._disk_io.wWaitTime = wWaitTime;
|
|
121
151
|
exports._disk_io.tWaitTime = tWaitTime;
|
|
152
|
+
exports._disk_io.rWaitTimeDelta = null;
|
|
153
|
+
exports._disk_io.wWaitTimeDelta = null;
|
|
154
|
+
exports._disk_io.tWaitTimeDelta = null;
|
|
122
155
|
exports._disk_io.rWaitPercent = null;
|
|
123
156
|
exports._disk_io.wWaitPercent = null;
|
|
124
157
|
exports._disk_io.tWaitPercent = null;
|
|
@@ -204,7 +237,10 @@ const raidMatchLinux = async (data) => {
|
|
|
204
237
|
try {
|
|
205
238
|
for (const element of data) {
|
|
206
239
|
if (element.type.startsWith('raid')) {
|
|
207
|
-
|
|
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 });
|
|
208
244
|
const lines = stdout.split('\n');
|
|
209
245
|
const mdData = decodeMdabmData(lines);
|
|
210
246
|
element.label = mdData.label;
|
|
@@ -280,3 +316,184 @@ const matchDevicesWin = (data, diskDrives) => {
|
|
|
280
316
|
return data;
|
|
281
317
|
};
|
|
282
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 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;
|
|
394
|
+
const applyPoolsLinux = (data, pools) => {
|
|
395
|
+
const defaults = (0, index_1.cloneObj)(defaults_1.initFsBlockDevice);
|
|
396
|
+
const result = [...data];
|
|
397
|
+
for (const pool of pools) {
|
|
398
|
+
const members = result.filter((element) => pool.members.includes(element.name));
|
|
399
|
+
if (!members.length) {
|
|
400
|
+
continue;
|
|
401
|
+
}
|
|
402
|
+
for (const member of members) {
|
|
403
|
+
member.group = pool.name;
|
|
404
|
+
}
|
|
405
|
+
result.push({
|
|
406
|
+
...defaults,
|
|
407
|
+
name: pool.name,
|
|
408
|
+
type: pool.type,
|
|
409
|
+
fsType: pool.fsType,
|
|
410
|
+
mount: pool.mount,
|
|
411
|
+
size: pool.size,
|
|
412
|
+
uuid: pool.uuid
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
return result;
|
|
416
|
+
};
|
|
417
|
+
exports.applyPoolsLinux = applyPoolsLinux;
|
|
418
|
+
const parseZfsMountpoints = (content) => {
|
|
419
|
+
const result = new Map();
|
|
420
|
+
for (const line of content.split('\n')) {
|
|
421
|
+
const parts = line.split(' ');
|
|
422
|
+
if (parts.length < 3 || parts[2] !== 'zfs' || parts[0].includes('/')) {
|
|
423
|
+
continue;
|
|
424
|
+
}
|
|
425
|
+
result.set(parts[0], parts[1].replace(/\\(\d{3})/g, (_, code) => String.fromCharCode(parseInt(code, 8))));
|
|
426
|
+
}
|
|
427
|
+
return result;
|
|
428
|
+
};
|
|
429
|
+
exports.parseZfsMountpoints = parseZfsMountpoints;
|
|
430
|
+
const zfsPoolsLinux = async (data) => {
|
|
431
|
+
const result = [];
|
|
432
|
+
if (!data.some((element) => element.fsType === 'zfs_member')) {
|
|
433
|
+
return result;
|
|
434
|
+
}
|
|
435
|
+
try {
|
|
436
|
+
const status = (0, exports.parseZpoolStatus)(await (0, exec_1.execSecure)('zpool', ['status', '-PL'], { timeout: 5000 }));
|
|
437
|
+
if (!status.size) {
|
|
438
|
+
return result;
|
|
439
|
+
}
|
|
440
|
+
const sizes = (0, exports.parseZpoolList)(await (0, exec_1.execSecure)('zpool', ['list', '-Hp', '-o', 'name,size'], { timeout: 5000 }));
|
|
441
|
+
const mountpoints = (0, exports.parseZfsMountpoints)(await (0, promises_1.readFile)('/proc/mounts', 'utf8').catch(() => ''));
|
|
442
|
+
for (const [name, info] of status) {
|
|
443
|
+
const members = data.filter((element) => info.members.includes(element.name));
|
|
444
|
+
result.push({
|
|
445
|
+
name,
|
|
446
|
+
type: info.type,
|
|
447
|
+
fsType: 'zfs',
|
|
448
|
+
size: sizes.get(name) || members.reduce((sum, element) => sum + element.size, 0),
|
|
449
|
+
uuid: '',
|
|
450
|
+
mount: mountpoints.get(name) || '',
|
|
451
|
+
members: info.members
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
catch { }
|
|
456
|
+
return result;
|
|
457
|
+
};
|
|
458
|
+
exports.zfsPoolsLinux = zfsPoolsLinux;
|
|
459
|
+
const BTRFS_SYSFS = '/sys/fs/btrfs';
|
|
460
|
+
const btrfsPoolsLinux = async (data) => {
|
|
461
|
+
const result = [];
|
|
462
|
+
let fsids = [];
|
|
463
|
+
try {
|
|
464
|
+
fsids = (await (0, promises_1.readdir)(BTRFS_SYSFS)).filter(security_1.isSafePathSegment);
|
|
465
|
+
}
|
|
466
|
+
catch {
|
|
467
|
+
return result;
|
|
468
|
+
}
|
|
469
|
+
for (const fsid of fsids) {
|
|
470
|
+
let devices = [];
|
|
471
|
+
try {
|
|
472
|
+
devices = await (0, promises_1.readdir)(`${BTRFS_SYSFS}/${fsid}/devices`);
|
|
473
|
+
}
|
|
474
|
+
catch {
|
|
475
|
+
continue;
|
|
476
|
+
}
|
|
477
|
+
if (devices.length < 2) {
|
|
478
|
+
continue;
|
|
479
|
+
}
|
|
480
|
+
let profile = '';
|
|
481
|
+
try {
|
|
482
|
+
profile = (0, exports.btrfsProfileFromEntries)(await (0, promises_1.readdir)(`${BTRFS_SYSFS}/${fsid}/allocation/data`));
|
|
483
|
+
}
|
|
484
|
+
catch { }
|
|
485
|
+
const label = (await (0, promises_1.readFile)(`${BTRFS_SYSFS}/${fsid}/label`, 'utf8').catch(() => '')).trim();
|
|
486
|
+
const members = data.filter((element) => devices.includes(element.name));
|
|
487
|
+
result.push({
|
|
488
|
+
name: label || fsid,
|
|
489
|
+
type: profile || 'btrfs',
|
|
490
|
+
fsType: 'btrfs',
|
|
491
|
+
size: members.length === devices.length ? (0, exports.btrfsUsableSize)(profile, members.map((element) => element.size)) : members.reduce((sum, element) => sum + element.size, 0),
|
|
492
|
+
uuid: fsid,
|
|
493
|
+
mount: members.find((element) => element.mount)?.mount || '',
|
|
494
|
+
members: devices
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
return result;
|
|
498
|
+
};
|
|
499
|
+
exports.btrfsPoolsLinux = btrfsPoolsLinux;
|
package/dist/common/host.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getUniqueMacAddresses = exports.getFQDN = void 0;
|
|
4
|
+
const node_child_process_1 = require("node:child_process");
|
|
4
5
|
const node_os_1 = require("node:os");
|
|
5
6
|
const const_1 = require("./const");
|
|
6
7
|
const exec_1 = require("./exec");
|
|
@@ -33,16 +34,67 @@ const getFQDN = async () => {
|
|
|
33
34
|
return (0, node_os_1.hostname)();
|
|
34
35
|
};
|
|
35
36
|
exports.getFQDN = getFQDN;
|
|
37
|
+
const MASKED_MACS = ['00:00:00:00:00:00', '02:00:00:00:00:00'];
|
|
38
|
+
const getMacAddressesSync = () => {
|
|
39
|
+
const result = {};
|
|
40
|
+
let iface = '';
|
|
41
|
+
let mac = '';
|
|
42
|
+
try {
|
|
43
|
+
if (const_1.LINUX) {
|
|
44
|
+
const lines = (0, node_child_process_1.execSync)('export LC_ALL=C; ip link show up; unset LC_ALL', { encoding: 'utf8' }).split('\n');
|
|
45
|
+
for (let i = 0; i < lines.length; i++) {
|
|
46
|
+
const line = lines[i];
|
|
47
|
+
if (line && line[0] !== ' ') {
|
|
48
|
+
const next = (lines[i + 1] || '').trim().split(' ');
|
|
49
|
+
if (next[0] === 'link/ether') {
|
|
50
|
+
iface = (line.split(' ')[1] || '').replace(/:$/, '');
|
|
51
|
+
mac = next[1] || '';
|
|
52
|
+
}
|
|
53
|
+
if (iface && mac) {
|
|
54
|
+
result[iface] = mac.trim();
|
|
55
|
+
iface = '';
|
|
56
|
+
mac = '';
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
else if (const_1.DARWIN || const_1.FREEBSD || const_1.NETBSD || const_1.OPENBSD) {
|
|
62
|
+
const lines = (0, node_child_process_1.execSync)('/sbin/ifconfig', { encoding: 'utf8' }).split('\n');
|
|
63
|
+
for (const line of lines) {
|
|
64
|
+
if (line && line[0] !== '\t' && line.indexOf(':') > 0) {
|
|
65
|
+
iface = line.split(':')[0];
|
|
66
|
+
}
|
|
67
|
+
else if (line.indexOf('\tether ') === 0) {
|
|
68
|
+
mac = line.split('\tether ')[1] || '';
|
|
69
|
+
if (iface && mac) {
|
|
70
|
+
result[iface] = mac.trim();
|
|
71
|
+
iface = '';
|
|
72
|
+
mac = '';
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
catch { }
|
|
79
|
+
return result;
|
|
80
|
+
};
|
|
36
81
|
const getUniqueMacAddresses = () => {
|
|
37
82
|
let macs = [];
|
|
38
83
|
try {
|
|
39
84
|
const interfaces = (0, node_os_1.networkInterfaces)();
|
|
85
|
+
let fallbackMacs = null;
|
|
40
86
|
for (const dev in interfaces) {
|
|
41
87
|
if (Object.keys(interfaces).includes(dev)) {
|
|
42
88
|
interfaces[dev]?.forEach((details) => {
|
|
43
|
-
if (details?.mac
|
|
44
|
-
|
|
45
|
-
if (
|
|
89
|
+
if (details?.mac) {
|
|
90
|
+
let mac = details.mac.toLowerCase();
|
|
91
|
+
if (MASKED_MACS.includes(mac)) {
|
|
92
|
+
if (fallbackMacs === null) {
|
|
93
|
+
fallbackMacs = getMacAddressesSync();
|
|
94
|
+
}
|
|
95
|
+
mac = (fallbackMacs[dev] || '').toLowerCase();
|
|
96
|
+
}
|
|
97
|
+
if (mac && !MASKED_MACS.includes(mac) && macs.indexOf(mac) === -1) {
|
|
46
98
|
macs.push(mac);
|
|
47
99
|
}
|
|
48
100
|
}
|
package/dist/common/internet.js
CHANGED
|
@@ -12,20 +12,41 @@ const checkWebsite = (url, timeout = 5000) => {
|
|
|
12
12
|
const client = url.startsWith('https:') || url.indexOf(':443/') > 0 || url.indexOf(':8443/') > 0 ? https_1.default : http_1.default;
|
|
13
13
|
const t = Date.now();
|
|
14
14
|
return new Promise((resolve) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
try {
|
|
16
|
+
const request = client
|
|
17
|
+
.get(url, (res) => {
|
|
18
|
+
res.on('data', () => { });
|
|
19
|
+
res.on('end', () => {
|
|
20
|
+
resolve({
|
|
21
|
+
url,
|
|
22
|
+
statusCode: res.statusCode,
|
|
23
|
+
ok: res.statusCode >= 200 && res.statusCode <= 399,
|
|
24
|
+
message: res.statusMessage,
|
|
25
|
+
ms: Date.now() - t
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
})
|
|
29
|
+
.on('error', (e) => {
|
|
30
|
+
resolve({
|
|
31
|
+
url,
|
|
32
|
+
statusCode: 404,
|
|
33
|
+
ok: false,
|
|
34
|
+
message: e.message,
|
|
35
|
+
ms: Date.now() - t
|
|
36
|
+
});
|
|
37
|
+
})
|
|
38
|
+
.setTimeout(timeout, () => {
|
|
39
|
+
request.destroy();
|
|
19
40
|
resolve({
|
|
20
41
|
url,
|
|
21
|
-
statusCode:
|
|
22
|
-
ok:
|
|
23
|
-
message:
|
|
42
|
+
statusCode: 408,
|
|
43
|
+
ok: false,
|
|
44
|
+
message: 'Request Timeout',
|
|
24
45
|
ms: Date.now() - t
|
|
25
46
|
});
|
|
26
47
|
});
|
|
27
|
-
}
|
|
28
|
-
|
|
48
|
+
}
|
|
49
|
+
catch (e) {
|
|
29
50
|
resolve({
|
|
30
51
|
url,
|
|
31
52
|
statusCode: 404,
|
|
@@ -33,17 +54,7 @@ const checkWebsite = (url, timeout = 5000) => {
|
|
|
33
54
|
message: e.message,
|
|
34
55
|
ms: Date.now() - t
|
|
35
56
|
});
|
|
36
|
-
}
|
|
37
|
-
.setTimeout(timeout, () => {
|
|
38
|
-
request.destroy();
|
|
39
|
-
resolve({
|
|
40
|
-
url,
|
|
41
|
-
statusCode: 408,
|
|
42
|
-
ok: false,
|
|
43
|
-
message: 'Request Timeout',
|
|
44
|
-
ms: Date.now() - t
|
|
45
|
-
});
|
|
46
|
-
});
|
|
57
|
+
}
|
|
47
58
|
});
|
|
48
59
|
};
|
|
49
60
|
exports.checkWebsite = checkWebsite;
|
|
@@ -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';
|
|
@@ -1670,23 +1670,44 @@ const graphicsMetalVersion = (id) => {
|
|
|
1670
1670
|
spdisplays_metalfeaturesetfamily14: 'family1_v4',
|
|
1671
1671
|
spdisplays_metalfeaturesetfamily21: 'family2_v1'
|
|
1672
1672
|
};
|
|
1673
|
-
|
|
1673
|
+
const version = /^spdisplays_metal(\d+)$/.exec(id);
|
|
1674
|
+
return families[id] || (version ? version[1] : '');
|
|
1674
1675
|
};
|
|
1675
1676
|
exports.graphicsMetalVersion = graphicsMetalVersion;
|
|
1676
|
-
exports.winProcessStatus = {
|
|
1677
|
-
'0': 'unknown',
|
|
1678
|
-
'1': 'other',
|
|
1679
|
-
'2': 'ready',
|
|
1680
|
-
'3': 'running',
|
|
1681
|
-
'4': 'blocked',
|
|
1682
|
-
'5': 'suspended blocked',
|
|
1683
|
-
'6': 'suspended ready',
|
|
1684
|
-
'7': 'terminated',
|
|
1685
|
-
'8': 'stopped',
|
|
1686
|
-
'9': 'growing'
|
|
1687
|
-
};
|
|
1688
1677
|
const getAppleModel = (key) => {
|
|
1689
1678
|
const appleModelIds = [
|
|
1679
|
+
{
|
|
1680
|
+
key: 'Mac18,5',
|
|
1681
|
+
name: 'Mac mini',
|
|
1682
|
+
size: '',
|
|
1683
|
+
processor: 'M6',
|
|
1684
|
+
year: '2026',
|
|
1685
|
+
additional: ''
|
|
1686
|
+
},
|
|
1687
|
+
{
|
|
1688
|
+
key: 'Mac17,16',
|
|
1689
|
+
name: 'Mac mini',
|
|
1690
|
+
size: '',
|
|
1691
|
+
processor: 'M5 Pro',
|
|
1692
|
+
year: '2026',
|
|
1693
|
+
additional: ''
|
|
1694
|
+
},
|
|
1695
|
+
{
|
|
1696
|
+
key: 'Mac17,15',
|
|
1697
|
+
name: 'Mac Studio',
|
|
1698
|
+
size: '',
|
|
1699
|
+
processor: 'M5 Ultra',
|
|
1700
|
+
year: '2026',
|
|
1701
|
+
additional: ''
|
|
1702
|
+
},
|
|
1703
|
+
{
|
|
1704
|
+
key: 'Mac17,14',
|
|
1705
|
+
name: 'Mac Studio',
|
|
1706
|
+
size: '',
|
|
1707
|
+
processor: 'M5 Max',
|
|
1708
|
+
year: '2026',
|
|
1709
|
+
additional: ''
|
|
1710
|
+
},
|
|
1690
1711
|
{
|
|
1691
1712
|
key: 'Mac17,9',
|
|
1692
1713
|
name: 'MacBook Pro',
|
package/dist/common/network.d.ts
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
|
-
import type { NetworkStatsData } from './types';
|
|
1
|
+
import type { NetworkInterfacesData, NetworkStatsData } from './types';
|
|
2
2
|
export declare const wifiDBFromQuality: (quality: string) => number | null;
|
|
3
3
|
export declare const wifiQualityFromDB: (db: number | string) => number | null;
|
|
4
4
|
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;
|
|
21
|
+
export declare const filterDefaultInterface: (interfaces: NetworkInterfacesData[], defaultString: string) => NetworkInterfacesData[];
|