systeminformation 6.0.0-beta.14 → 6.0.0-beta.16
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 +9 -4
- package/dist/bsd/mem.js +8 -3
- package/dist/bsd/network-stats.d.ts +1 -1
- package/dist/bsd/network-stats.js +11 -5
- package/dist/bsd/os-info.d.ts +1 -0
- package/dist/common/defaults.js +9 -1
- package/dist/common/exec.js +28 -12
- package/dist/common/filesys.js +3 -3
- package/dist/common/network.d.ts +15 -2
- package/dist/common/network.js +18 -22
- package/dist/common/security.js +9 -3
- package/dist/common/types.d.ts +9 -0
- package/dist/darwin/network-interfaces.js +2 -5
- package/dist/darwin/network-stats.d.ts +1 -1
- package/dist/darwin/network-stats.js +8 -2
- package/dist/darwin/os-info.d.ts +2 -0
- package/dist/darwin/os-info.js +24 -2
- package/dist/darwin/users.js +1 -1
- package/dist/linux/cpu-temperature.js +1 -1
- package/dist/linux/disk-layout.js +2 -2
- package/dist/linux/fs-size.d.ts +1 -1
- package/dist/linux/fs-size.js +3 -3
- package/dist/linux/gpu.d.ts +2 -0
- package/dist/linux/gpu.js +82 -7
- package/dist/linux/mem-layout.js +1 -5
- package/dist/linux/mem.d.ts +1 -0
- package/dist/linux/mem.js +21 -1
- package/dist/linux/network-interfaces.js +68 -94
- package/dist/linux/network-stats.d.ts +1 -1
- package/dist/linux/network-stats.js +9 -7
- package/dist/linux/os-info.js +37 -1
- package/dist/linux/printer.js +1 -1
- package/dist/linux/processes.js +2 -2
- package/dist/linux/users.js +1 -1
- package/dist/linux/wifi-networks.js +2 -2
- package/dist/windows/network-interfaces.js +2 -11
- package/dist/windows/network-stats.js +16 -4
- package/package.json +1 -1
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 {};
|
package/dist/linux/gpu.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.gpu = exports.mergeControllerDrm = exports.drmDevices = void 0;
|
|
3
|
+
exports.gpu = exports.mergeControllerDrm = exports.tegraDevice = exports.drmDevices = void 0;
|
|
4
4
|
const promises_1 = require("fs/promises");
|
|
5
5
|
const common_1 = require("../common");
|
|
6
6
|
const const_1 = require("../common/const");
|
|
@@ -28,6 +28,7 @@ const parseAmdClock = (stdout) => {
|
|
|
28
28
|
const value = line ? Number.parseFloat(line.replace(/^\d+:\s*/, '')) : Number.NaN;
|
|
29
29
|
return Number.isNaN(value) ? null : value;
|
|
30
30
|
};
|
|
31
|
+
const INTEGRATED_DRM_DRIVERS = ['i915', 'xe'];
|
|
31
32
|
const drmDevices = async (drmPath = '/sys/class/drm') => {
|
|
32
33
|
const devices = [];
|
|
33
34
|
let cards = [];
|
|
@@ -50,6 +51,11 @@ const drmDevices = async (drmPath = '/sys/class/drm') => {
|
|
|
50
51
|
if (!/^[\da-f]{2}:[\da-f]{2}\.[\da-f]$/i.test(busAddress)) {
|
|
51
52
|
continue;
|
|
52
53
|
}
|
|
54
|
+
let driver = '';
|
|
55
|
+
try {
|
|
56
|
+
driver = (await (0, promises_1.readlink)(`${devicePath}/driver`)).split('/').pop() || '';
|
|
57
|
+
}
|
|
58
|
+
catch { }
|
|
53
59
|
let hwmon = [];
|
|
54
60
|
try {
|
|
55
61
|
hwmon = (await (0, promises_1.readdir)(`${devicePath}/hwmon`)).filter(security_1.isSafePathSegment).map((node) => `${devicePath}/hwmon/${node}`);
|
|
@@ -63,10 +69,12 @@ const drmDevices = async (drmPath = '/sys/class/drm') => {
|
|
|
63
69
|
`${devicePath}/tile0/gt0/freq0/act_freq`,
|
|
64
70
|
`${devicePath}/tile0/gt0/freq0/cur_freq`
|
|
65
71
|
], 1, true);
|
|
72
|
+
const memoryTotal = await readSysfsNumber([`${devicePath}/mem_info_vram_total`, `${cardPath}/lmem_total_bytes`, `${devicePath}/tile0/physical_vram_size_bytes`], 1024 * 1024, true);
|
|
66
73
|
devices.push({
|
|
67
74
|
busAddress,
|
|
75
|
+
sharedMemory: INTEGRATED_DRM_DRIVERS.includes(driver) && !memoryTotal,
|
|
68
76
|
utilizationGpu: await readSysfsNumber([`${devicePath}/gpu_busy_percent`]),
|
|
69
|
-
memoryTotal
|
|
77
|
+
memoryTotal,
|
|
70
78
|
memoryUsed: await readSysfsNumber([`${devicePath}/mem_info_vram_used`], 1024 * 1024),
|
|
71
79
|
temperatureGpu: await readSysfsNumber(hwmon.map((node) => `${node}/temp1_input`), 1000),
|
|
72
80
|
powerDraw: await readSysfsNumber(hwmon.map((node) => `${node}/power1_input`), 1000000),
|
|
@@ -77,6 +85,65 @@ const drmDevices = async (drmPath = '/sys/class/drm') => {
|
|
|
77
85
|
return devices;
|
|
78
86
|
};
|
|
79
87
|
exports.drmDevices = drmDevices;
|
|
88
|
+
const readDeviceTree = async (file) => (await (0, files_1.readSysfs)(file)).replace(/\0/g, '\n').trim();
|
|
89
|
+
const tegraClock = async (root) => {
|
|
90
|
+
let nodes = [];
|
|
91
|
+
try {
|
|
92
|
+
nodes = (await (0, promises_1.readdir)(`${root}/sys/class/devfreq`)).filter(security_1.isSafePathSegment);
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
const gpuNodes = nodes.filter((node) => /\.(gpu|gm20b|gp10b|gv11b|ga10b)$/.test(node)).sort();
|
|
98
|
+
return await readSysfsNumber(gpuNodes.map((node) => `${root}/sys/class/devfreq/${node}/cur_freq`), 1000000, true);
|
|
99
|
+
};
|
|
100
|
+
const tegraTemperature = async (root) => {
|
|
101
|
+
let zones = [];
|
|
102
|
+
try {
|
|
103
|
+
zones = (await (0, promises_1.readdir)(`${root}/sys/class/thermal`)).filter((zone) => zone.startsWith('thermal_zone') && (0, security_1.isSafePathSegment)(zone)).sort();
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
for (const zone of zones) {
|
|
109
|
+
if ((await (0, files_1.readSysfs)(`${root}/sys/class/thermal/${zone}/type`)).toLowerCase().startsWith('gpu')) {
|
|
110
|
+
return await readSysfsNumber([`${root}/sys/class/thermal/${zone}/temp`], 1000);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return null;
|
|
114
|
+
};
|
|
115
|
+
const tegraSoc = (compatible) => {
|
|
116
|
+
const match = /nvidia,(tegra\d+)/.exec(compatible);
|
|
117
|
+
return match ? match[1].charAt(0).toUpperCase() + match[1].slice(1) : '';
|
|
118
|
+
};
|
|
119
|
+
const tegraDevice = async (root = '') => {
|
|
120
|
+
const compatible = (await readDeviceTree(`${root}/proc/device-tree/compatible`)).toLowerCase();
|
|
121
|
+
if (!compatible.includes('nvidia,tegra')) {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
const model = (await readDeviceTree(`${root}/proc/device-tree/model`)) || tegraSoc(compatible);
|
|
125
|
+
const load = await readSysfsNumber([`${root}/sys/devices/platform/gpu.0/load`, `${root}/sys/devices/gpu.0/load`]);
|
|
126
|
+
const temperatureGpu = await tegraTemperature(root);
|
|
127
|
+
const clockCore = await tegraClock(root);
|
|
128
|
+
const result = {
|
|
129
|
+
vendor: 'NVIDIA',
|
|
130
|
+
model: model || 'Tegra',
|
|
131
|
+
bus: '',
|
|
132
|
+
vram: null,
|
|
133
|
+
vramDynamic: true
|
|
134
|
+
};
|
|
135
|
+
if (load !== null) {
|
|
136
|
+
result.utilizationGpu = Math.min(100, Math.round(load) / 10);
|
|
137
|
+
}
|
|
138
|
+
if (temperatureGpu !== null) {
|
|
139
|
+
result.temperatureGpu = temperatureGpu;
|
|
140
|
+
}
|
|
141
|
+
if (clockCore !== null) {
|
|
142
|
+
result.clockCore = clockCore;
|
|
143
|
+
}
|
|
144
|
+
return result;
|
|
145
|
+
};
|
|
146
|
+
exports.tegraDevice = tegraDevice;
|
|
80
147
|
const mergeControllerDrm = (controller, drm) => {
|
|
81
148
|
if (!drm) {
|
|
82
149
|
return controller;
|
|
@@ -86,10 +153,8 @@ const mergeControllerDrm = (controller, drm) => {
|
|
|
86
153
|
}
|
|
87
154
|
if (controller.memoryTotal === undefined && drm.memoryTotal) {
|
|
88
155
|
controller.memoryTotal = drm.memoryTotal;
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
controller.vramDynamic = false;
|
|
92
|
-
}
|
|
156
|
+
controller.vram = Math.round(drm.memoryTotal);
|
|
157
|
+
controller.vramDynamic = false;
|
|
93
158
|
}
|
|
94
159
|
if (controller.memoryUsed === undefined && drm.memoryUsed !== null) {
|
|
95
160
|
controller.memoryUsed = drm.memoryUsed;
|
|
@@ -109,6 +174,10 @@ const mergeControllerDrm = (controller, drm) => {
|
|
|
109
174
|
if (controller.clockCore === undefined && drm.clockCore !== null) {
|
|
110
175
|
controller.clockCore = drm.clockCore;
|
|
111
176
|
}
|
|
177
|
+
if (drm.sharedMemory) {
|
|
178
|
+
controller.vram = null;
|
|
179
|
+
controller.vramDynamic = true;
|
|
180
|
+
}
|
|
112
181
|
return controller;
|
|
113
182
|
};
|
|
114
183
|
exports.mergeControllerDrm = mergeControllerDrm;
|
|
@@ -127,7 +196,7 @@ const parseLinesLinuxControllers = async (lines) => {
|
|
|
127
196
|
let isGraphicsController = false;
|
|
128
197
|
let pciIDs = [];
|
|
129
198
|
try {
|
|
130
|
-
const { stdout } = await (0, exec_1.exec)('export LC_ALL=C; dmidecode -t 9 2>/dev/null
|
|
199
|
+
const { stdout } = await (0, exec_1.exec)('export LC_ALL=C; dmidecode -t 9 2>/dev/null | grep "Bus Address: "', const_1.execOptsLinux);
|
|
131
200
|
pciIDs = stdout.split('\n');
|
|
132
201
|
for (let i = 0; i < pciIDs.length; i++) {
|
|
133
202
|
pciIDs[i] = pciIDs[i].replace('Bus Address:', '').replace('0000:', '').trim();
|
|
@@ -376,6 +445,12 @@ const gpu = async () => {
|
|
|
376
445
|
catch { }
|
|
377
446
|
}
|
|
378
447
|
catch { }
|
|
448
|
+
if (!result.length) {
|
|
449
|
+
const tegra = await (0, exports.tegraDevice)();
|
|
450
|
+
if (tegra) {
|
|
451
|
+
result.push(tegra);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
379
454
|
}
|
|
380
455
|
catch { }
|
|
381
456
|
return result;
|
package/dist/linux/mem-layout.js
CHANGED
|
@@ -31,11 +31,7 @@ const memLayout = async () => {
|
|
|
31
31
|
channel: null,
|
|
32
32
|
type: (0, common_1.getValue)(lines, 'Type:'),
|
|
33
33
|
ecc: dataWidth && totalWidth ? totalWidth > dataWidth : false,
|
|
34
|
-
clockSpeed: (0, common_1.getValue)(lines, 'Configured Clock Speed:')
|
|
35
|
-
? parseInt((0, common_1.getValue)(lines, 'Configured Clock Speed:'), 10)
|
|
36
|
-
: (0, common_1.getValue)(lines, 'Speed:')
|
|
37
|
-
? parseInt((0, common_1.getValue)(lines, 'Speed:'), 10)
|
|
38
|
-
: null,
|
|
34
|
+
clockSpeed: (0, common_1.toInt)((0, common_1.getValue)(lines, 'Configured Memory Speed:')) || (0, common_1.toInt)((0, common_1.getValue)(lines, 'Configured Clock Speed:')) || (0, common_1.toInt)((0, common_1.getValue)(lines, 'Speed:')) || null,
|
|
39
35
|
formFactor: (0, common_1.getValue)(lines, 'Form Factor:'),
|
|
40
36
|
manufacturer: (0, mappings_1.getMemManufacturer)((0, common_1.getValue)(lines, 'Manufacturer:')),
|
|
41
37
|
partNum: (0, common_1.getValue)(lines, 'Part Number:'),
|
package/dist/linux/mem.d.ts
CHANGED
package/dist/linux/mem.js
CHANGED
|
@@ -1,10 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mem = void 0;
|
|
3
|
+
exports.mem = exports.parseArcstats = void 0;
|
|
4
4
|
const promises_1 = require("node:fs/promises");
|
|
5
5
|
const node_os_1 = require("node:os");
|
|
6
6
|
const common_1 = require("../common");
|
|
7
7
|
const defaults_1 = require("../common/defaults");
|
|
8
|
+
const files_1 = require("../common/files");
|
|
9
|
+
const parseArcstats = (lines) => {
|
|
10
|
+
let size = 0;
|
|
11
|
+
let cMin = 0;
|
|
12
|
+
for (const line of lines) {
|
|
13
|
+
const parts = line.trim().split(/\s+/);
|
|
14
|
+
if (parts.length < 3) {
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
if (parts[0] === 'size') {
|
|
18
|
+
size = (0, common_1.toInt)(parts[2]);
|
|
19
|
+
}
|
|
20
|
+
else if (parts[0] === 'c_min') {
|
|
21
|
+
cMin = (0, common_1.toInt)(parts[2]);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return Math.max(size - cMin, 0);
|
|
25
|
+
};
|
|
26
|
+
exports.parseArcstats = parseArcstats;
|
|
8
27
|
const mem = async () => {
|
|
9
28
|
await (0, common_1.nextTick)();
|
|
10
29
|
const defaults = (0, common_1.cloneObj)(defaults_1.initMemData);
|
|
@@ -25,6 +44,7 @@ const mem = async () => {
|
|
|
25
44
|
const buffcache = buffers + cached + slab;
|
|
26
45
|
let available = (0, common_1.toInt)((0, common_1.getValue)(lines, 'memavailable'));
|
|
27
46
|
available = available ? available * 1024 : free + buffcache;
|
|
47
|
+
available = Math.min(total, available + (0, exports.parseArcstats)(await (0, files_1.readFileLines)('/proc/spl/kstat/zfs/arcstats')));
|
|
28
48
|
const active = total - available;
|
|
29
49
|
let swaptotal = (0, common_1.toInt)((0, common_1.getValue)(lines, 'swaptotal'));
|
|
30
50
|
swaptotal = swaptotal ? swaptotal * 1024 : 0;
|
|
@@ -15,6 +15,9 @@ const security_1 = require("../common/security");
|
|
|
15
15
|
const network_interface_default_1 = require("./network-interface-default");
|
|
16
16
|
const pci_1 = require("./pci");
|
|
17
17
|
const EXEC_OPTS = { timeout: 5000 };
|
|
18
|
+
const EXEC_OPTS_LINUX = { ...const_1.execOptsLinux, ...EXEC_OPTS };
|
|
19
|
+
const EXEC_OPTS_NMCLI = { ...EXEC_OPTS_LINUX, env: { ...process.env, LC_ALL: 'C.UTF-8' } };
|
|
20
|
+
const SCAN_CONCURRENCY = 8;
|
|
18
21
|
let _interfaces = {};
|
|
19
22
|
let _networkInterfaces = [];
|
|
20
23
|
const splitSectionsNics = (lines) => {
|
|
@@ -35,21 +38,36 @@ const splitSectionsNics = (lines) => {
|
|
|
35
38
|
return result;
|
|
36
39
|
};
|
|
37
40
|
const getLinuxDeviceStatus = async () => {
|
|
41
|
+
const result = new Map();
|
|
38
42
|
try {
|
|
39
|
-
const { stdout } = await (0, exec_1.execFile)('nmcli', ['device', 'status'],
|
|
43
|
+
const { stdout } = await (0, exec_1.execFile)('nmcli', ['-t', '-f', 'DEVICE,STATE,CONNECTION', 'device', 'status'], EXEC_OPTS_NMCLI);
|
|
44
|
+
for (const line of stdout.split('\n')) {
|
|
45
|
+
const [device, state, connection] = line.split(/(?<!\\):/).map((part) => part.replace(/\\:/g, ':'));
|
|
46
|
+
if (device && state !== undefined) {
|
|
47
|
+
result.set(device, { state, connection: connection && connection !== '--' ? connection : '' });
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
catch { }
|
|
52
|
+
return result;
|
|
53
|
+
};
|
|
54
|
+
const getLinuxIfaceConnectionName = (deviceStatus, interfaceName) => {
|
|
55
|
+
const device = deviceStatus.get(interfaceName);
|
|
56
|
+
return device && !device.state.includes('externally') ? device.connection : '';
|
|
57
|
+
};
|
|
58
|
+
const getLinuxConnectionDetails = async (connectionName) => {
|
|
59
|
+
if (!connectionName) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
try {
|
|
63
|
+
const { stdout } = await (0, exec_1.execFile)('nmcli', ['connection', 'show', 'id', connectionName], EXEC_OPTS_NMCLI);
|
|
40
64
|
return stdout;
|
|
41
65
|
}
|
|
42
66
|
catch {
|
|
43
|
-
return
|
|
67
|
+
return null;
|
|
44
68
|
}
|
|
45
69
|
};
|
|
46
|
-
const
|
|
47
|
-
const result = (0, common_1.grep)(deviceStatus, interfaceName);
|
|
48
|
-
const resultFormat = result.replace(/\s+/g, ' ').trim();
|
|
49
|
-
const connectionNameLines = resultFormat.split(' ').slice(3);
|
|
50
|
-
const connectionName = connectionNameLines.join(' ');
|
|
51
|
-
return connectionName !== '--' ? connectionName : '';
|
|
52
|
-
};
|
|
70
|
+
const getNmcliValue = (stdout, property) => (0, common_1.grep)(stdout, property).replace(/\s+/g, ' ').trim().split(' ').slice(1).toString();
|
|
53
71
|
const readInterfacesLines = async (file) => {
|
|
54
72
|
if (file.includes('*') || file.includes('?')) {
|
|
55
73
|
try {
|
|
@@ -94,7 +112,7 @@ exports.checkLinuxDCHPInterfaces = checkLinuxDCHPInterfaces;
|
|
|
94
112
|
const getLinuxDHCPNics = async () => {
|
|
95
113
|
let result = [];
|
|
96
114
|
try {
|
|
97
|
-
const { stdout } = await (0, exec_1.exec)('ip a 2> /dev/null',
|
|
115
|
+
const { stdout } = await (0, exec_1.exec)('ip a 2> /dev/null', EXEC_OPTS_LINUX);
|
|
98
116
|
const lines = stdout.split('\n');
|
|
99
117
|
const nsections = splitSectionsNics(lines);
|
|
100
118
|
result = parseLinuxDHCPNics(nsections);
|
|
@@ -125,65 +143,25 @@ const parseLinuxDHCPNics = (sections) => {
|
|
|
125
143
|
}
|
|
126
144
|
return result;
|
|
127
145
|
};
|
|
128
|
-
const getLinuxIfaceDHCPstatus =
|
|
129
|
-
|
|
130
|
-
if (connectionName) {
|
|
131
|
-
try {
|
|
132
|
-
const { stdout } = await (0, exec_1.execFile)('nmcli', ['connection', 'show', connectionName], const_1.execOptsLinux);
|
|
133
|
-
const res = (0, common_1.grep)(stdout, 'ipv4.method');
|
|
134
|
-
const resultFormat = res.replace(/\s+/g, ' ').trim();
|
|
135
|
-
const dhcStatus = resultFormat.split(' ').slice(1).toString();
|
|
136
|
-
switch (dhcStatus) {
|
|
137
|
-
case 'auto':
|
|
138
|
-
result = true;
|
|
139
|
-
break;
|
|
140
|
-
default:
|
|
141
|
-
result = false;
|
|
142
|
-
break;
|
|
143
|
-
}
|
|
144
|
-
return result;
|
|
145
|
-
}
|
|
146
|
-
catch {
|
|
147
|
-
return DHCPNics.indexOf(iface) >= 0;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
else {
|
|
146
|
+
const getLinuxIfaceDHCPstatus = (iface, details, DHCPNics) => {
|
|
147
|
+
if (details === null) {
|
|
151
148
|
return DHCPNics.indexOf(iface) >= 0;
|
|
152
149
|
}
|
|
150
|
+
return getNmcliValue(details, 'ipv4.method') === 'auto';
|
|
153
151
|
};
|
|
154
|
-
const getLinuxIfaceDNSsuffix =
|
|
155
|
-
if (
|
|
156
|
-
try {
|
|
157
|
-
const { stdout } = await (0, exec_1.execFile)('nmcli', ['connection', 'show', connectionName], const_1.execOptsLinux);
|
|
158
|
-
const res = (0, common_1.grep)(stdout, 'ipv4.dns-search');
|
|
159
|
-
const resultFormat = res.replace(/\s+/g, ' ').trim();
|
|
160
|
-
const dnsSuffix = resultFormat.split(' ').slice(1).toString();
|
|
161
|
-
return dnsSuffix === '--' ? 'Not defined' : dnsSuffix;
|
|
162
|
-
}
|
|
163
|
-
catch {
|
|
164
|
-
return 'Unknown';
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
else {
|
|
152
|
+
const getLinuxIfaceDNSsuffix = (details) => {
|
|
153
|
+
if (details === null) {
|
|
168
154
|
return 'Unknown';
|
|
169
155
|
}
|
|
156
|
+
const dnsSuffix = getNmcliValue(details, 'ipv4.dns-search');
|
|
157
|
+
return dnsSuffix === '--' ? 'Not defined' : dnsSuffix;
|
|
170
158
|
};
|
|
171
|
-
const getLinuxIfaceIEEE8021xAuth =
|
|
172
|
-
if (
|
|
173
|
-
try {
|
|
174
|
-
const { stdout } = await (0, exec_1.execFile)('nmcli', ['connection', 'show', connectionName], const_1.execOptsLinux);
|
|
175
|
-
const res = (0, common_1.grep)(stdout, '802-1x.eap');
|
|
176
|
-
const resultFormat = res.replace(/\s+/g, ' ').trim();
|
|
177
|
-
const authenticationProtocol = resultFormat.split(' ').slice(1).toString();
|
|
178
|
-
return authenticationProtocol === '--' ? '' : authenticationProtocol;
|
|
179
|
-
}
|
|
180
|
-
catch {
|
|
181
|
-
return 'Not defined';
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
else {
|
|
159
|
+
const getLinuxIfaceIEEE8021xAuth = (details) => {
|
|
160
|
+
if (details === null) {
|
|
185
161
|
return 'Not defined';
|
|
186
162
|
}
|
|
163
|
+
const authenticationProtocol = getNmcliValue(details, '802-1x.eap');
|
|
164
|
+
return authenticationProtocol === '--' ? '' : authenticationProtocol;
|
|
187
165
|
};
|
|
188
166
|
const getLinuxIfaceIEEE8021xState = (authenticationProtocol) => {
|
|
189
167
|
if (authenticationProtocol) {
|
|
@@ -199,7 +177,7 @@ const getLinuxIfaceIEEE8021xState = (authenticationProtocol) => {
|
|
|
199
177
|
const getLinuxGateways = async () => {
|
|
200
178
|
const result = {};
|
|
201
179
|
try {
|
|
202
|
-
const { stdout } = await (0, exec_1.exec)('ip -4 route show default 2> /dev/null',
|
|
180
|
+
const { stdout } = await (0, exec_1.exec)('ip -4 route show default 2> /dev/null', EXEC_OPTS_LINUX);
|
|
203
181
|
for (const line of stdout.split('\n')) {
|
|
204
182
|
for (const match of line.matchAll(/(?:via\s+(\S+)\s+)?dev\s+(\S+)/g)) {
|
|
205
183
|
if (!result[match[2]]) {
|
|
@@ -260,26 +238,27 @@ const networkInterfaces = async (defaultString = '', rescan = true) => {
|
|
|
260
238
|
await (0, common_1.nextTick)();
|
|
261
239
|
const interfaces = (0, node_os_1.networkInterfaces)();
|
|
262
240
|
if (JSON.stringify(interfaces) === JSON.stringify(_interfaces) && !rescan) {
|
|
263
|
-
return _networkInterfaces;
|
|
241
|
+
return (0, network_1.filterDefaultInterface)(_networkInterfaces, defaultString);
|
|
264
242
|
}
|
|
265
243
|
_interfaces = (0, index_1.cloneObj)(interfaces);
|
|
266
244
|
let result = [];
|
|
267
245
|
try {
|
|
268
|
-
const _dhcpNics = await
|
|
269
|
-
|
|
270
|
-
|
|
246
|
+
const [_dhcpNics, defaultInterface, deviceStatus, gateways, sysfsDevices, wirelessLines] = await Promise.all([
|
|
247
|
+
getLinuxDHCPNics(),
|
|
248
|
+
(0, network_interface_default_1.networkInterfaceDefault)(),
|
|
249
|
+
getLinuxDeviceStatus(),
|
|
250
|
+
getLinuxGateways(),
|
|
251
|
+
(0, promises_1.readdir)('/sys/class/net').catch(() => []),
|
|
252
|
+
(0, files_1.readFileLines)('/proc/net/wireless')
|
|
253
|
+
]);
|
|
271
254
|
const devices = Object.keys(interfaces);
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
devices.push(dev);
|
|
276
|
-
}
|
|
255
|
+
for (const dev of sysfsDevices) {
|
|
256
|
+
if (!devices.some((device) => device.split(':')[0] === dev)) {
|
|
257
|
+
devices.push(dev);
|
|
277
258
|
}
|
|
278
259
|
}
|
|
279
|
-
catch { }
|
|
280
|
-
const gateways = await getLinuxGateways();
|
|
281
260
|
const hardware = await getLinuxNicHardware(devices);
|
|
282
|
-
|
|
261
|
+
const scanInterface = async (dev) => {
|
|
283
262
|
const iface = dev;
|
|
284
263
|
let ip4 = '';
|
|
285
264
|
let ip4subnet = '';
|
|
@@ -335,18 +314,19 @@ const networkInterfaces = async (defaultString = '', rescan = true) => {
|
|
|
335
314
|
const ifaceSanitized = (0, security_1.sanitizeString)(ifaceDevName, true);
|
|
336
315
|
let lines = [];
|
|
337
316
|
try {
|
|
338
|
-
const
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
(0,
|
|
317
|
+
const safe = (0, security_1.isSafePathSegment)(ifaceSanitized);
|
|
318
|
+
const connectionName = getLinuxIfaceConnectionName(deviceStatus, ifaceSanitized);
|
|
319
|
+
const [sysfsLines, iwOut, details] = await Promise.all([
|
|
320
|
+
safe ? (0, files_1.readSysfsMany)(`/sys/class/net/${ifaceSanitized}`, ['address', 'carrier_changes', 'duplex', 'mtu', 'operstate', 'speed', 'type']) : [],
|
|
321
|
+
safe ? (0, files_1.fileExists)(`/sys/class/net/${ifaceSanitized}/phy80211`).then((wifi) => (wifi ? (0, exec_1.execSecure)('iw', ['dev', ifaceSanitized, 'link'], EXEC_OPTS) : '')) : '',
|
|
322
|
+
getLinuxConnectionDetails(connectionName)
|
|
342
323
|
]);
|
|
343
324
|
lines = sysfsLines;
|
|
344
325
|
lines.push(`wireless: ${wirelessLines.find((line) => line.indexOf(ifaceSanitized) >= 0) || ''}`);
|
|
345
326
|
lines.push(...iwOut.split('\n').filter((line) => line.indexOf('bitrate') >= 0).map((line) => line.trim()));
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
ieee8021xAuth = await getLinuxIfaceIEEE8021xAuth(connectionName);
|
|
327
|
+
dhcp = getLinuxIfaceDHCPstatus(ifaceSanitized, details, _dhcpNics);
|
|
328
|
+
dnsSuffix = getLinuxIfaceDNSsuffix(details);
|
|
329
|
+
ieee8021xAuth = getLinuxIfaceIEEE8021xAuth(details);
|
|
350
330
|
ieee8021xState = getLinuxIfaceIEEE8021xState(ieee8021xAuth);
|
|
351
331
|
}
|
|
352
332
|
catch { }
|
|
@@ -373,7 +353,7 @@ const networkInterfaces = async (defaultString = '', rescan = true) => {
|
|
|
373
353
|
internal = true;
|
|
374
354
|
}
|
|
375
355
|
const virtual = internal ? false : (0, network_1.testVirtualNic)(dev, ifaceName, mac);
|
|
376
|
-
|
|
356
|
+
return {
|
|
377
357
|
...defaults_1.initNetworkInterface,
|
|
378
358
|
iface: ifaceSanitized,
|
|
379
359
|
ifaceName,
|
|
@@ -398,20 +378,14 @@ const networkInterfaces = async (defaultString = '', rescan = true) => {
|
|
|
398
378
|
ieee8021xAuth,
|
|
399
379
|
ieee8021xState,
|
|
400
380
|
carrierChanges
|
|
401
|
-
}
|
|
381
|
+
};
|
|
382
|
+
};
|
|
383
|
+
for (let i = 0; i < devices.length; i += SCAN_CONCURRENCY) {
|
|
384
|
+
result.push(...(await Promise.all(devices.slice(i, i + SCAN_CONCURRENCY).map(scanInterface))));
|
|
402
385
|
}
|
|
403
386
|
}
|
|
404
387
|
catch { }
|
|
405
388
|
_networkInterfaces = result;
|
|
406
|
-
|
|
407
|
-
result = result.filter((item) => item.default);
|
|
408
|
-
if (result.length > 0) {
|
|
409
|
-
return [result[0]];
|
|
410
|
-
}
|
|
411
|
-
else {
|
|
412
|
-
result = [];
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
return result;
|
|
389
|
+
return (0, network_1.filterDefaultInterface)(result, defaultString);
|
|
416
390
|
};
|
|
417
391
|
exports.networkInterfaces = networkInterfaces;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { NetworkStatsData } from '../common/types';
|
|
1
|
+
import type { NetworkStatsData } from '../common/types';
|
|
2
2
|
export declare const networkStats: (interfaces?: string) => Promise<NetworkStatsData[]>;
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.networkStats = void 0;
|
|
4
|
-
const files_1 = require("../common/files");
|
|
5
4
|
const common_1 = require("../common");
|
|
6
|
-
const security_1 = require("../common/security");
|
|
7
5
|
const defaults_1 = require("../common/defaults");
|
|
8
|
-
const
|
|
6
|
+
const files_1 = require("../common/files");
|
|
9
7
|
const network_1 = require("../common/network");
|
|
10
|
-
const
|
|
8
|
+
const security_1 = require("../common/security");
|
|
9
|
+
const index_1 = require("./index");
|
|
10
|
+
const _network = Object.create(null);
|
|
11
11
|
const networkStatsSingle = async (iface) => {
|
|
12
12
|
await (0, common_1.nextTick)();
|
|
13
13
|
const defaults = { ...defaults_1.initNetworkSpeed, iface };
|
|
14
14
|
if (!_network[iface] || (_network[iface] && !_network[iface].ms) || (_network[iface] && _network[iface].ms && Date.now() - _network[iface].ms >= 500)) {
|
|
15
15
|
const dir = '/sys/class/net/' + iface;
|
|
16
16
|
if ((0, security_1.isSafePathSegment)(iface) && (await (0, files_1.fileExists)(dir))) {
|
|
17
|
-
const [operstate, rx_bytes, tx_bytes, rx_dropped, rx_errors, tx_dropped, tx_errors] = await Promise.all([
|
|
17
|
+
const [operstate, rx_bytes, tx_bytes, rx_packets, tx_packets, rx_dropped, rx_errors, tx_dropped, tx_errors] = await Promise.all([
|
|
18
18
|
(0, files_1.readSysfs)(dir + '/operstate'),
|
|
19
|
-
...['rx_bytes', 'tx_bytes', 'rx_dropped', 'rx_errors', 'tx_dropped', 'tx_errors'].map(async (f) => (0, common_1.toInt)(await (0, files_1.readSysfs)(dir + '/statistics/' + f)))
|
|
19
|
+
...['rx_bytes', 'tx_bytes', 'rx_packets', 'tx_packets', 'rx_dropped', 'rx_errors', 'tx_dropped', 'tx_errors'].map(async (f) => (0, common_1.toInt)(await (0, files_1.readSysfs)(dir + '/statistics/' + f)))
|
|
20
20
|
]);
|
|
21
|
-
return (0, network_1.calcNetworkSpeed)(iface, rx_bytes, tx_bytes, rx_dropped, rx_errors, tx_dropped, tx_errors, operstate, _network);
|
|
21
|
+
return (0, network_1.calcNetworkSpeed)({ iface, rx_bytes, tx_bytes, rx_packets, tx_packets, rx_dropped, rx_errors, tx_dropped, tx_errors, operstate }, _network);
|
|
22
22
|
}
|
|
23
23
|
return defaults;
|
|
24
24
|
}
|
|
@@ -27,6 +27,8 @@ const networkStatsSingle = async (iface) => {
|
|
|
27
27
|
...defaults,
|
|
28
28
|
rx_bytes: _network[iface].rx_bytes,
|
|
29
29
|
tx_bytes: _network[iface].tx_bytes,
|
|
30
|
+
rx_packets: _network[iface].rx_packets,
|
|
31
|
+
tx_packets: _network[iface].tx_packets,
|
|
30
32
|
rx_sec: _network[iface].rx_sec,
|
|
31
33
|
tx_sec: _network[iface].tx_sec,
|
|
32
34
|
rx_dropped: _network[iface].rx_dropped,
|
package/dist/linux/os-info.js
CHANGED
|
@@ -69,6 +69,41 @@ const linuxIsUefi = async () => {
|
|
|
69
69
|
return stdout.split('\n').length > 0 && stdout.indexOf('EFI') >= 0;
|
|
70
70
|
}
|
|
71
71
|
};
|
|
72
|
+
const getSecurity = async () => {
|
|
73
|
+
const enforce = await (0, files_1.readSysfs)('/sys/fs/selinux/enforce');
|
|
74
|
+
if (enforce === '0' || enforce === '1') {
|
|
75
|
+
const config = await (0, files_1.readFileLines)('/etc/selinux/config');
|
|
76
|
+
const policy = config.find((line) => line.trim().startsWith('SELINUXTYPE='));
|
|
77
|
+
return {
|
|
78
|
+
module: 'selinux',
|
|
79
|
+
enabled: true,
|
|
80
|
+
mode: enforce === '1' ? 'enforcing' : 'permissive',
|
|
81
|
+
policy: policy ? policy.split('=')[1].trim() : ''
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
const apparmor = await (0, files_1.readSysfs)('/sys/module/apparmor/parameters/enabled');
|
|
85
|
+
if (apparmor) {
|
|
86
|
+
const enabled = apparmor.toUpperCase() === 'Y';
|
|
87
|
+
const mode = await (0, files_1.readSysfs)('/sys/module/apparmor/parameters/mode');
|
|
88
|
+
return {
|
|
89
|
+
module: 'apparmor',
|
|
90
|
+
enabled,
|
|
91
|
+
mode: enabled ? mode || 'enforce' : 'disabled',
|
|
92
|
+
policy: ''
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
const config = await (0, files_1.readFileLines)('/etc/selinux/config');
|
|
96
|
+
const configured = config.find((line) => line.trim().startsWith('SELINUX='));
|
|
97
|
+
if (configured) {
|
|
98
|
+
return {
|
|
99
|
+
module: 'selinux',
|
|
100
|
+
enabled: false,
|
|
101
|
+
mode: 'disabled',
|
|
102
|
+
policy: ''
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
return { module: '', enabled: false, mode: '', policy: '' };
|
|
106
|
+
};
|
|
72
107
|
const parseOsInfo = async (stdout, defaults) => {
|
|
73
108
|
const release = {};
|
|
74
109
|
const lines = stdout.toString().split('\n');
|
|
@@ -100,7 +135,8 @@ const parseOsInfo = async (stdout, defaults) => {
|
|
|
100
135
|
serial: (await (0, uuid_1.uuid)()).os,
|
|
101
136
|
installDate: await getInstallDate(),
|
|
102
137
|
lastUpdate: await getLastUpdate(),
|
|
103
|
-
displayServer: await getDisplayServer()
|
|
138
|
+
displayServer: await getDisplayServer(),
|
|
139
|
+
security: await getSecurity()
|
|
104
140
|
};
|
|
105
141
|
};
|
|
106
142
|
const osInfo = async () => {
|
package/dist/linux/printer.js
CHANGED
|
@@ -61,7 +61,7 @@ const printer = async () => {
|
|
|
61
61
|
}
|
|
62
62
|
if (result.length === 0) {
|
|
63
63
|
if (const_1.LINUX) {
|
|
64
|
-
const { stdout } = await (0, exec_1.execSave)('export LC_ALL=C; lpstat -lp 2>/dev/null; unset LC_ALL');
|
|
64
|
+
const { stdout } = await (0, exec_1.execSave)('export LC_ALL=C.UTF-8; lpstat -lp 2>/dev/null; unset LC_ALL');
|
|
65
65
|
const parts = ('\n' + stdout.toString()).split('\nprinter ');
|
|
66
66
|
for (let i = 1; i < parts.length; i++) {
|
|
67
67
|
const printers = parseLinuxLpstatPrinter(parts[i].split('\n'), i);
|
package/dist/linux/processes.js
CHANGED
|
@@ -283,10 +283,10 @@ const processes = async () => {
|
|
|
283
283
|
if ((_processes_cpu.ms && Date.now() - _processes_cpu.ms >= 500) || _processes_cpu.ms === 0) {
|
|
284
284
|
try {
|
|
285
285
|
if (const_1.LINUX || const_1.ANDROID) {
|
|
286
|
-
cmd = 'export LC_ALL=C; ps -axo pid:11,ppid:11,pcpu:6,pmem:6,pri:5,vsz:11,rss:11,ni:5,etime:30,state:5,tty:15,user:20,time,command; unset LC_ALL';
|
|
286
|
+
cmd = 'export LC_ALL=C.UTF-8; ps -axo pid:11,ppid:11,pcpu:6,pmem:6,pri:5,vsz:11,rss:11,ni:5,etime:30,state:5,tty:15,user:20,time,command; unset LC_ALL';
|
|
287
287
|
}
|
|
288
288
|
if (const_1.FREEBSD || const_1.NETBSD || const_1.OPENBSD) {
|
|
289
|
-
cmd = 'export LC_ALL=C; ps -axo pid,ppid,pcpu,pmem,pri,vsz,rss,ni,etime,state,tty,user,time,command; unset LC_ALL';
|
|
289
|
+
cmd = 'export LC_ALL=C.UTF-8; ps -axo pid,ppid,pcpu,pmem,pri,vsz,rss,ni,etime,state,tty,user,time,command; unset LC_ALL';
|
|
290
290
|
}
|
|
291
291
|
if (const_1.DARWIN) {
|
|
292
292
|
cmd = 'ps -axo pid,ppid,pcpu,pmem,pri,vsz=temp_title_1,rss=temp_title_2,nice,etime=temp_title_3,state,tty,user,time,command -r';
|
package/dist/linux/users.js
CHANGED
|
@@ -89,7 +89,7 @@ const parseUsersLinux = (lines, phase) => {
|
|
|
89
89
|
const users = async () => {
|
|
90
90
|
await (0, common_1.nextTick)();
|
|
91
91
|
let result = [];
|
|
92
|
-
let { stdout } = await (0, exec_1.exec)('export LC_ALL=C; who --ips; echo "---"; w
|
|
92
|
+
let { stdout } = await (0, exec_1.exec)('export LC_ALL=C.UTF-8; who --ips; echo "---"; w | tail -n +2', const_1.execOptsLinux);
|
|
93
93
|
let lines = stdout.toString().split('\n');
|
|
94
94
|
result = parseUsersLinux(lines, 1);
|
|
95
95
|
if (result.length === 0) {
|
|
@@ -43,7 +43,7 @@ const getWifiNetworkListNmi = async () => {
|
|
|
43
43
|
const getWifiNetworkListIw = async (networkInterface) => {
|
|
44
44
|
const result = [];
|
|
45
45
|
try {
|
|
46
|
-
const { stdout } = await (0, exec_1.exec)(`export LC_ALL=C; iwlist ${networkInterface} scan 2>&1; unset LC_ALL`, const_1.execOptsLinux);
|
|
46
|
+
const { stdout } = await (0, exec_1.exec)(`export LC_ALL=C.UTF-8; iwlist ${networkInterface} scan 2>&1; unset LC_ALL`, const_1.execOptsLinux);
|
|
47
47
|
let iwlistParts = stdout.split(' Cell ');
|
|
48
48
|
if (iwlistParts[0].indexOf('resource busy') >= 0) {
|
|
49
49
|
return -1;
|
|
@@ -137,7 +137,7 @@ const wifiNetworks = async () => {
|
|
|
137
137
|
let result = await getWifiNetworkListNmi();
|
|
138
138
|
if (result.length === 0) {
|
|
139
139
|
try {
|
|
140
|
-
const { stdout } = await (0, exec_1.exec)('export LC_ALL=C; iwconfig 2>/dev/null; unset LC_ALL', const_1.execOptsLinux);
|
|
140
|
+
const { stdout } = await (0, exec_1.exec)('export LC_ALL=C.UTF-8; iwconfig 2>/dev/null; unset LC_ALL', const_1.execOptsLinux);
|
|
141
141
|
const iwconfigParts = stdout.split('\n\n');
|
|
142
142
|
let networkInterface = '';
|
|
143
143
|
iwconfigParts.forEach((element) => {
|