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/linux/displays.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.displays = void 0;
|
|
3
|
+
exports.displays = exports.drmDisplays = exports.drmConnectorInfo = exports.parseDrmDevicePath = exports.normalizeDrmConnector = exports.dpmsToPowerState = void 0;
|
|
4
|
+
const promises_1 = require("node:fs/promises");
|
|
5
|
+
const node_path_1 = require("node:path");
|
|
4
6
|
const common_1 = require("../common");
|
|
5
7
|
const const_1 = require("../common/const");
|
|
6
8
|
const defaults_1 = require("../common/defaults");
|
|
7
9
|
const exec_1 = require("../common/exec");
|
|
10
|
+
const files_1 = require("../common/files");
|
|
8
11
|
const index_1 = require("../common/index");
|
|
9
12
|
const raspberry_1 = require("../common/raspberry");
|
|
13
|
+
const security_1 = require("../common/security");
|
|
10
14
|
const parseLinesLinuxEdid = (edid) => {
|
|
11
15
|
const result = (0, index_1.cloneObj)(defaults_1.initDisplay);
|
|
12
16
|
let start = 108;
|
|
@@ -135,8 +139,138 @@ const parseLinesLinuxDisplays = (lines, depth) => {
|
|
|
135
139
|
currentDisplay.resolutionX !== null) {
|
|
136
140
|
displays.push(currentDisplay);
|
|
137
141
|
}
|
|
142
|
+
displays.forEach((display, i) => {
|
|
143
|
+
display.mirror = displays.some((other, j) => j !== i && other.positionX === display.positionX && other.positionY === display.positionY && other.currentResX === display.currentResX && other.currentResY === display.currentResY);
|
|
144
|
+
});
|
|
138
145
|
return displays;
|
|
139
146
|
};
|
|
147
|
+
const getWorkAreaLinux = async (displays) => {
|
|
148
|
+
try {
|
|
149
|
+
const { stdout } = await (0, exec_1.execSave)('xprop -root _NET_WORKAREA 2>/dev/null');
|
|
150
|
+
const values = (stdout.toString().split('=')[1] || '').split(',').map((value) => (0, common_1.toInt)(value));
|
|
151
|
+
const [areaX, areaY, areaWidth, areaHeight] = values;
|
|
152
|
+
if (values.length < 4 || !areaWidth || !areaHeight) {
|
|
153
|
+
return displays;
|
|
154
|
+
}
|
|
155
|
+
displays.forEach((display) => {
|
|
156
|
+
const width = display.currentResX || display.resolutionX;
|
|
157
|
+
const height = display.currentResY || display.resolutionY;
|
|
158
|
+
if (!width || !height) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const left = Math.max(display.positionX, areaX);
|
|
162
|
+
const top = Math.max(display.positionY, areaY);
|
|
163
|
+
const right = Math.min(display.positionX + width, areaX + areaWidth);
|
|
164
|
+
const bottom = Math.min(display.positionY + height, areaY + areaHeight);
|
|
165
|
+
if (right > left && bottom > top) {
|
|
166
|
+
display.workAreaResolutionX = right - left;
|
|
167
|
+
display.workAreaResolutionY = bottom - top;
|
|
168
|
+
display.workAreaPositionX = left;
|
|
169
|
+
display.workAreaPositionY = top;
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
catch { }
|
|
174
|
+
return displays;
|
|
175
|
+
};
|
|
176
|
+
const dpmsToPowerState = (value) => {
|
|
177
|
+
const state = value.trim().toLowerCase();
|
|
178
|
+
return state === 'on' || state === 'off' || state === 'standby' || state === 'suspend' ? state : '';
|
|
179
|
+
};
|
|
180
|
+
exports.dpmsToPowerState = dpmsToPowerState;
|
|
181
|
+
const normalizeDrmConnector = (name) => name.replace(/^card\d+-/, '').replace(/^(HDMI|DVI)-[AB]-/i, '$1-').toLowerCase();
|
|
182
|
+
exports.normalizeDrmConnector = normalizeDrmConnector;
|
|
183
|
+
const parseDrmDevicePath = (target) => {
|
|
184
|
+
const address = (target.split('/').pop() || '').replace(/^0000:/, '');
|
|
185
|
+
return /^[\da-f]{2}:[\da-f]{2}\.[\da-f]$/i.test(address) ? address : '';
|
|
186
|
+
};
|
|
187
|
+
exports.parseDrmDevicePath = parseDrmDevicePath;
|
|
188
|
+
const drmConnectorInfo = async (path = '/sys/class/drm') => {
|
|
189
|
+
const result = new Map();
|
|
190
|
+
let connectors = [];
|
|
191
|
+
try {
|
|
192
|
+
connectors = (await (0, promises_1.readdir)(path)).filter((name) => /^card\d+-/.test(name) && (0, security_1.isSafePathSegment)(name));
|
|
193
|
+
}
|
|
194
|
+
catch {
|
|
195
|
+
return result;
|
|
196
|
+
}
|
|
197
|
+
const busAddresses = new Map();
|
|
198
|
+
for (const connector of connectors) {
|
|
199
|
+
const card = connector.replace(/-.*$/, '');
|
|
200
|
+
if (!busAddresses.has(card)) {
|
|
201
|
+
busAddresses.set(card, (0, exports.parseDrmDevicePath)(await (0, promises_1.readlink)((0, node_path_1.join)(path, card, 'device')).catch(() => '')));
|
|
202
|
+
}
|
|
203
|
+
result.set((0, exports.normalizeDrmConnector)(connector), {
|
|
204
|
+
powerState: (0, exports.dpmsToPowerState)(await (0, files_1.readSysfs)((0, node_path_1.join)(path, connector, 'dpms'))),
|
|
205
|
+
gpuBusAddress: busAddresses.get(card) || ''
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
return result;
|
|
209
|
+
};
|
|
210
|
+
exports.drmConnectorInfo = drmConnectorInfo;
|
|
211
|
+
const applyDrmInfo = async (displays) => {
|
|
212
|
+
const info = await (0, exports.drmConnectorInfo)();
|
|
213
|
+
if (!info.size) {
|
|
214
|
+
return displays;
|
|
215
|
+
}
|
|
216
|
+
const single = (pick) => {
|
|
217
|
+
const values = new Set([...info.values()].map(pick).filter(Boolean));
|
|
218
|
+
return values.size === 1 ? [...values][0] : '';
|
|
219
|
+
};
|
|
220
|
+
const powerStateFallback = single((entry) => entry.powerState);
|
|
221
|
+
const busAddressFallback = single((entry) => entry.gpuBusAddress);
|
|
222
|
+
for (const display of displays) {
|
|
223
|
+
const entry = info.get((0, exports.normalizeDrmConnector)(display.connection || ''));
|
|
224
|
+
display.powerState = (entry && entry.powerState) || powerStateFallback;
|
|
225
|
+
display.gpuBusAddress = (entry && entry.gpuBusAddress) || busAddressFallback;
|
|
226
|
+
}
|
|
227
|
+
return displays;
|
|
228
|
+
};
|
|
229
|
+
const drmDisplays = async (path = '/sys/class/drm') => {
|
|
230
|
+
const result = [];
|
|
231
|
+
let connectors = [];
|
|
232
|
+
try {
|
|
233
|
+
connectors = (await (0, promises_1.readdir)(path)).filter((name) => /^card\d+-/.test(name) && (0, security_1.isSafePathSegment)(name)).sort();
|
|
234
|
+
}
|
|
235
|
+
catch {
|
|
236
|
+
return result;
|
|
237
|
+
}
|
|
238
|
+
for (const connector of connectors) {
|
|
239
|
+
const dir = (0, node_path_1.join)(path, connector);
|
|
240
|
+
if ((await (0, files_1.readSysfs)((0, node_path_1.join)(dir, 'status'))) !== 'connected') {
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
243
|
+
const display = (0, index_1.cloneObj)(defaults_1.initDisplay);
|
|
244
|
+
display.connection = connector.replace(/^card\d+-/, '');
|
|
245
|
+
display.builtin = /^(edp|lvds|dsi)/i.test(display.connection);
|
|
246
|
+
display.positionX = 0;
|
|
247
|
+
display.positionY = 0;
|
|
248
|
+
const mode = (await (0, files_1.readSysfs)((0, node_path_1.join)(dir, 'modes'))).split('\n')[0].split('x');
|
|
249
|
+
if (mode.length === 2) {
|
|
250
|
+
display.currentResX = (0, common_1.toInt)(mode[0]);
|
|
251
|
+
display.currentResY = (0, common_1.toInt)(mode[1]);
|
|
252
|
+
}
|
|
253
|
+
try {
|
|
254
|
+
const edid = (await (0, promises_1.readFile)((0, node_path_1.join)(dir, 'edid'))).toString('hex');
|
|
255
|
+
if (edid) {
|
|
256
|
+
const decoded = parseLinesLinuxEdid(edid);
|
|
257
|
+
display.model = decoded.model;
|
|
258
|
+
display.resolutionX = decoded.resolutionX;
|
|
259
|
+
display.resolutionY = decoded.resolutionY;
|
|
260
|
+
display.sizeX = decoded.sizeX;
|
|
261
|
+
display.sizeY = decoded.sizeY;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
catch { }
|
|
265
|
+
result.push(display);
|
|
266
|
+
}
|
|
267
|
+
const main = result.find((display) => display.builtin) || result[0];
|
|
268
|
+
if (main) {
|
|
269
|
+
main.main = true;
|
|
270
|
+
}
|
|
271
|
+
return result;
|
|
272
|
+
};
|
|
273
|
+
exports.drmDisplays = drmDisplays;
|
|
140
274
|
const displays = async () => {
|
|
141
275
|
await (0, common_1.nextTick)();
|
|
142
276
|
const result = [];
|
|
@@ -148,6 +282,9 @@ const displays = async () => {
|
|
|
148
282
|
const parts = lines[0].replace('mode', '').replace(/"/g, '').trim().split('x');
|
|
149
283
|
if (parts.length === 2) {
|
|
150
284
|
result.push({
|
|
285
|
+
powerState: '',
|
|
286
|
+
gpu: '',
|
|
287
|
+
gpuBusAddress: '',
|
|
151
288
|
vendor: '',
|
|
152
289
|
vendorId: null,
|
|
153
290
|
model: (0, common_1.getValue)(lines, 'device_name', '='),
|
|
@@ -156,6 +293,7 @@ const displays = async () => {
|
|
|
156
293
|
deviceName: '',
|
|
157
294
|
displayId: null,
|
|
158
295
|
main: true,
|
|
296
|
+
mirror: false,
|
|
159
297
|
builtin: false,
|
|
160
298
|
connection: 'HDMI',
|
|
161
299
|
sizeX: null,
|
|
@@ -167,7 +305,12 @@ const displays = async () => {
|
|
|
167
305
|
currentResY: null,
|
|
168
306
|
positionX: 0,
|
|
169
307
|
positionY: 0,
|
|
170
|
-
|
|
308
|
+
workAreaResolutionX: null,
|
|
309
|
+
workAreaResolutionY: null,
|
|
310
|
+
workAreaPositionX: null,
|
|
311
|
+
workAreaPositionY: null,
|
|
312
|
+
currentRefreshRate: null,
|
|
313
|
+
scale: null
|
|
171
314
|
});
|
|
172
315
|
}
|
|
173
316
|
}
|
|
@@ -181,13 +324,17 @@ const displays = async () => {
|
|
|
181
324
|
try {
|
|
182
325
|
({ stdout } = await (0, exec_1.exec)('xrandr --verbose 2>/dev/null', const_1.execOptsLinux));
|
|
183
326
|
const lines = stdout.toString().split('\n');
|
|
184
|
-
|
|
327
|
+
const xrandrDisplays = parseLinesLinuxDisplays(lines, depth);
|
|
328
|
+
if (xrandrDisplays.length) {
|
|
329
|
+
return await applyDrmInfo(await getWorkAreaLinux(xrandrDisplays));
|
|
330
|
+
}
|
|
185
331
|
}
|
|
186
332
|
catch { }
|
|
187
333
|
}
|
|
188
334
|
catch { }
|
|
189
335
|
}
|
|
190
336
|
catch { }
|
|
191
|
-
|
|
337
|
+
const drm = await (0, exports.drmDisplays)();
|
|
338
|
+
return await applyDrmInfo(drm.length ? drm : result);
|
|
192
339
|
};
|
|
193
340
|
exports.displays = displays;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fans = void 0;
|
|
4
|
+
const promises_1 = require("fs/promises");
|
|
5
|
+
const common_1 = require("../common");
|
|
6
|
+
const files_1 = require("../common/files");
|
|
7
|
+
const security_1 = require("../common/security");
|
|
8
|
+
const toNumber = (value) => {
|
|
9
|
+
const result = Number.parseFloat(value);
|
|
10
|
+
return Number.isNaN(result) ? null : result;
|
|
11
|
+
};
|
|
12
|
+
const pwmToPercent = (value) => {
|
|
13
|
+
const raw = toNumber(value);
|
|
14
|
+
return raw === null ? null : Math.round((raw / 255) * 100);
|
|
15
|
+
};
|
|
16
|
+
const hwmonFans = async (hwmonPath) => {
|
|
17
|
+
const fans = [];
|
|
18
|
+
let nodes = [];
|
|
19
|
+
try {
|
|
20
|
+
nodes = (await (0, promises_1.readdir)(hwmonPath)).filter(security_1.isSafePathSegment);
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return fans;
|
|
24
|
+
}
|
|
25
|
+
for (const node of nodes) {
|
|
26
|
+
const entries = [];
|
|
27
|
+
try {
|
|
28
|
+
entries.push(...(await (0, promises_1.readdir)(`${hwmonPath}/${node}`)));
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
const source = (await (0, files_1.readSysfs)(`${hwmonPath}/${node}/name`)) || node;
|
|
34
|
+
for (const entry of entries) {
|
|
35
|
+
const match = /^fan(\d+)_input$/.exec(entry);
|
|
36
|
+
if (!match) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
const index = match[1];
|
|
40
|
+
const rpm = toNumber(await (0, files_1.readSysfs)(`${hwmonPath}/${node}/fan${index}_input`));
|
|
41
|
+
if (rpm === null) {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
fans.push({
|
|
45
|
+
id: `${node}/fan${index}`,
|
|
46
|
+
label: (await (0, files_1.readSysfs)(`${hwmonPath}/${node}/fan${index}_label`)) || null,
|
|
47
|
+
rpm,
|
|
48
|
+
pwm: pwmToPercent(await (0, files_1.readSysfs)(`${hwmonPath}/${node}/pwm${index}`)),
|
|
49
|
+
source
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return fans;
|
|
54
|
+
};
|
|
55
|
+
const coolingDeviceFans = async (thermalPath) => {
|
|
56
|
+
const fans = [];
|
|
57
|
+
let nodes = [];
|
|
58
|
+
try {
|
|
59
|
+
nodes = (await (0, promises_1.readdir)(thermalPath)).filter((entry) => entry.startsWith('cooling_device') && (0, security_1.isSafePathSegment)(entry));
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return fans;
|
|
63
|
+
}
|
|
64
|
+
for (const node of nodes) {
|
|
65
|
+
const type = await (0, files_1.readSysfs)(`${thermalPath}/${node}/type`);
|
|
66
|
+
if (!type.toLowerCase().includes('fan')) {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
const current = toNumber(await (0, files_1.readSysfs)(`${thermalPath}/${node}/cur_state`));
|
|
70
|
+
const max = toNumber(await (0, files_1.readSysfs)(`${thermalPath}/${node}/max_state`));
|
|
71
|
+
if (current === null || !max) {
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
fans.push({
|
|
75
|
+
id: node,
|
|
76
|
+
label: null,
|
|
77
|
+
rpm: null,
|
|
78
|
+
pwm: Math.round((current / max) * 100),
|
|
79
|
+
source: type
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
return fans;
|
|
83
|
+
};
|
|
84
|
+
const fans = async (hwmonPath = '/sys/class/hwmon', thermalPath = '/sys/class/thermal') => {
|
|
85
|
+
await (0, common_1.nextTick)();
|
|
86
|
+
const result = await hwmonFans(hwmonPath);
|
|
87
|
+
if (!result.length) {
|
|
88
|
+
return coolingDeviceFans(thermalPath);
|
|
89
|
+
}
|
|
90
|
+
return result;
|
|
91
|
+
};
|
|
92
|
+
exports.fans = fans;
|
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
|
@@ -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 = [];
|
|
8
|
-
let
|
|
11
|
+
let macOsFsTypes = new Map();
|
|
12
|
+
let osMounts = Object.create(null);
|
|
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,12 +64,12 @@ 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
|
-
const size = (0, common_1.toInt)(match[withType ? 3 : 2]) * 1024;
|
|
60
70
|
const used = (0, common_1.toInt)(match[withType ? 4 : 3]) * 1024;
|
|
61
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;
|
|
62
73
|
const use = parseFloat((100.0 * (used / (used + available))).toFixed(2));
|
|
63
74
|
const rw = osMounts && Object.keys(osMounts).length > 0 ? osMounts[fs] || false : null;
|
|
64
75
|
if (!data.find((el) => el.fs === fs && el.type === fsType && el.mount === mount)) {
|
|
@@ -78,6 +89,128 @@ 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 rawSize = stats.blocks * stats.bsize;
|
|
147
|
+
if (!rawSize) {
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
const used = (stats.blocks - stats.bfree) * stats.bsize;
|
|
151
|
+
const available = stats.bavail * stats.bsize;
|
|
152
|
+
const size = type === 'btrfs' ? used + available : rawSize;
|
|
153
|
+
const item = {
|
|
154
|
+
dev,
|
|
155
|
+
entry: {
|
|
156
|
+
fs,
|
|
157
|
+
type,
|
|
158
|
+
size,
|
|
159
|
+
used,
|
|
160
|
+
available,
|
|
161
|
+
use: parseFloat((100.0 * (used / (used + available))).toFixed(2)),
|
|
162
|
+
mount,
|
|
163
|
+
rw: osMountsKnown ? osMounts[fs] || false : null
|
|
164
|
+
},
|
|
165
|
+
trusted: statfsSafeTypes.includes(type)
|
|
166
|
+
};
|
|
167
|
+
const duplicate = data.findIndex((el) => el.dev === dev);
|
|
168
|
+
if (duplicate >= 0) {
|
|
169
|
+
if (data[duplicate].entry.mount.length > mount.length) {
|
|
170
|
+
data[duplicate] = item;
|
|
171
|
+
}
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
data.push(item);
|
|
175
|
+
}
|
|
176
|
+
catch { }
|
|
177
|
+
}
|
|
178
|
+
if (!data.length) {
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
const requested = data.filter((item) => matchesDrives(item.entry.fs, item.entry.mount, drives));
|
|
182
|
+
if (requested.some((item) => !item.trusted)) {
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
return requested.map((item) => item.entry);
|
|
186
|
+
};
|
|
187
|
+
const matchesDrives = (fs, mount, drives) => {
|
|
188
|
+
if (!drives.length) {
|
|
189
|
+
return true;
|
|
190
|
+
}
|
|
191
|
+
return drives.some((drive) => typeof drive === 'string' && (fs.toLowerCase().indexOf(drive.toLowerCase()) >= 0 || mount.toLowerCase().indexOf(drive.toLowerCase()) >= 0));
|
|
192
|
+
};
|
|
193
|
+
const applyZfsUsage = async (data) => {
|
|
194
|
+
if (!data.some((item) => item.type === 'zfs')) {
|
|
195
|
+
return data;
|
|
196
|
+
}
|
|
197
|
+
const { byMount, byName } = await (0, filesys_1.zfsDatasets)();
|
|
198
|
+
for (const item of data) {
|
|
199
|
+
if (item.type !== 'zfs') {
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
const dataset = byName.get(item.fs) || byMount.get(item.mount);
|
|
203
|
+
if (!dataset || !(dataset.used + dataset.available)) {
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
item.used = dataset.used;
|
|
207
|
+
item.available = dataset.available;
|
|
208
|
+
item.size = dataset.used + dataset.available;
|
|
209
|
+
item.use = parseFloat(((100.0 * dataset.used) / item.size).toFixed(2));
|
|
210
|
+
}
|
|
211
|
+
return data;
|
|
212
|
+
};
|
|
213
|
+
const filterDrives = (data, drives) => data.filter((item) => matchesDrives(item.fs, item.mount, drives));
|
|
81
214
|
const fsSize = async (drives) => {
|
|
82
215
|
await (0, common_1.nextTick)();
|
|
83
216
|
let data = [];
|
|
@@ -86,7 +219,8 @@ const fsSize = async (drives) => {
|
|
|
86
219
|
let stderr = '';
|
|
87
220
|
let lines = [];
|
|
88
221
|
macOsDisks = [];
|
|
89
|
-
|
|
222
|
+
macOsFsTypes = new Map();
|
|
223
|
+
osMounts = Object.create(null);
|
|
90
224
|
if (const_1.DARWIN) {
|
|
91
225
|
cmd = 'df -kP';
|
|
92
226
|
try {
|
|
@@ -95,35 +229,35 @@ const fsSize = async (drives) => {
|
|
|
95
229
|
return !line.startsWith('/') && line.indexOf(':') > 0;
|
|
96
230
|
});
|
|
97
231
|
({ stdout } = await (0, exec_1.exec)('mount', const_1.execOptsLinux));
|
|
98
|
-
stdout
|
|
99
|
-
.split('
|
|
100
|
-
.
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
232
|
+
stdout.split('\n').forEach((line) => {
|
|
233
|
+
const fs = line.split(' on ')[0];
|
|
234
|
+
const type = line.match(/\(([^),]+)[^)]*\)$/);
|
|
235
|
+
if (fs && type) {
|
|
236
|
+
macOsFsTypes.set(fs, type[1].trim().toLowerCase());
|
|
237
|
+
}
|
|
238
|
+
if (line.startsWith('/')) {
|
|
239
|
+
osMounts[fs] = line.toLowerCase().indexOf('read-only') === -1;
|
|
240
|
+
}
|
|
105
241
|
});
|
|
106
242
|
}
|
|
107
243
|
catch { }
|
|
108
244
|
}
|
|
109
245
|
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
|
-
});
|
|
246
|
+
for (const line of await (0, files_1.readFileLines)('/proc/mounts')) {
|
|
247
|
+
if (!line.startsWith('/')) {
|
|
248
|
+
continue;
|
|
249
|
+
}
|
|
250
|
+
const fs = unescapeMount(line.split(' ')[0]);
|
|
251
|
+
osMounts[fs] = osMounts[fs] || false;
|
|
252
|
+
if (line.indexOf('/snap/') === -1) {
|
|
253
|
+
osMounts[fs] = line.toLowerCase().indexOf('rw,') >= 0 || line.toLowerCase().indexOf(' rw ') >= 0;
|
|
254
|
+
}
|
|
125
255
|
}
|
|
126
|
-
|
|
256
|
+
const linuxData = await linuxFsSize(drives);
|
|
257
|
+
if (linuxData) {
|
|
258
|
+
return await applyZfsUsage(linuxData);
|
|
259
|
+
}
|
|
260
|
+
cmd = 'export LC_ALL=C.UTF-8; df -kPTx squashfs; unset LC_ALL';
|
|
127
261
|
}
|
|
128
262
|
if (const_1.FREEBSD || const_1.NETBSD || const_1.OPENBSD) {
|
|
129
263
|
try {
|
|
@@ -135,23 +269,16 @@ const fsSize = async (drives) => {
|
|
|
135
269
|
}
|
|
136
270
|
catch { }
|
|
137
271
|
}
|
|
138
|
-
({ stdout, stderr } = await (0, exec_1.
|
|
272
|
+
({ stdout, stderr } = await (0, exec_1.execSave)(cmd, const_1.execOptsLinux));
|
|
139
273
|
if (!stderr) {
|
|
140
274
|
lines = filterFsLines(stdout);
|
|
141
275
|
data = parseNixFsSize(lines);
|
|
142
276
|
}
|
|
143
277
|
else {
|
|
144
|
-
({ stdout } = await (0, exec_1.
|
|
278
|
+
({ stdout } = await (0, exec_1.execSave)('df -kPT 2>/dev/null', const_1.execOptsLinux));
|
|
145
279
|
lines = filterFsLines(stdout);
|
|
146
280
|
data = parseNixFsSize(lines);
|
|
147
281
|
}
|
|
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;
|
|
282
|
+
return await applyZfsUsage(filterDrives(data, drives));
|
|
156
283
|
};
|
|
157
284
|
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.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { GpuData } from '../common/types';
|
|
2
2
|
type DrmMetrics = {
|
|
3
3
|
busAddress: string;
|
|
4
|
+
sharedMemory: boolean;
|
|
4
5
|
utilizationGpu: number | null;
|
|
5
6
|
memoryTotal: number | null;
|
|
6
7
|
memoryUsed: number | null;
|
|
@@ -10,6 +11,7 @@ type DrmMetrics = {
|
|
|
10
11
|
clockCore: number | null;
|
|
11
12
|
};
|
|
12
13
|
export declare const drmDevices: (drmPath?: string) => Promise<DrmMetrics[]>;
|
|
14
|
+
export declare const tegraDevice: (root?: string) => Promise<GpuData | null>;
|
|
13
15
|
export declare const mergeControllerDrm: (controller: GpuData, drm?: DrmMetrics) => GpuData;
|
|
14
16
|
export declare const gpu: () => Promise<GpuData[]>;
|
|
15
17
|
export {};
|