systeminformation 6.0.0-beta.1 → 6.0.0-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -7
- package/dist/bsd/network-stats.js +2 -2
- 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 +21 -5
- package/dist/common/exec.js +1 -1
- package/dist/common/files.d.ts +9 -0
- package/dist/common/files.js +67 -3
- package/dist/common/filesys.d.ts +10 -0
- package/dist/common/filesys.js +41 -10
- package/dist/common/host.js +55 -3
- package/dist/common/mappings.js +2 -1
- package/dist/common/network.js +4 -4
- 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 +1 -0
- package/dist/common/security.js +3 -1
- package/dist/common/types.d.ts +33 -5
- package/dist/cpu-current-load.js +28 -6
- 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.js +34 -1
- 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 +2 -0
- package/dist/darwin/index.js +6 -2
- package/dist/darwin/keyboard.js +4 -4
- package/dist/darwin/mouse.js +4 -4
- package/dist/darwin/network-interfaces.js +5 -10
- package/dist/darwin/network-stats.js +5 -5
- package/dist/darwin/serial-ports.d.ts +2 -0
- package/dist/darwin/serial-ports.js +94 -0
- 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/index.d.ts +2 -0
- package/dist/index.js +6 -2
- package/dist/linux/audio.js +59 -0
- package/dist/linux/baseboard.js +9 -20
- package/dist/linux/bios.js +6 -15
- 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 +7 -10
- package/dist/linux/disks-io.js +9 -9
- package/dist/linux/displays.js +40 -2
- package/dist/linux/fans.d.ts +2 -0
- package/dist/linux/fans.js +92 -0
- package/dist/linux/fs-size.js +160 -34
- package/dist/linux/fs-stats.js +6 -9
- package/dist/linux/gpu.js +15 -15
- package/dist/linux/index.d.ts +2 -0
- package/dist/linux/index.js +6 -2
- package/dist/linux/mem-layout.js +2 -2
- package/dist/linux/network-interfaces.js +36 -39
- package/dist/linux/network-stats.js +8 -36
- package/dist/linux/npu.js +2 -1
- package/dist/linux/os-info.js +19 -4
- package/dist/linux/printer.js +4 -4
- package/dist/linux/process-load.js +9 -12
- 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 +179 -47
- package/dist/linux/system.js +1 -7
- package/dist/linux/uuid.js +4 -10
- package/dist/serial-ports.d.ts +1 -0
- package/dist/serial-ports.js +17 -0
- package/dist/versions.js +32 -77
- package/dist/windows/disk-layout.js +3 -0
- package/dist/windows/disks-io.js +3 -3
- package/dist/windows/displays.js +43 -12
- package/dist/windows/fans.d.ts +2 -0
- package/dist/windows/fans.js +71 -0
- package/dist/windows/index.d.ts +2 -0
- package/dist/windows/index.js +6 -2
- package/dist/windows/network-interfaces.js +20 -29
- package/dist/windows/network-stats.js +4 -2
- package/dist/windows/process-load.js +7 -5
- package/dist/windows/processes.js +17 -11
- package/dist/windows/serial-ports.d.ts +3 -0
- package/dist/windows/serial-ports.js +73 -0
- package/dist/windows/services.js +3 -0
- package/package.json +1 -1
package/dist/linux/fs-size.js
CHANGED
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.fsSize = void 0;
|
|
4
|
+
const promises_1 = require("node:fs/promises");
|
|
4
5
|
const common_1 = require("../common");
|
|
5
6
|
const const_1 = require("../common/const");
|
|
6
7
|
const exec_1 = require("../common/exec");
|
|
8
|
+
const files_1 = require("../common/files");
|
|
9
|
+
const filesys_1 = require("../common/filesys");
|
|
7
10
|
let macOsDisks = [];
|
|
11
|
+
let macOsFsTypes = new Map();
|
|
8
12
|
let osMounts = {};
|
|
13
|
+
const macOsFsType = (fs) => {
|
|
14
|
+
const type = macOsFsTypes.get(fs);
|
|
15
|
+
if (!type) {
|
|
16
|
+
return getmacOsFsType(fs);
|
|
17
|
+
}
|
|
18
|
+
return type === 'apfs' ? 'APFS' : type === 'hfs' ? 'HFS' : type === 'nfs' ? 'NFS' : type;
|
|
19
|
+
};
|
|
9
20
|
const getmacOsFsType = (fs) => {
|
|
10
21
|
if (!fs.startsWith('/')) {
|
|
11
22
|
return 'NFS';
|
|
@@ -53,7 +64,7 @@ const parseNixFsSize = (lines) => {
|
|
|
53
64
|
const match = line.trim().match(withType ? dfLineWithType : dfLineNoType);
|
|
54
65
|
if (match) {
|
|
55
66
|
const fs = match[1].trim();
|
|
56
|
-
const fsType = withType ? match[2] :
|
|
67
|
+
const fsType = withType ? match[2] : macOsFsType(fs);
|
|
57
68
|
const mount = (withType ? match[6] : match[5]).trim();
|
|
58
69
|
if (fs.startsWith('/') || mount === '/' || fs.indexOf('/') > 0 || fs.indexOf(':') === 1 || (!const_1.DARWIN && !isLinuxTmpFs(fsType))) {
|
|
59
70
|
const size = (0, common_1.toInt)(match[withType ? 3 : 2]) * 1024;
|
|
@@ -78,6 +89,127 @@ const parseNixFsSize = (lines) => {
|
|
|
78
89
|
});
|
|
79
90
|
return data;
|
|
80
91
|
};
|
|
92
|
+
const unescapeMount = (value) => value.replace(/\\(\d{3})/g, (_, octal) => String.fromCharCode(parseInt(octal, 8)));
|
|
93
|
+
const statfsSafeTypes = [
|
|
94
|
+
'bcachefs',
|
|
95
|
+
'btrfs',
|
|
96
|
+
'erofs',
|
|
97
|
+
'exfat',
|
|
98
|
+
'ext2',
|
|
99
|
+
'ext3',
|
|
100
|
+
'ext4',
|
|
101
|
+
'efivarfs',
|
|
102
|
+
'f2fs',
|
|
103
|
+
'gfs2',
|
|
104
|
+
'hfs',
|
|
105
|
+
'hfsplus',
|
|
106
|
+
'iso9660',
|
|
107
|
+
'jffs2',
|
|
108
|
+
'jfs',
|
|
109
|
+
'msdos',
|
|
110
|
+
'nilfs2',
|
|
111
|
+
'ntfs',
|
|
112
|
+
'ntfs3',
|
|
113
|
+
'ocfs2',
|
|
114
|
+
'overlay',
|
|
115
|
+
'reiserfs',
|
|
116
|
+
'tmpfs',
|
|
117
|
+
'ubifs',
|
|
118
|
+
'udf',
|
|
119
|
+
'vfat',
|
|
120
|
+
'xfs',
|
|
121
|
+
'zfs'
|
|
122
|
+
];
|
|
123
|
+
const linuxFsSize = async (drives) => {
|
|
124
|
+
const data = [];
|
|
125
|
+
const mounts = await (0, files_1.readFileLines)('/proc/mounts');
|
|
126
|
+
if (!mounts.length) {
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
const osMountsKnown = Object.keys(osMounts).length > 0;
|
|
130
|
+
for (const line of mounts) {
|
|
131
|
+
const parts = line.split(' ');
|
|
132
|
+
if (parts.length < 4) {
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
const fs = unescapeMount(parts[0]);
|
|
136
|
+
const mount = unescapeMount(parts[1]);
|
|
137
|
+
const type = parts[2];
|
|
138
|
+
if (type === 'squashfs') {
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
if (!(fs.startsWith('/') || mount === '/' || fs.indexOf('/') > 0 || fs.indexOf(':') === 1 || !isLinuxTmpFs(type))) {
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
try {
|
|
145
|
+
const [stats, { dev }] = await Promise.all([(0, promises_1.statfs)(mount), (0, promises_1.stat)(mount)]);
|
|
146
|
+
const size = stats.blocks * stats.bsize;
|
|
147
|
+
if (!size) {
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
const used = (stats.blocks - stats.bfree) * stats.bsize;
|
|
151
|
+
const available = stats.bavail * stats.bsize;
|
|
152
|
+
const item = {
|
|
153
|
+
dev,
|
|
154
|
+
entry: {
|
|
155
|
+
fs,
|
|
156
|
+
type,
|
|
157
|
+
size,
|
|
158
|
+
used,
|
|
159
|
+
available,
|
|
160
|
+
use: parseFloat((100.0 * (used / (used + available))).toFixed(2)),
|
|
161
|
+
mount,
|
|
162
|
+
rw: osMountsKnown ? osMounts[fs] || false : null
|
|
163
|
+
},
|
|
164
|
+
trusted: statfsSafeTypes.includes(type)
|
|
165
|
+
};
|
|
166
|
+
const duplicate = data.findIndex((el) => el.dev === dev);
|
|
167
|
+
if (duplicate >= 0) {
|
|
168
|
+
if (data[duplicate].entry.mount.length > mount.length) {
|
|
169
|
+
data[duplicate] = item;
|
|
170
|
+
}
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
data.push(item);
|
|
174
|
+
}
|
|
175
|
+
catch { }
|
|
176
|
+
}
|
|
177
|
+
if (!data.length) {
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
const requested = data.filter((item) => matchesDrives(item.entry.fs, item.entry.mount, drives));
|
|
181
|
+
if (requested.some((item) => !item.trusted)) {
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
return requested.map((item) => item.entry);
|
|
185
|
+
};
|
|
186
|
+
const matchesDrives = (fs, mount, drives) => {
|
|
187
|
+
if (!drives.length) {
|
|
188
|
+
return true;
|
|
189
|
+
}
|
|
190
|
+
return drives.some((drive) => fs.toLowerCase().indexOf(drive.toLowerCase()) >= 0 || mount.toLowerCase().indexOf(drive.toLowerCase()) >= 0);
|
|
191
|
+
};
|
|
192
|
+
const applyZfsUsage = async (data) => {
|
|
193
|
+
if (!data.some((item) => item.type === 'zfs')) {
|
|
194
|
+
return data;
|
|
195
|
+
}
|
|
196
|
+
const { byMount, byName } = await (0, filesys_1.zfsDatasets)();
|
|
197
|
+
for (const item of data) {
|
|
198
|
+
if (item.type !== 'zfs') {
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
const dataset = byName.get(item.fs) || byMount.get(item.mount);
|
|
202
|
+
if (!dataset || !(dataset.used + dataset.available)) {
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
item.used = dataset.used;
|
|
206
|
+
item.available = dataset.available;
|
|
207
|
+
item.size = dataset.used + dataset.available;
|
|
208
|
+
item.use = parseFloat(((100.0 * dataset.used) / item.size).toFixed(2));
|
|
209
|
+
}
|
|
210
|
+
return data;
|
|
211
|
+
};
|
|
212
|
+
const filterDrives = (data, drives) => data.filter((item) => matchesDrives(item.fs, item.mount, drives));
|
|
81
213
|
const fsSize = async (drives) => {
|
|
82
214
|
await (0, common_1.nextTick)();
|
|
83
215
|
let data = [];
|
|
@@ -86,6 +218,7 @@ const fsSize = async (drives) => {
|
|
|
86
218
|
let stderr = '';
|
|
87
219
|
let lines = [];
|
|
88
220
|
macOsDisks = [];
|
|
221
|
+
macOsFsTypes = new Map();
|
|
89
222
|
osMounts = {};
|
|
90
223
|
if (const_1.DARWIN) {
|
|
91
224
|
cmd = 'df -kP';
|
|
@@ -95,35 +228,35 @@ const fsSize = async (drives) => {
|
|
|
95
228
|
return !line.startsWith('/') && line.indexOf(':') > 0;
|
|
96
229
|
});
|
|
97
230
|
({ stdout } = await (0, exec_1.exec)('mount', const_1.execOptsLinux));
|
|
98
|
-
stdout
|
|
99
|
-
.split('
|
|
100
|
-
.
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
231
|
+
stdout.split('\n').forEach((line) => {
|
|
232
|
+
const fs = line.split(' on ')[0];
|
|
233
|
+
const type = line.match(/\(([^),]+)[^)]*\)$/);
|
|
234
|
+
if (fs && type) {
|
|
235
|
+
macOsFsTypes.set(fs, type[1].trim().toLowerCase());
|
|
236
|
+
}
|
|
237
|
+
if (line.startsWith('/')) {
|
|
238
|
+
osMounts[fs] = line.toLowerCase().indexOf('read-only') === -1;
|
|
239
|
+
}
|
|
105
240
|
});
|
|
106
241
|
}
|
|
107
242
|
catch { }
|
|
108
243
|
}
|
|
109
244
|
if (const_1.LINUX) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
const fs = line.split(' ')[0].replace(/\\(\d{3})/g, (_, octal) => String.fromCharCode(parseInt(octal, 8)));
|
|
120
|
-
osMounts[fs] = osMounts[fs] || false;
|
|
121
|
-
if (line.indexOf('/snap/') === -1) {
|
|
122
|
-
osMounts[fs] = line.toLowerCase().indexOf('rw,') >= 0 || line.toLowerCase().indexOf(' rw ') >= 0;
|
|
123
|
-
}
|
|
124
|
-
});
|
|
245
|
+
for (const line of await (0, files_1.readFileLines)('/proc/mounts')) {
|
|
246
|
+
if (!line.startsWith('/')) {
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
const fs = unescapeMount(line.split(' ')[0]);
|
|
250
|
+
osMounts[fs] = osMounts[fs] || false;
|
|
251
|
+
if (line.indexOf('/snap/') === -1) {
|
|
252
|
+
osMounts[fs] = line.toLowerCase().indexOf('rw,') >= 0 || line.toLowerCase().indexOf(' rw ') >= 0;
|
|
253
|
+
}
|
|
125
254
|
}
|
|
126
|
-
|
|
255
|
+
const linuxData = await linuxFsSize(drives);
|
|
256
|
+
if (linuxData) {
|
|
257
|
+
return await applyZfsUsage(linuxData);
|
|
258
|
+
}
|
|
259
|
+
cmd = 'export LC_ALL=C; df -kPTx squashfs; unset LC_ALL';
|
|
127
260
|
}
|
|
128
261
|
if (const_1.FREEBSD || const_1.NETBSD || const_1.OPENBSD) {
|
|
129
262
|
try {
|
|
@@ -135,23 +268,16 @@ const fsSize = async (drives) => {
|
|
|
135
268
|
}
|
|
136
269
|
catch { }
|
|
137
270
|
}
|
|
138
|
-
({ stdout, stderr } = await (0, exec_1.
|
|
271
|
+
({ stdout, stderr } = await (0, exec_1.execSave)(cmd, const_1.execOptsLinux));
|
|
139
272
|
if (!stderr) {
|
|
140
273
|
lines = filterFsLines(stdout);
|
|
141
274
|
data = parseNixFsSize(lines);
|
|
142
275
|
}
|
|
143
276
|
else {
|
|
144
|
-
({ stdout } = await (0, exec_1.
|
|
277
|
+
({ stdout } = await (0, exec_1.execSave)('df -kPT 2>/dev/null', const_1.execOptsLinux));
|
|
145
278
|
lines = filterFsLines(stdout);
|
|
146
279
|
data = parseNixFsSize(lines);
|
|
147
280
|
}
|
|
148
|
-
|
|
149
|
-
data = data.filter((item) => {
|
|
150
|
-
return drives.some((drive) => {
|
|
151
|
-
return item.fs.toLowerCase().indexOf(drive.toLowerCase()) >= 0 || item.mount.toLowerCase().indexOf(drive.toLowerCase()) >= 0;
|
|
152
|
-
});
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
return data;
|
|
281
|
+
return await applyZfsUsage(filterDrives(data, drives));
|
|
156
282
|
};
|
|
157
283
|
exports.fsSize = fsSize;
|
package/dist/linux/fs-stats.js
CHANGED
|
@@ -6,6 +6,7 @@ const index_1 = require("../common/index");
|
|
|
6
6
|
const exec_1 = require("../common/exec");
|
|
7
7
|
const common_1 = require("../common");
|
|
8
8
|
const filesys_1 = require("../common/filesys");
|
|
9
|
+
const files_1 = require("../common/files");
|
|
9
10
|
const security_1 = require("../common/security");
|
|
10
11
|
const const_1 = require("../common/const");
|
|
11
12
|
const fsStats = async () => {
|
|
@@ -16,8 +17,8 @@ const fsStats = async () => {
|
|
|
16
17
|
let rx = 0;
|
|
17
18
|
let wx = 0;
|
|
18
19
|
try {
|
|
19
|
-
({ stdout } = await (0, exec_1.exec)('lsblk -r 2>/dev/null
|
|
20
|
-
const lines = stdout.toString().split('\n');
|
|
20
|
+
({ stdout } = await (0, exec_1.exec)('lsblk -r 2>/dev/null', const_1.execOptsLinux));
|
|
21
|
+
const lines = stdout.toString().split('\n').filter((line) => line.indexOf('/') >= 0);
|
|
21
22
|
const fs_filter = [];
|
|
22
23
|
lines.forEach((line) => {
|
|
23
24
|
if (line !== '') {
|
|
@@ -28,14 +29,10 @@ const fsStats = async () => {
|
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
31
|
});
|
|
31
|
-
const output = fs_filter.join('|');
|
|
32
32
|
try {
|
|
33
|
-
(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
line = line.trim();
|
|
37
|
-
if (line !== '') {
|
|
38
|
-
const lineParts = line.replace(/ +/g, ' ').split(' ');
|
|
33
|
+
(await (0, files_1.readFileLines)('/proc/diskstats')).forEach((line) => {
|
|
34
|
+
const lineParts = line.trim().split(/\s+/);
|
|
35
|
+
if (fs_filter.indexOf(lineParts[2]) >= 0) {
|
|
39
36
|
rx += (0, common_1.toInt)(lineParts[5]) * 512;
|
|
40
37
|
wx += (0, common_1.toInt)(lineParts[9]) * 512;
|
|
41
38
|
}
|
package/dist/linux/gpu.js
CHANGED
|
@@ -5,24 +5,23 @@ const promises_1 = require("fs/promises");
|
|
|
5
5
|
const common_1 = require("../common");
|
|
6
6
|
const const_1 = require("../common/const");
|
|
7
7
|
const exec_1 = require("../common/exec");
|
|
8
|
+
const files_1 = require("../common/files");
|
|
8
9
|
const nvidia_1 = require("../common/nvidia");
|
|
9
10
|
const raspberry_1 = require("../common/raspberry");
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
catch {
|
|
15
|
-
return '';
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
const readSysfsNumber = async (files, divisor = 1) => {
|
|
11
|
+
const security_1 = require("../common/security");
|
|
12
|
+
const readSysfsNumber = async (files, divisor = 1, preferNonZero = false) => {
|
|
13
|
+
let fallback = null;
|
|
19
14
|
for (const file of files) {
|
|
20
|
-
const value = Number.parseFloat(await readSysfs(file));
|
|
21
|
-
if (
|
|
15
|
+
const value = Number.parseFloat(await (0, files_1.readSysfs)(file));
|
|
16
|
+
if (Number.isNaN(value)) {
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
if (!preferNonZero || value !== 0) {
|
|
22
20
|
return value / divisor;
|
|
23
21
|
}
|
|
22
|
+
fallback = 0;
|
|
24
23
|
}
|
|
25
|
-
return
|
|
24
|
+
return fallback;
|
|
26
25
|
};
|
|
27
26
|
const parseAmdClock = (stdout) => {
|
|
28
27
|
const line = stdout.split('\n').find((l) => l.includes('*'));
|
|
@@ -53,16 +52,17 @@ const drmDevices = async (drmPath = '/sys/class/drm') => {
|
|
|
53
52
|
}
|
|
54
53
|
let hwmon = [];
|
|
55
54
|
try {
|
|
56
|
-
hwmon = (await (0, promises_1.readdir)(`${devicePath}/hwmon`)).map((node) => `${devicePath}/hwmon/${node}`);
|
|
55
|
+
hwmon = (await (0, promises_1.readdir)(`${devicePath}/hwmon`)).filter(security_1.isSafePathSegment).map((node) => `${devicePath}/hwmon/${node}`);
|
|
57
56
|
}
|
|
58
57
|
catch { }
|
|
59
58
|
const clockCore = await readSysfsNumber([
|
|
60
59
|
`${cardPath}/gt_act_freq_mhz`,
|
|
61
60
|
`${cardPath}/gt_cur_freq_mhz`,
|
|
62
61
|
`${cardPath}/gt/gt0/rps_act_freq_mhz`,
|
|
62
|
+
`${cardPath}/gt/gt0/rps_cur_freq_mhz`,
|
|
63
63
|
`${devicePath}/tile0/gt0/freq0/act_freq`,
|
|
64
64
|
`${devicePath}/tile0/gt0/freq0/cur_freq`
|
|
65
|
-
]);
|
|
65
|
+
], 1, true);
|
|
66
66
|
devices.push({
|
|
67
67
|
busAddress,
|
|
68
68
|
utilizationGpu: await readSysfsNumber([`${devicePath}/gpu_busy_percent`]),
|
|
@@ -71,7 +71,7 @@ const drmDevices = async (drmPath = '/sys/class/drm') => {
|
|
|
71
71
|
temperatureGpu: await readSysfsNumber(hwmon.map((node) => `${node}/temp1_input`), 1000),
|
|
72
72
|
powerDraw: await readSysfsNumber(hwmon.map((node) => `${node}/power1_input`), 1000000),
|
|
73
73
|
powerLimit: await readSysfsNumber(hwmon.map((node) => `${node}/power1_max`), 1000000),
|
|
74
|
-
clockCore: clockCore !== null ? clockCore : parseAmdClock(await readSysfs(`${devicePath}/pp_dpm_sclk`))
|
|
74
|
+
clockCore: clockCore !== null ? clockCore : parseAmdClock(await (0, files_1.readSysfs)(`${devicePath}/pp_dpm_sclk`))
|
|
75
75
|
});
|
|
76
76
|
}
|
|
77
77
|
return devices;
|
package/dist/linux/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export { cpuCache } from './cpu-cache';
|
|
|
11
11
|
export { cpuCurrentSpeed } from '../cpu-current-speed';
|
|
12
12
|
export { cpuFlags } from './cpu-flags';
|
|
13
13
|
export { cpuTemperature } from './cpu-temperature';
|
|
14
|
+
export { fans } from './fans';
|
|
14
15
|
export { currentLoad } from '../cpu-current-load';
|
|
15
16
|
export { diskLayout } from './disk-layout';
|
|
16
17
|
export { disksIO } from './disks-io';
|
|
@@ -45,6 +46,7 @@ export { software } from './software';
|
|
|
45
46
|
export { system } from './system';
|
|
46
47
|
export { thunderbolt } from './thunderbolt';
|
|
47
48
|
export { time } from '../time';
|
|
49
|
+
export { serialPorts } from './serial-ports';
|
|
48
50
|
export { usb } from './usb';
|
|
49
51
|
export { users } from './users';
|
|
50
52
|
export { uuid } from './uuid';
|
package/dist/linux/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.wifiNetworks = exports.wifiInterfaces = exports.wifiConnections = exports.versions = exports.version = exports.vboxInfo = exports.uuid = exports.users = exports.usb = exports.time = exports.thunderbolt = exports.system = void 0;
|
|
3
|
+
exports.shell = exports.services = exports.processLoad = exports.processes = exports.printer = exports.pci = exports.osInfo = exports.npu = exports.npm = exports.networkStats = exports.networkInterfaces = exports.networkInterfaceDefault = exports.networkGatewayDefault = exports.networkConnections = exports.mouse = exports.memLayout = exports.mem = exports.keyboard = exports.inetLatency = exports.inetChecksite = exports.gpu = exports.fullLoad = exports.fsStats = exports.fsSize = exports.fsOpenFiles = exports.dockerAll = exports.dockerVolumes = exports.dockerContainerProcesses = exports.dockerContainerStats = exports.dockerContainers = exports.dockerImages = exports.dockerInfo = exports.displays = exports.disksIO = exports.diskLayout = exports.currentLoad = exports.fans = exports.cpuTemperature = exports.cpuFlags = exports.cpuCurrentSpeed = exports.cpuCache = exports.cpu = exports.chassis = exports.camera = exports.bluetoothDevices = exports.blockDevices = exports.bios = exports.battery = exports.baseboard = exports.audio = void 0;
|
|
4
|
+
exports.wifiNetworks = exports.wifiInterfaces = exports.wifiConnections = exports.versions = exports.version = exports.vboxInfo = exports.uuid = exports.users = exports.usb = exports.serialPorts = exports.time = exports.thunderbolt = exports.system = exports.software = void 0;
|
|
5
5
|
var audio_1 = require("./audio");
|
|
6
6
|
Object.defineProperty(exports, "audio", { enumerable: true, get: function () { return audio_1.audio; } });
|
|
7
7
|
var baseboard_1 = require("./baseboard");
|
|
@@ -28,6 +28,8 @@ var cpu_flags_1 = require("./cpu-flags");
|
|
|
28
28
|
Object.defineProperty(exports, "cpuFlags", { enumerable: true, get: function () { return cpu_flags_1.cpuFlags; } });
|
|
29
29
|
var cpu_temperature_1 = require("./cpu-temperature");
|
|
30
30
|
Object.defineProperty(exports, "cpuTemperature", { enumerable: true, get: function () { return cpu_temperature_1.cpuTemperature; } });
|
|
31
|
+
var fans_1 = require("./fans");
|
|
32
|
+
Object.defineProperty(exports, "fans", { enumerable: true, get: function () { return fans_1.fans; } });
|
|
31
33
|
var cpu_current_load_1 = require("../cpu-current-load");
|
|
32
34
|
Object.defineProperty(exports, "currentLoad", { enumerable: true, get: function () { return cpu_current_load_1.currentLoad; } });
|
|
33
35
|
var disk_layout_1 = require("./disk-layout");
|
|
@@ -102,6 +104,8 @@ var thunderbolt_1 = require("./thunderbolt");
|
|
|
102
104
|
Object.defineProperty(exports, "thunderbolt", { enumerable: true, get: function () { return thunderbolt_1.thunderbolt; } });
|
|
103
105
|
var time_1 = require("../time");
|
|
104
106
|
Object.defineProperty(exports, "time", { enumerable: true, get: function () { return time_1.time; } });
|
|
107
|
+
var serial_ports_1 = require("./serial-ports");
|
|
108
|
+
Object.defineProperty(exports, "serialPorts", { enumerable: true, get: function () { return serial_ports_1.serialPorts; } });
|
|
105
109
|
var usb_1 = require("./usb");
|
|
106
110
|
Object.defineProperty(exports, "usb", { enumerable: true, get: function () { return usb_1.usb; } });
|
|
107
111
|
var users_1 = require("./users");
|
package/dist/linux/mem-layout.js
CHANGED
|
@@ -5,6 +5,7 @@ const node_os_1 = require("node:os");
|
|
|
5
5
|
const common_1 = require("../common");
|
|
6
6
|
const const_1 = require("../common/const");
|
|
7
7
|
const exec_1 = require("../common/exec");
|
|
8
|
+
const files_1 = require("../common/files");
|
|
8
9
|
const mappings_1 = require("../common/mappings");
|
|
9
10
|
const raspberry_1 = require("../common/raspberry");
|
|
10
11
|
const memLayout = async () => {
|
|
@@ -78,8 +79,7 @@ const memLayout = async () => {
|
|
|
78
79
|
voltageMin: null,
|
|
79
80
|
voltageMax: null
|
|
80
81
|
});
|
|
81
|
-
|
|
82
|
-
let lines = stdout.split('\n');
|
|
82
|
+
let lines = await (0, files_1.readFileLines)('/proc/cpuinfo');
|
|
83
83
|
const version = (0, common_1.getValue)(lines, 'revision', ':', true).toLowerCase();
|
|
84
84
|
if (await (0, raspberry_1.isRaspberry)(lines)) {
|
|
85
85
|
result[0].type = 'LPDDR2';
|
|
@@ -8,6 +8,7 @@ const common_1 = require("../common");
|
|
|
8
8
|
const const_1 = require("../common/const");
|
|
9
9
|
const defaults_1 = require("../common/defaults");
|
|
10
10
|
const exec_1 = require("../common/exec");
|
|
11
|
+
const files_1 = require("../common/files");
|
|
11
12
|
const index_1 = require("../common/index");
|
|
12
13
|
const network_1 = require("../common/network");
|
|
13
14
|
const security_1 = require("../common/security");
|
|
@@ -31,24 +32,27 @@ const splitSectionsNics = (lines) => {
|
|
|
31
32
|
}
|
|
32
33
|
return result;
|
|
33
34
|
};
|
|
34
|
-
const
|
|
35
|
+
const getLinuxDeviceStatus = async () => {
|
|
35
36
|
try {
|
|
36
37
|
const { stdout } = await (0, exec_1.execFile)('nmcli', ['device', 'status'], const_1.execOptsLinux);
|
|
37
|
-
|
|
38
|
-
const resultFormat = result.replace(/\s+/g, ' ').trim();
|
|
39
|
-
const connectionNameLines = resultFormat.split(' ').slice(3);
|
|
40
|
-
const connectionName = connectionNameLines.join(' ');
|
|
41
|
-
return connectionName !== '--' ? connectionName : '';
|
|
38
|
+
return stdout;
|
|
42
39
|
}
|
|
43
40
|
catch {
|
|
44
41
|
return '';
|
|
45
42
|
}
|
|
46
43
|
};
|
|
44
|
+
const getLinuxIfaceConnectionName = (deviceStatus, interfaceName) => {
|
|
45
|
+
const result = (0, common_1.grep)(deviceStatus, interfaceName);
|
|
46
|
+
const resultFormat = result.replace(/\s+/g, ' ').trim();
|
|
47
|
+
const connectionNameLines = resultFormat.split(' ').slice(3);
|
|
48
|
+
const connectionName = connectionNameLines.join(' ');
|
|
49
|
+
return connectionName !== '--' ? connectionName : '';
|
|
50
|
+
};
|
|
47
51
|
const readInterfacesLines = async (file) => {
|
|
48
52
|
if (file.includes('*') || file.includes('?')) {
|
|
49
53
|
try {
|
|
50
54
|
const rx = new RegExp(`^${(0, node_path_1.basename)(file).replace(/\./g, '\\.').replace(/\*/g, '.*').replace(/\?/g, '.')}$`);
|
|
51
|
-
const names = (await (0, promises_1.readdir)((0, node_path_1.dirname)(file))).filter((n) => rx.test(n)).sort();
|
|
55
|
+
const names = (await (0, promises_1.readdir)((0, node_path_1.dirname)(file))).filter((n) => rx.test(n) && (0, security_1.isSafePathSegment)(n)).sort();
|
|
52
56
|
const out = [];
|
|
53
57
|
for (const n of names) {
|
|
54
58
|
out.push(...(await readInterfacesLines((0, node_path_1.join)((0, node_path_1.dirname)(file), n))));
|
|
@@ -201,7 +205,17 @@ const networkInterfaces = async (defaultString = '', rescan = true) => {
|
|
|
201
205
|
try {
|
|
202
206
|
const _dhcpNics = await getLinuxDHCPNics();
|
|
203
207
|
const defaultInterface = await (0, network_interface_default_1.networkInterfaceDefault)();
|
|
204
|
-
|
|
208
|
+
const deviceStatus = await getLinuxDeviceStatus();
|
|
209
|
+
const devices = Object.keys(interfaces);
|
|
210
|
+
try {
|
|
211
|
+
for (const dev of await (0, promises_1.readdir)('/sys/class/net')) {
|
|
212
|
+
if (!devices.some((device) => device.split(':')[0] === dev)) {
|
|
213
|
+
devices.push(dev);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
catch { }
|
|
218
|
+
for (const dev of devices) {
|
|
205
219
|
const iface = dev;
|
|
206
220
|
let ip4 = '';
|
|
207
221
|
let ip4subnet = '';
|
|
@@ -254,37 +268,18 @@ const networkInterfaces = async (defaultString = '', rescan = true) => {
|
|
|
254
268
|
ip6subnet = ip6linksubnet;
|
|
255
269
|
}
|
|
256
270
|
const ifaceDevName = dev.split(':')[0].trim();
|
|
257
|
-
const ifaceSanitized = (0, security_1.sanitizeString)(ifaceDevName);
|
|
258
|
-
const cmd = `echo -n "addr_assign_type: "; cat /sys/class/net/${ifaceSanitized}/addr_assign_type 2>/dev/null; echo;
|
|
259
|
-
echo -n "address: "; cat /sys/class/net/${ifaceSanitized}/address 2>/dev/null; echo;
|
|
260
|
-
echo -n "addr_len: "; cat /sys/class/net/${ifaceSanitized}/addr_len 2>/dev/null; echo;
|
|
261
|
-
echo -n "broadcast: "; cat /sys/class/net/${ifaceSanitized}/broadcast 2>/dev/null; echo;
|
|
262
|
-
echo -n "carrier: "; cat /sys/class/net/${ifaceSanitized}/carrier 2>/dev/null; echo;
|
|
263
|
-
echo -n "carrier_changes: "; cat /sys/class/net/${ifaceSanitized}/carrier_changes 2>/dev/null; echo;
|
|
264
|
-
echo -n "dev_id: "; cat /sys/class/net/${ifaceSanitized}/dev_id 2>/dev/null; echo;
|
|
265
|
-
echo -n "dev_port: "; cat /sys/class/net/${ifaceSanitized}/dev_port 2>/dev/null; echo;
|
|
266
|
-
echo -n "dormant: "; cat /sys/class/net/${ifaceSanitized}/dormant 2>/dev/null; echo;
|
|
267
|
-
echo -n "duplex: "; cat /sys/class/net/${ifaceSanitized}/duplex 2>/dev/null; echo;
|
|
268
|
-
echo -n "flags: "; cat /sys/class/net/${ifaceSanitized}/flags 2>/dev/null; echo;
|
|
269
|
-
echo -n "gro_flush_timeout: "; cat /sys/class/net/${ifaceSanitized}/gro_flush_timeout 2>/dev/null; echo;
|
|
270
|
-
echo -n "ifalias: "; cat /sys/class/net/${ifaceSanitized}/ifalias 2>/dev/null; echo;
|
|
271
|
-
echo -n "ifindex: "; cat /sys/class/net/${ifaceSanitized}/ifindex 2>/dev/null; echo;
|
|
272
|
-
echo -n "iflink: "; cat /sys/class/net/${ifaceSanitized}/iflink 2>/dev/null; echo;
|
|
273
|
-
echo -n "link_mode: "; cat /sys/class/net/${ifaceSanitized}/link_mode 2>/dev/null; echo;
|
|
274
|
-
echo -n "mtu: "; cat /sys/class/net/${ifaceSanitized}/mtu 2>/dev/null; echo;
|
|
275
|
-
echo -n "netdev_group: "; cat /sys/class/net/${ifaceSanitized}/netdev_group 2>/dev/null; echo;
|
|
276
|
-
echo -n "operstate: "; cat /sys/class/net/${ifaceSanitized}/operstate 2>/dev/null; echo;
|
|
277
|
-
echo -n "proto_down: "; cat /sys/class/net/${ifaceSanitized}/proto_down 2>/dev/null; echo;
|
|
278
|
-
echo -n "speed: "; cat /sys/class/net/${ifaceSanitized}/speed 2>/dev/null; echo;
|
|
279
|
-
echo -n "tx_queue_len: "; cat /sys/class/net/${ifaceSanitized}/tx_queue_len 2>/dev/null; echo;
|
|
280
|
-
echo -n "type: "; cat /sys/class/net/${ifaceSanitized}/type 2>/dev/null; echo;
|
|
281
|
-
echo -n "wireless: "; cat /proc/net/wireless 2>/dev/null | grep ${ifaceSanitized}; echo;
|
|
282
|
-
echo -n "wirelessspeed: "; iw dev ${ifaceSanitized} link 2>&1 | grep bitrate; echo;`;
|
|
271
|
+
const ifaceSanitized = (0, security_1.sanitizeString)(ifaceDevName, true);
|
|
283
272
|
let lines = [];
|
|
284
273
|
try {
|
|
285
|
-
const
|
|
286
|
-
|
|
287
|
-
|
|
274
|
+
const [sysfsLines, wirelessLines, iwOut] = await Promise.all([
|
|
275
|
+
(0, security_1.isSafePathSegment)(ifaceSanitized) ? (0, files_1.readSysfsMany)(`/sys/class/net/${ifaceSanitized}`, ['address', 'carrier_changes', 'duplex', 'mtu', 'operstate', 'speed', 'type']) : [],
|
|
276
|
+
(0, files_1.readFileLines)('/proc/net/wireless'),
|
|
277
|
+
(0, exec_1.execSecure)('iw', ['dev', ifaceSanitized, 'link'])
|
|
278
|
+
]);
|
|
279
|
+
lines = sysfsLines;
|
|
280
|
+
lines.push(`wireless: ${wirelessLines.find((line) => line.indexOf(ifaceSanitized) >= 0) || ''}`);
|
|
281
|
+
lines.push(...iwOut.split('\n').filter((line) => line.indexOf('bitrate') >= 0).map((line) => line.trim()));
|
|
282
|
+
const connectionName = getLinuxIfaceConnectionName(deviceStatus, ifaceSanitized);
|
|
288
283
|
dhcp = await getLinuxIfaceDHCPstatus(ifaceSanitized, connectionName, _dhcpNics);
|
|
289
284
|
dnsSuffix = await getLinuxIfaceDNSsuffix(connectionName);
|
|
290
285
|
ieee8021xAuth = await getLinuxIfaceIEEE8021xAuth(connectionName);
|
|
@@ -292,7 +287,6 @@ const networkInterfaces = async (defaultString = '', rescan = true) => {
|
|
|
292
287
|
}
|
|
293
288
|
catch { }
|
|
294
289
|
duplex = (0, common_1.getValue)(lines, 'duplex');
|
|
295
|
-
duplex = duplex.startsWith('cat') ? '' : duplex;
|
|
296
290
|
mtu = (0, common_1.toInt)((0, common_1.getValue)(lines, 'mtu'));
|
|
297
291
|
let myspeed = (0, common_1.toInt)((0, common_1.getValue)(lines, 'speed'));
|
|
298
292
|
speed = Number.isNaN(myspeed) ? null : myspeed;
|
|
@@ -301,9 +295,12 @@ const networkInterfaces = async (defaultString = '', rescan = true) => {
|
|
|
301
295
|
myspeed = Number.parseFloat(wirelessspeed);
|
|
302
296
|
speed = Number.isNaN(myspeed) ? null : myspeed;
|
|
303
297
|
}
|
|
298
|
+
if (!mac) {
|
|
299
|
+
mac = (0, common_1.getValue)(lines, 'address');
|
|
300
|
+
}
|
|
304
301
|
carrierChanges = (0, common_1.toInt)((0, common_1.getValue)(lines, 'carrier_changes'));
|
|
305
302
|
const operstate = (0, common_1.getValue)(lines, 'operstate');
|
|
306
|
-
type =
|
|
303
|
+
type = (0, common_1.getValue)(lines, 'wireless').trim() ? 'wireless' : (0, common_1.toInt)((0, common_1.getValue)(lines, 'type')) === 1 ? 'wired' : 'unknown';
|
|
307
304
|
if (ifaceSanitized === 'lo' || ifaceSanitized.startsWith('bond')) {
|
|
308
305
|
type = 'virtual';
|
|
309
306
|
}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.networkStats = void 0;
|
|
4
4
|
const files_1 = require("../common/files");
|
|
5
|
-
const exec_1 = require("../common/exec");
|
|
6
5
|
const common_1 = require("../common");
|
|
7
6
|
const security_1 = require("../common/security");
|
|
8
7
|
const defaults_1 = require("../common/defaults");
|
|
@@ -11,42 +10,15 @@ const network_1 = require("../common/network");
|
|
|
11
10
|
const _network = {};
|
|
12
11
|
const networkStatsSingle = async (iface) => {
|
|
13
12
|
await (0, common_1.nextTick)();
|
|
14
|
-
const defaults = defaults_1.initNetworkSpeed;
|
|
13
|
+
const defaults = { ...defaults_1.initNetworkSpeed, iface };
|
|
15
14
|
if (!_network[iface] || (_network[iface] && !_network[iface].ms) || (_network[iface] && _network[iface].ms && Date.now() - _network[iface].ms >= 500)) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
'/operstate
|
|
20
|
-
'
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
'cat /sys/class/net/' +
|
|
24
|
-
iface +
|
|
25
|
-
'/statistics/tx_bytes; ' +
|
|
26
|
-
'cat /sys/class/net/' +
|
|
27
|
-
iface +
|
|
28
|
-
'/statistics/rx_dropped; ' +
|
|
29
|
-
'cat /sys/class/net/' +
|
|
30
|
-
iface +
|
|
31
|
-
'/statistics/rx_errors; ' +
|
|
32
|
-
'cat /sys/class/net/' +
|
|
33
|
-
iface +
|
|
34
|
-
'/statistics/tx_dropped; ' +
|
|
35
|
-
'cat /sys/class/net/' +
|
|
36
|
-
iface +
|
|
37
|
-
'/statistics/tx_errors; ';
|
|
38
|
-
const { stdout } = await (0, exec_1.execSave)(cmd);
|
|
39
|
-
if (stdout) {
|
|
40
|
-
const lines = stdout.split('\n');
|
|
41
|
-
const operstate = lines[0].trim();
|
|
42
|
-
const rx_bytes = (0, common_1.toInt)(lines[1]);
|
|
43
|
-
const tx_bytes = (0, common_1.toInt)(lines[2]);
|
|
44
|
-
const rx_dropped = (0, common_1.toInt)(lines[3]);
|
|
45
|
-
const rx_errors = (0, common_1.toInt)(lines[4]);
|
|
46
|
-
const tx_dropped = (0, common_1.toInt)(lines[5]);
|
|
47
|
-
const tx_errors = (0, common_1.toInt)(lines[6]);
|
|
48
|
-
return (0, network_1.calcNetworkSpeed)(iface, rx_bytes, tx_bytes, rx_dropped, rx_errors, tx_dropped, tx_errors, operstate, _network);
|
|
49
|
-
}
|
|
15
|
+
const dir = '/sys/class/net/' + iface;
|
|
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([
|
|
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)))
|
|
20
|
+
]);
|
|
21
|
+
return (0, network_1.calcNetworkSpeed)(iface, rx_bytes, tx_bytes, rx_dropped, rx_errors, tx_dropped, tx_errors, operstate, _network);
|
|
50
22
|
}
|
|
51
23
|
return defaults;
|
|
52
24
|
}
|
package/dist/linux/npu.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.npu = void 0;
|
|
|
4
4
|
const promises_1 = require("node:fs/promises");
|
|
5
5
|
const common_1 = require("../common");
|
|
6
6
|
const defaults_1 = require("../common/defaults");
|
|
7
|
+
const security_1 = require("../common/security");
|
|
7
8
|
const ACCEL_PATH = '/sys/class/accel';
|
|
8
9
|
const readAttr = async (path) => {
|
|
9
10
|
try {
|
|
@@ -41,7 +42,7 @@ const npu = async () => {
|
|
|
41
42
|
const result = [];
|
|
42
43
|
const seen = new Set();
|
|
43
44
|
try {
|
|
44
|
-
const nodes = (await (0, promises_1.readdir)(ACCEL_PATH)).filter((node) => node.startsWith('accel')).sort();
|
|
45
|
+
const nodes = (await (0, promises_1.readdir)(ACCEL_PATH)).filter((node) => node.startsWith('accel') && (0, security_1.isSafePathSegment)(node)).sort();
|
|
45
46
|
for (const node of nodes) {
|
|
46
47
|
let dev;
|
|
47
48
|
try {
|