systeminformation 6.0.0-beta.1 → 6.0.0-beta.3
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/dist/bsd/network-stats.js +1 -1
- package/dist/common/defaults.js +1 -0
- package/dist/common/network.js +4 -4
- package/dist/common/nvidia.d.ts +1 -1
- package/dist/common/nvidia.js +1 -0
- package/dist/common/types.d.ts +2 -0
- package/dist/darwin/displays.js +1 -0
- package/dist/darwin/network-interfaces.js +5 -10
- package/dist/darwin/network-stats.js +1 -1
- package/dist/linux/audio.js +46 -0
- package/dist/linux/disk-layout.js +5 -5
- package/dist/linux/displays.js +4 -0
- package/dist/linux/gpu.js +10 -4
- package/dist/linux/network-interfaces.js +25 -9
- package/dist/linux/network-stats.js +1 -1
- package/dist/linux/services.js +179 -47
- package/dist/windows/displays.js +2 -0
- package/dist/windows/network-interfaces.js +15 -23
- package/dist/windows/network-stats.js +4 -2
- package/dist/windows/services.js +3 -0
- package/package.json +1 -1
|
@@ -9,7 +9,7 @@ const darwin_1 = require("../darwin");
|
|
|
9
9
|
const network_1 = require("../common/network");
|
|
10
10
|
const _network = {};
|
|
11
11
|
const networkStatsSingle = async (iface) => {
|
|
12
|
-
const defaults = defaults_1.initNetworkSpeed;
|
|
12
|
+
const defaults = { ...defaults_1.initNetworkSpeed, iface };
|
|
13
13
|
if (!_network[iface] || (_network[iface] && !_network[iface].ms) || (_network[iface] && _network[iface].ms && Date.now() - _network[iface].ms >= 500)) {
|
|
14
14
|
let operstate = 'unknown';
|
|
15
15
|
let rx_bytes = 0;
|
package/dist/common/defaults.js
CHANGED
package/dist/common/network.js
CHANGED
|
@@ -137,10 +137,10 @@ const calcNetworkSpeed = (iface, rx_bytes, tx_bytes, rx_dropped, rx_errors, tx_d
|
|
|
137
137
|
_network[iface].tx_bytes = tx_bytes;
|
|
138
138
|
_network[iface].rx_sec = null;
|
|
139
139
|
_network[iface].tx_sec = null;
|
|
140
|
-
_network[iface].rx_dropped =
|
|
141
|
-
_network[iface].rx_errors =
|
|
142
|
-
_network[iface].tx_dropped =
|
|
143
|
-
_network[iface].tx_errors =
|
|
140
|
+
_network[iface].rx_dropped = rx_dropped;
|
|
141
|
+
_network[iface].rx_errors = rx_errors;
|
|
142
|
+
_network[iface].tx_dropped = tx_dropped;
|
|
143
|
+
_network[iface].tx_errors = tx_errors;
|
|
144
144
|
_network[iface].ms = Date.now();
|
|
145
145
|
_network[iface].last_ms = 0;
|
|
146
146
|
_network[iface].operstate = operstate;
|
package/dist/common/nvidia.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { GpuData, GpuNvidiaData } from './types';
|
|
2
|
-
export declare const getNvidiaSmi: () => Promise<string
|
|
2
|
+
export declare const getNvidiaSmi: () => Promise<string>;
|
|
3
3
|
export declare const nvidiaSmi: () => Promise<string>;
|
|
4
4
|
export declare const nvidiaDevices: () => Promise<({
|
|
5
5
|
driverVersion: string | undefined;
|
package/dist/common/nvidia.js
CHANGED
package/dist/common/types.d.ts
CHANGED
|
@@ -811,6 +811,7 @@ export type DisplayData = {
|
|
|
811
811
|
deviceName: string | null;
|
|
812
812
|
displayId: string | null;
|
|
813
813
|
main: boolean;
|
|
814
|
+
mirror: boolean;
|
|
814
815
|
builtin: boolean;
|
|
815
816
|
connection: string | null;
|
|
816
817
|
sizeX: number | null;
|
|
@@ -866,6 +867,7 @@ export type ServicesData = {
|
|
|
866
867
|
name: string;
|
|
867
868
|
running: boolean;
|
|
868
869
|
startmode: string;
|
|
870
|
+
lastChanged: Date | null;
|
|
869
871
|
pids: number[];
|
|
870
872
|
cpu: number;
|
|
871
873
|
mem: number;
|
package/dist/darwin/displays.js
CHANGED
|
@@ -26,6 +26,7 @@ const parseDisplaysDarwin = (graphicsArr) => {
|
|
|
26
26
|
displayId: displayItem['_spdisplays_displayID'] || null,
|
|
27
27
|
deviceName: null,
|
|
28
28
|
main: displayItem['spdisplays_main'] ? displayItem['spdisplays_main'] === 'spdisplays_yes' : false,
|
|
29
|
+
mirror: (displayItem['spdisplays_mirror'] || 'spdisplays_off') !== 'spdisplays_off',
|
|
29
30
|
builtin: (displayItem['spdisplays_display_type'] || '').indexOf('built-in') > -1,
|
|
30
31
|
connection: connectionType.indexOf('_internal') > -1 ? 'Internal' : connectionType.indexOf('_displayport') > -1 ? 'Display Port' : connectionType.indexOf('_hdmi') > -1 ? 'HDMI' : null,
|
|
31
32
|
sizeX: null,
|
|
@@ -187,16 +187,11 @@ const networkInterfaces = async (defaultString = '', rescan = true) => {
|
|
|
187
187
|
ieee8021xState: '',
|
|
188
188
|
carrierChanges: 0
|
|
189
189
|
});
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
}
|
|
196
|
-
else {
|
|
197
|
-
result = [];
|
|
198
|
-
}
|
|
199
|
-
}
|
|
190
|
+
}
|
|
191
|
+
_networkInterfaces = result;
|
|
192
|
+
if (defaultString.toLowerCase().indexOf('default') >= 0) {
|
|
193
|
+
result = result.filter((item) => item.default);
|
|
194
|
+
return result.length ? [result[0]] : [];
|
|
200
195
|
}
|
|
201
196
|
}
|
|
202
197
|
catch { }
|
|
@@ -10,7 +10,7 @@ const darwin_1 = require("../darwin");
|
|
|
10
10
|
const _network = {};
|
|
11
11
|
const networkStatsSingle = async (iface) => {
|
|
12
12
|
await (0, common_1.nextTick)();
|
|
13
|
-
const defaults = defaults_1.initNetworkSpeed;
|
|
13
|
+
const defaults = { ...defaults_1.initNetworkSpeed, iface };
|
|
14
14
|
if (!_network[iface] || (_network[iface] && !_network[iface].ms) || (_network[iface] && _network[iface].ms && Date.now() - _network[iface].ms >= 500)) {
|
|
15
15
|
let operstate = 'unknown';
|
|
16
16
|
let rx_bytes = 0;
|
package/dist/linux/audio.js
CHANGED
|
@@ -46,6 +46,49 @@ const parseAudioPci = (lines, audioPCI) => {
|
|
|
46
46
|
status: 'online'
|
|
47
47
|
};
|
|
48
48
|
};
|
|
49
|
+
const parseAudioAlsa = (stdout) => {
|
|
50
|
+
const result = [];
|
|
51
|
+
const [cards, pcms] = `${stdout}`.split('--pcm--');
|
|
52
|
+
const lines = (cards || '').split('\n');
|
|
53
|
+
lines.forEach((line, i) => {
|
|
54
|
+
const card = line.match(/^\s*(\d+)\s+\[(.+?)\s*\]:\s*(\S+)\s+-\s+(.*)$/);
|
|
55
|
+
if (card) {
|
|
56
|
+
const index = card[1];
|
|
57
|
+
const driver = card[3];
|
|
58
|
+
const name = card[4].trim();
|
|
59
|
+
const longName = (lines[i + 1] || '').trim();
|
|
60
|
+
const manufacturer = longName.indexOf(name) > 0 ? longName.substring(0, longName.indexOf(name)).trim() : '';
|
|
61
|
+
const devices = (pcms || '').split('\n').filter((pcm) => pcm.indexOf(`/card${index}/pcm`) >= 0);
|
|
62
|
+
const out = devices.some((pcm) => pcm.trim().endsWith('p'));
|
|
63
|
+
const isIn = devices.some((pcm) => pcm.trim().endsWith('c'));
|
|
64
|
+
const usb = `${driver} ${longName}`.toLowerCase().indexOf('usb') >= 0;
|
|
65
|
+
const hdmi = `${card[2]} ${name}`.toLowerCase().indexOf('hdmi') >= 0;
|
|
66
|
+
result.push({
|
|
67
|
+
id: `hw:${index}`,
|
|
68
|
+
name,
|
|
69
|
+
manufacturer,
|
|
70
|
+
revision: null,
|
|
71
|
+
driver,
|
|
72
|
+
default: null,
|
|
73
|
+
channel: usb ? 'USB' : hdmi ? 'HDMI' : 'Onboard',
|
|
74
|
+
type: (0, mappings_1.audioTypeLabel)(name, isIn, out),
|
|
75
|
+
in: devices.length ? isIn : null,
|
|
76
|
+
out: devices.length ? out : null,
|
|
77
|
+
status: 'online'
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
return result;
|
|
82
|
+
};
|
|
83
|
+
const getAudioAlsa = async () => {
|
|
84
|
+
try {
|
|
85
|
+
const { stdout } = await (0, exec_1.exec)('cat /proc/asound/cards 2>/dev/null; echo "--pcm--"; ls -d /proc/asound/card*/pcm* 2>/dev/null', const_1.execOptsLinux);
|
|
86
|
+
return parseAudioAlsa(stdout.toString());
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
return [];
|
|
90
|
+
}
|
|
91
|
+
};
|
|
49
92
|
const audio = async () => {
|
|
50
93
|
await (0, common_1.nextTick)();
|
|
51
94
|
const result = [];
|
|
@@ -62,6 +105,9 @@ const audio = async () => {
|
|
|
62
105
|
});
|
|
63
106
|
}
|
|
64
107
|
catch { }
|
|
108
|
+
if (!result.length) {
|
|
109
|
+
return await getAudioAlsa();
|
|
110
|
+
}
|
|
65
111
|
return result;
|
|
66
112
|
};
|
|
67
113
|
exports.audio = audio;
|
|
@@ -7,6 +7,7 @@ const exec_1 = require("../common/exec");
|
|
|
7
7
|
const filesys_1 = require("../common/filesys");
|
|
8
8
|
const mappings_1 = require("../common/mappings");
|
|
9
9
|
const security_1 = require("../common/security");
|
|
10
|
+
const virtualBlockDevice = /^(ram|zram|loop|dm-|nbd|fd)\d*$/;
|
|
10
11
|
const diskLayout = async () => {
|
|
11
12
|
await (0, common_1.nextTick)();
|
|
12
13
|
const result = [];
|
|
@@ -29,10 +30,7 @@ const diskLayout = async () => {
|
|
|
29
30
|
item.fstype === null &&
|
|
30
31
|
item.parttype === null &&
|
|
31
32
|
item.path &&
|
|
32
|
-
item.path.
|
|
33
|
-
item.path.indexOf('/loop') !== 0 &&
|
|
34
|
-
item['disc-max'] &&
|
|
35
|
-
item['disc-max'] !== 0)));
|
|
33
|
+
!virtualBlockDevice.test(item.name || item.path.replace('/dev/', '')))));
|
|
36
34
|
});
|
|
37
35
|
}
|
|
38
36
|
}
|
|
@@ -42,7 +40,9 @@ const diskLayout = async () => {
|
|
|
42
40
|
const lines = (0, filesys_1.blkStdoutToObject)(stdout).split('\n');
|
|
43
41
|
const data = (0, filesys_1.parseLinuxBlk)(lines);
|
|
44
42
|
devices = data.filter((item) => {
|
|
45
|
-
return item.type === 'disk' &&
|
|
43
|
+
return (item.type === 'disk' &&
|
|
44
|
+
item.size > 0 &&
|
|
45
|
+
((item.model !== null && item.model !== '') || (item.mount === '' && item.label === '' && item.fsType === '' && !virtualBlockDevice.test(item.name || ''))));
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
catch { }
|
package/dist/linux/displays.js
CHANGED
|
@@ -135,6 +135,9 @@ const parseLinesLinuxDisplays = (lines, depth) => {
|
|
|
135
135
|
currentDisplay.resolutionX !== null) {
|
|
136
136
|
displays.push(currentDisplay);
|
|
137
137
|
}
|
|
138
|
+
displays.forEach((display, i) => {
|
|
139
|
+
display.mirror = displays.some((other, j) => j !== i && other.positionX === display.positionX && other.positionY === display.positionY && other.currentResX === display.currentResX && other.currentResY === display.currentResY);
|
|
140
|
+
});
|
|
138
141
|
return displays;
|
|
139
142
|
};
|
|
140
143
|
const displays = async () => {
|
|
@@ -156,6 +159,7 @@ const displays = async () => {
|
|
|
156
159
|
deviceName: '',
|
|
157
160
|
displayId: null,
|
|
158
161
|
main: true,
|
|
162
|
+
mirror: false,
|
|
159
163
|
builtin: false,
|
|
160
164
|
connection: 'HDMI',
|
|
161
165
|
sizeX: null,
|
package/dist/linux/gpu.js
CHANGED
|
@@ -15,14 +15,19 @@ const readSysfs = async (file) => {
|
|
|
15
15
|
return '';
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
|
-
const readSysfsNumber = async (files, divisor = 1) => {
|
|
18
|
+
const readSysfsNumber = async (files, divisor = 1, preferNonZero = false) => {
|
|
19
|
+
let fallback = null;
|
|
19
20
|
for (const file of files) {
|
|
20
21
|
const value = Number.parseFloat(await readSysfs(file));
|
|
21
|
-
if (
|
|
22
|
+
if (Number.isNaN(value)) {
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
if (!preferNonZero || value !== 0) {
|
|
22
26
|
return value / divisor;
|
|
23
27
|
}
|
|
28
|
+
fallback = 0;
|
|
24
29
|
}
|
|
25
|
-
return
|
|
30
|
+
return fallback;
|
|
26
31
|
};
|
|
27
32
|
const parseAmdClock = (stdout) => {
|
|
28
33
|
const line = stdout.split('\n').find((l) => l.includes('*'));
|
|
@@ -60,9 +65,10 @@ const drmDevices = async (drmPath = '/sys/class/drm') => {
|
|
|
60
65
|
`${cardPath}/gt_act_freq_mhz`,
|
|
61
66
|
`${cardPath}/gt_cur_freq_mhz`,
|
|
62
67
|
`${cardPath}/gt/gt0/rps_act_freq_mhz`,
|
|
68
|
+
`${cardPath}/gt/gt0/rps_cur_freq_mhz`,
|
|
63
69
|
`${devicePath}/tile0/gt0/freq0/act_freq`,
|
|
64
70
|
`${devicePath}/tile0/gt0/freq0/cur_freq`
|
|
65
|
-
]);
|
|
71
|
+
], 1, true);
|
|
66
72
|
devices.push({
|
|
67
73
|
busAddress,
|
|
68
74
|
utilizationGpu: await readSysfsNumber([`${devicePath}/gpu_busy_percent`]),
|
|
@@ -31,19 +31,22 @@ const splitSectionsNics = (lines) => {
|
|
|
31
31
|
}
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
|
-
const
|
|
34
|
+
const getLinuxDeviceStatus = async () => {
|
|
35
35
|
try {
|
|
36
36
|
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 : '';
|
|
37
|
+
return stdout;
|
|
42
38
|
}
|
|
43
39
|
catch {
|
|
44
40
|
return '';
|
|
45
41
|
}
|
|
46
42
|
};
|
|
43
|
+
const getLinuxIfaceConnectionName = (deviceStatus, interfaceName) => {
|
|
44
|
+
const result = (0, common_1.grep)(deviceStatus, interfaceName);
|
|
45
|
+
const resultFormat = result.replace(/\s+/g, ' ').trim();
|
|
46
|
+
const connectionNameLines = resultFormat.split(' ').slice(3);
|
|
47
|
+
const connectionName = connectionNameLines.join(' ');
|
|
48
|
+
return connectionName !== '--' ? connectionName : '';
|
|
49
|
+
};
|
|
47
50
|
const readInterfacesLines = async (file) => {
|
|
48
51
|
if (file.includes('*') || file.includes('?')) {
|
|
49
52
|
try {
|
|
@@ -201,7 +204,17 @@ const networkInterfaces = async (defaultString = '', rescan = true) => {
|
|
|
201
204
|
try {
|
|
202
205
|
const _dhcpNics = await getLinuxDHCPNics();
|
|
203
206
|
const defaultInterface = await (0, network_interface_default_1.networkInterfaceDefault)();
|
|
204
|
-
|
|
207
|
+
const deviceStatus = await getLinuxDeviceStatus();
|
|
208
|
+
const devices = Object.keys(interfaces);
|
|
209
|
+
try {
|
|
210
|
+
for (const dev of await (0, promises_1.readdir)('/sys/class/net')) {
|
|
211
|
+
if (!devices.some((device) => device.split(':')[0] === dev)) {
|
|
212
|
+
devices.push(dev);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
catch { }
|
|
217
|
+
for (const dev of devices) {
|
|
205
218
|
const iface = dev;
|
|
206
219
|
let ip4 = '';
|
|
207
220
|
let ip4subnet = '';
|
|
@@ -284,7 +297,7 @@ const networkInterfaces = async (defaultString = '', rescan = true) => {
|
|
|
284
297
|
try {
|
|
285
298
|
const { stdout } = await (0, exec_1.exec)(cmd, const_1.execOptsLinux);
|
|
286
299
|
lines = stdout.split('\n');
|
|
287
|
-
const connectionName =
|
|
300
|
+
const connectionName = getLinuxIfaceConnectionName(deviceStatus, ifaceSanitized);
|
|
288
301
|
dhcp = await getLinuxIfaceDHCPstatus(ifaceSanitized, connectionName, _dhcpNics);
|
|
289
302
|
dnsSuffix = await getLinuxIfaceDNSsuffix(connectionName);
|
|
290
303
|
ieee8021xAuth = await getLinuxIfaceIEEE8021xAuth(connectionName);
|
|
@@ -301,9 +314,12 @@ const networkInterfaces = async (defaultString = '', rescan = true) => {
|
|
|
301
314
|
myspeed = Number.parseFloat(wirelessspeed);
|
|
302
315
|
speed = Number.isNaN(myspeed) ? null : myspeed;
|
|
303
316
|
}
|
|
317
|
+
if (!mac) {
|
|
318
|
+
mac = (0, common_1.getValue)(lines, 'address');
|
|
319
|
+
}
|
|
304
320
|
carrierChanges = (0, common_1.toInt)((0, common_1.getValue)(lines, 'carrier_changes'));
|
|
305
321
|
const operstate = (0, common_1.getValue)(lines, 'operstate');
|
|
306
|
-
type =
|
|
322
|
+
type = (0, common_1.getValue)(lines, 'wireless').trim() ? 'wireless' : (0, common_1.toInt)((0, common_1.getValue)(lines, 'type')) === 1 ? 'wired' : 'unknown';
|
|
307
323
|
if (ifaceSanitized === 'lo' || ifaceSanitized.startsWith('bond')) {
|
|
308
324
|
type = 'virtual';
|
|
309
325
|
}
|
|
@@ -11,7 +11,7 @@ const network_1 = require("../common/network");
|
|
|
11
11
|
const _network = {};
|
|
12
12
|
const networkStatsSingle = async (iface) => {
|
|
13
13
|
await (0, common_1.nextTick)();
|
|
14
|
-
const defaults = defaults_1.initNetworkSpeed;
|
|
14
|
+
const defaults = { ...defaults_1.initNetworkSpeed, iface };
|
|
15
15
|
if (!_network[iface] || (_network[iface] && !_network[iface].ms) || (_network[iface] && _network[iface].ms && Date.now() - _network[iface].ms >= 500)) {
|
|
16
16
|
if (await (0, files_1.fileExists)('/sys/class/net/' + iface)) {
|
|
17
17
|
const cmd = 'cat /sys/class/net/' +
|
package/dist/linux/services.js
CHANGED
|
@@ -82,15 +82,180 @@ const darwinGetServices = async () => {
|
|
|
82
82
|
catch { }
|
|
83
83
|
return srvs;
|
|
84
84
|
};
|
|
85
|
+
const calcServicesCpuLinux = async (result) => {
|
|
86
|
+
let cmd = 'cat /proc/stat | grep "cpu "';
|
|
87
|
+
for (const i in result) {
|
|
88
|
+
for (const j in result[i].pids) {
|
|
89
|
+
cmd += ';cat /proc/' + result[i].pids[j] + '/stat';
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const { stdout } = await (0, exec_1.exec)(cmd, const_1.execOptsLinux);
|
|
93
|
+
let curr_processes = stdout.toString().split('\n');
|
|
94
|
+
const all = (0, parse_1.parseProcStat)(curr_processes[0]);
|
|
95
|
+
curr_processes = curr_processes.slice(1);
|
|
96
|
+
const list_new = {};
|
|
97
|
+
curr_processes.forEach((element) => {
|
|
98
|
+
const resultProcess = (0, parse_1.calcProcStatLinux)(element, all, _services_cpu);
|
|
99
|
+
if (resultProcess.pid) {
|
|
100
|
+
let listPos = -1;
|
|
101
|
+
for (let i = 0; i < result.length; i++) {
|
|
102
|
+
for (let j = 0; j < result[i].pids.length; j++) {
|
|
103
|
+
if (result[i].pids[j] === resultProcess.pid) {
|
|
104
|
+
listPos = i;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (listPos >= 0) {
|
|
109
|
+
result[listPos].cpu += resultProcess.cpuu + resultProcess.cpus;
|
|
110
|
+
}
|
|
111
|
+
list_new[resultProcess.pid] = {
|
|
112
|
+
cpuu: resultProcess.cpuu,
|
|
113
|
+
cpus: resultProcess.cpus,
|
|
114
|
+
utime: resultProcess.utime,
|
|
115
|
+
stime: resultProcess.stime,
|
|
116
|
+
cutime: resultProcess.cutime,
|
|
117
|
+
cstime: resultProcess.cstime
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
_services_cpu.all = all;
|
|
122
|
+
_services_cpu.list = Object.assign({}, list_new);
|
|
123
|
+
_services_cpu.ms = Date.now();
|
|
124
|
+
_services_cpu.result = Object.assign({}, result);
|
|
125
|
+
};
|
|
126
|
+
const systemdTimestamp = (value) => {
|
|
127
|
+
const parts = value.match(/(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2})(?: (\S+))?/);
|
|
128
|
+
if (!parts) {
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
const utc = parts[3] === 'UTC' || parts[3] === 'GMT';
|
|
132
|
+
const date = new Date(`${parts[1]}T${parts[2]}${utc ? 'Z' : ''}`);
|
|
133
|
+
return Number.isNaN(date.getTime()) ? null : date;
|
|
134
|
+
};
|
|
135
|
+
const systemdUnits = async () => {
|
|
136
|
+
const units = [];
|
|
137
|
+
const stdout = await (0, exec_1.execSecure)('systemctl', [
|
|
138
|
+
'show',
|
|
139
|
+
'--no-pager',
|
|
140
|
+
'--property=Id',
|
|
141
|
+
'--property=LoadState',
|
|
142
|
+
'--property=ActiveState',
|
|
143
|
+
'--property=UnitFileState',
|
|
144
|
+
'--property=ActiveEnterTimestamp',
|
|
145
|
+
'--property=ActiveExitTimestamp',
|
|
146
|
+
'--property=MainPID',
|
|
147
|
+
'*.service'
|
|
148
|
+
]);
|
|
149
|
+
stdout.split(/\n\s*\n/).forEach((block) => {
|
|
150
|
+
const lines = block.split('\n');
|
|
151
|
+
const id = (0, common_1.getValue)(lines, 'Id', '=', false, true);
|
|
152
|
+
if (id && (0, common_1.getValue)(lines, 'LoadState', '=', false, true) !== 'not-found') {
|
|
153
|
+
const mainPid = (0, common_1.toInt)((0, common_1.getValue)(lines, 'MainPID', '=', false, true));
|
|
154
|
+
const activeState = (0, common_1.getValue)(lines, 'ActiveState', '=', false, true);
|
|
155
|
+
const running = activeState === 'active' || activeState === 'reloading';
|
|
156
|
+
const enter = systemdTimestamp((0, common_1.getValue)(lines, 'ActiveEnterTimestamp', '=', false, true));
|
|
157
|
+
const exit = systemdTimestamp((0, common_1.getValue)(lines, 'ActiveExitTimestamp', '=', false, true));
|
|
158
|
+
units.push({
|
|
159
|
+
name: id.replace(/\.service$/, ''),
|
|
160
|
+
running,
|
|
161
|
+
startmode: (0, common_1.getValue)(lines, 'UnitFileState', '=', false, true),
|
|
162
|
+
lastChanged: (running ? enter || exit : exit || enter) || null,
|
|
163
|
+
mainPid
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
return units;
|
|
168
|
+
};
|
|
169
|
+
const elapsedToDate = (elapsed) => {
|
|
170
|
+
const parts = elapsed.split('-');
|
|
171
|
+
const days = parts.length > 1 ? (0, common_1.toInt)(parts[0]) : 0;
|
|
172
|
+
const time = (parts.length > 1 ? parts[1] : parts[0]).split(':');
|
|
173
|
+
if (time.length < 2 || time.length > 3) {
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
const seconds = time.reduce((total, part) => total * 60 + (0, common_1.toInt)(part), 0) + days * 86400;
|
|
177
|
+
return seconds > 0 ? new Date(Date.now() - seconds * 1000) : null;
|
|
178
|
+
};
|
|
179
|
+
const psProcessesLinux = async () => {
|
|
180
|
+
const procs = [];
|
|
181
|
+
const stdout = await (0, exec_1.execSecure)('ps', ['-axo', 'pcpu,pmem,pid,ppid']);
|
|
182
|
+
stdout
|
|
183
|
+
.replace(/ +/g, ' ')
|
|
184
|
+
.replace(/,+/g, '.')
|
|
185
|
+
.split('\n')
|
|
186
|
+
.forEach((line) => {
|
|
187
|
+
const parts = line.trim().split(' ');
|
|
188
|
+
if (parts.length >= 4) {
|
|
189
|
+
const pid = (0, common_1.toInt)(parts[2]);
|
|
190
|
+
if (pid) {
|
|
191
|
+
procs.push({ pid, ppid: (0, common_1.toInt)(parts[3]), cpu: parseFloat(parts[0]) || 0, mem: parseFloat(parts[1]) || 0 });
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
return procs;
|
|
196
|
+
};
|
|
197
|
+
const servicesFromSystemd = async (srvs, units) => {
|
|
198
|
+
const all = srvs.length === 1 && srvs[0] === '*';
|
|
199
|
+
const matches = (unit) => {
|
|
200
|
+
const name = unit.name.toLowerCase();
|
|
201
|
+
return srvs.indexOf(name) >= 0 || srvs.indexOf(`${name}.service`) >= 0;
|
|
202
|
+
};
|
|
203
|
+
const selected = all ? units : units.filter(matches);
|
|
204
|
+
const procs = await psProcessesLinux();
|
|
205
|
+
const byPid = {};
|
|
206
|
+
const children = {};
|
|
207
|
+
procs.forEach((proc) => {
|
|
208
|
+
byPid[proc.pid] = { cpu: proc.cpu, mem: proc.mem };
|
|
209
|
+
children[proc.ppid] = (children[proc.ppid] || []).concat(proc.pid);
|
|
210
|
+
});
|
|
211
|
+
const result = [];
|
|
212
|
+
selected.forEach((unit) => {
|
|
213
|
+
const pids = [];
|
|
214
|
+
const collect = (pid) => {
|
|
215
|
+
pids.push(pid);
|
|
216
|
+
(children[pid] || []).forEach(collect);
|
|
217
|
+
};
|
|
218
|
+
if (unit.mainPid && byPid[unit.mainPid]) {
|
|
219
|
+
collect(unit.mainPid);
|
|
220
|
+
}
|
|
221
|
+
result.push({
|
|
222
|
+
name: unit.name,
|
|
223
|
+
running: unit.running,
|
|
224
|
+
startmode: unit.startmode,
|
|
225
|
+
lastChanged: unit.lastChanged,
|
|
226
|
+
pids,
|
|
227
|
+
cpu: parseFloat(pids.reduce((sum, pid) => sum + (byPid[pid] ? byPid[pid].cpu : 0), 0).toFixed(2)),
|
|
228
|
+
mem: parseFloat(pids.reduce((sum, pid) => sum + (byPid[pid] ? byPid[pid].mem : 0), 0).toFixed(2))
|
|
229
|
+
});
|
|
230
|
+
});
|
|
231
|
+
if (!all) {
|
|
232
|
+
srvs
|
|
233
|
+
.filter((srv) => !selected.some((unit) => unit.name.toLowerCase() === srv || `${unit.name.toLowerCase()}.service` === srv))
|
|
234
|
+
.forEach((srv) => {
|
|
235
|
+
result.push({ name: srv, running: false, startmode: '', lastChanged: null, pids: [], cpu: 0, mem: 0 });
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
await calcServicesCpuLinux(result);
|
|
239
|
+
return result;
|
|
240
|
+
};
|
|
85
241
|
const services = async (srv) => {
|
|
86
242
|
await (0, common_1.nextTick)();
|
|
87
243
|
const result = [];
|
|
88
244
|
if (!(0, security_1.isPrototypePolluted)()) {
|
|
89
245
|
let srvs = (0, security_1.sanitizeServiceString)(srv);
|
|
246
|
+
if (const_1.LINUX) {
|
|
247
|
+
try {
|
|
248
|
+
const units = await systemdUnits();
|
|
249
|
+
if (units.length) {
|
|
250
|
+
return await servicesFromSystemd(srvs, units);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
catch { }
|
|
254
|
+
}
|
|
90
255
|
if (srvs.length === 1 && srvs[0] === '*') {
|
|
91
256
|
srvs = const_1.DARWIN ? await darwinGetServices() : await nixGetServices();
|
|
92
257
|
}
|
|
93
|
-
let args = const_1.DARWIN ? ['-caxo', 'pcpu,pmem,pid,command'] : ['-axo', 'pcpu,pmem,pid,command'];
|
|
258
|
+
let args = const_1.DARWIN ? ['-caxo', 'pcpu,pmem,pid,etime,command'] : ['-axo', 'pcpu,pmem,pid,etime,command'];
|
|
94
259
|
if (srvs.length > 0) {
|
|
95
260
|
let stdout = await (0, exec_1.execSecure)('ps', args);
|
|
96
261
|
if (stdout) {
|
|
@@ -112,16 +277,22 @@ const services = async (srv) => {
|
|
|
112
277
|
});
|
|
113
278
|
}
|
|
114
279
|
const pids = [];
|
|
280
|
+
let lastChanged = null;
|
|
115
281
|
for (const p of ps) {
|
|
116
|
-
const
|
|
117
|
-
if (
|
|
118
|
-
pids.push((0, common_1.toInt)(
|
|
282
|
+
const parts = p.trim().split(' ');
|
|
283
|
+
if (parts[2]) {
|
|
284
|
+
pids.push((0, common_1.toInt)(parts[2]));
|
|
285
|
+
const started = elapsedToDate(parts[3] || '');
|
|
286
|
+
if (started && (!lastChanged || started < lastChanged)) {
|
|
287
|
+
lastChanged = started;
|
|
288
|
+
}
|
|
119
289
|
}
|
|
120
290
|
}
|
|
121
291
|
result.push({
|
|
122
292
|
name: srv,
|
|
123
293
|
running: ps.length > 0,
|
|
124
294
|
startmode: '',
|
|
295
|
+
lastChanged,
|
|
125
296
|
pids: pids,
|
|
126
297
|
cpu: parseFloat(ps
|
|
127
298
|
.reduce(function (pv, cv) {
|
|
@@ -136,50 +307,9 @@ const services = async (srv) => {
|
|
|
136
307
|
});
|
|
137
308
|
});
|
|
138
309
|
if (const_1.LINUX) {
|
|
139
|
-
|
|
140
|
-
for (const i in result) {
|
|
141
|
-
for (const j in result[i].pids) {
|
|
142
|
-
cmd += ';cat /proc/' + result[i].pids[j] + '/stat';
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
const { stdout } = await (0, exec_1.exec)(cmd, const_1.execOptsLinux);
|
|
146
|
-
let curr_processes = stdout.toString().split('\n');
|
|
147
|
-
const all = (0, parse_1.parseProcStat)(curr_processes[0]);
|
|
148
|
-
curr_processes = curr_processes.slice(1);
|
|
149
|
-
const list_new = {};
|
|
150
|
-
curr_processes.forEach((element) => {
|
|
151
|
-
const resultProcess = (0, parse_1.calcProcStatLinux)(element, all, _services_cpu);
|
|
152
|
-
if (resultProcess.pid) {
|
|
153
|
-
let listPos = -1;
|
|
154
|
-
for (let i = 0; i < result.length; i++) {
|
|
155
|
-
for (let j = 0; j < result[i].pids.length; j++) {
|
|
156
|
-
if (result[i].pids[j] === resultProcess.pid) {
|
|
157
|
-
listPos = i;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
if (listPos >= 0) {
|
|
162
|
-
result[listPos].cpu += resultProcess.cpuu + resultProcess.cpus;
|
|
163
|
-
}
|
|
164
|
-
list_new[resultProcess.pid] = {
|
|
165
|
-
cpuu: resultProcess.cpuu,
|
|
166
|
-
cpus: resultProcess.cpus,
|
|
167
|
-
utime: resultProcess.utime,
|
|
168
|
-
stime: resultProcess.stime,
|
|
169
|
-
cutime: resultProcess.cutime,
|
|
170
|
-
cstime: resultProcess.cstime
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
_services_cpu.all = all;
|
|
175
|
-
_services_cpu.list = Object.assign({}, list_new);
|
|
176
|
-
_services_cpu.ms = Date.now();
|
|
177
|
-
_services_cpu.result = Object.assign({}, result);
|
|
178
|
-
return result;
|
|
179
|
-
}
|
|
180
|
-
else {
|
|
181
|
-
return result;
|
|
310
|
+
await calcServicesCpuLinux(result);
|
|
182
311
|
}
|
|
312
|
+
return result;
|
|
183
313
|
}
|
|
184
314
|
else {
|
|
185
315
|
args = ['-o', 'comm'];
|
|
@@ -194,6 +324,7 @@ const services = async (srv) => {
|
|
|
194
324
|
name: srv,
|
|
195
325
|
running: ps.length > 0,
|
|
196
326
|
startmode: '',
|
|
327
|
+
lastChanged: null,
|
|
197
328
|
pids: [],
|
|
198
329
|
cpu: 0,
|
|
199
330
|
mem: 0
|
|
@@ -207,6 +338,7 @@ const services = async (srv) => {
|
|
|
207
338
|
name: srv,
|
|
208
339
|
running: false,
|
|
209
340
|
startmode: '',
|
|
341
|
+
lastChanged: null,
|
|
210
342
|
pids: [],
|
|
211
343
|
cpu: 0,
|
|
212
344
|
mem: 0
|
package/dist/windows/displays.js
CHANGED
|
@@ -44,6 +44,7 @@ const parseLinesWindowsDisplaysPowershell = (ssections, monitors, dsections, con
|
|
|
44
44
|
deviceName,
|
|
45
45
|
displayId: instanceName || null,
|
|
46
46
|
main: hasOwnScreen ? primary.toLowerCase() === 'true' : false,
|
|
47
|
+
mirror: !hasOwnScreen || (monitors.length > ssections.length && i === 0),
|
|
47
48
|
builtin: videoOutputTechnology === '2147483648',
|
|
48
49
|
connection: videoOutputTechnology && mappings_1.graphicsVideoTypes[videoOutputTechnology] ? mappings_1.graphicsVideoTypes[videoOutputTechnology] : '',
|
|
49
50
|
resolutionX: (0, common_1.toInt)((0, common_1.getValue)(bounds, 'Width', ':')),
|
|
@@ -70,6 +71,7 @@ const parseLinesWindowsDisplaysPowershell = (ssections, monitors, dsections, con
|
|
|
70
71
|
deviceName: '',
|
|
71
72
|
displayId: null,
|
|
72
73
|
main: true,
|
|
74
|
+
mirror: false,
|
|
73
75
|
builtin: true,
|
|
74
76
|
sizeX: null,
|
|
75
77
|
sizeY: null,
|
|
@@ -234,18 +234,9 @@ const networkInterfaces = async (defaultString = '', rescan = true) => {
|
|
|
234
234
|
const defaultInterface = await (0, network_interface_default_1.networkInterfaceDefault)();
|
|
235
235
|
const nics = await getWindowsNics();
|
|
236
236
|
nics.forEach((nic) => {
|
|
237
|
-
|
|
238
|
-
Object.keys(interfaces).
|
|
239
|
-
|
|
240
|
-
(interfaces[key] || []).forEach((value) => {
|
|
241
|
-
if (Object.keys(value).indexOf('mac') >= 0) {
|
|
242
|
-
found = value['mac'] === nic.mac;
|
|
243
|
-
}
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
});
|
|
247
|
-
if (!found) {
|
|
248
|
-
interfaces[nic.name] = [{ mac: nic.mac }];
|
|
237
|
+
const name = nic.iface || nic.name;
|
|
238
|
+
if (name && !Object.keys(interfaces).some((key) => key.toLowerCase() === name.toLowerCase())) {
|
|
239
|
+
interfaces[name] = [{ mac: nic.mac }];
|
|
249
240
|
}
|
|
250
241
|
});
|
|
251
242
|
const nics8021xInfo = await getWindowsWiredProfilesInformation();
|
|
@@ -280,18 +271,19 @@ const networkInterfaces = async (defaultString = '', rescan = true) => {
|
|
|
280
271
|
mac = details.mac;
|
|
281
272
|
});
|
|
282
273
|
dnsSuffix = getWindowsIfaceDNSsuffix(dnsSuffixes.interfaces, ifaceSanitized);
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
274
|
+
const detail = nics.find((nic) => (nic.iface || '').toLowerCase() === dev.toLowerCase() || (nic.name || '').toLowerCase() === dev.toLowerCase()) ||
|
|
275
|
+
(mac ? nics.find((nic) => nic.mac === mac) : undefined);
|
|
276
|
+
if (detail) {
|
|
277
|
+
iface = detail.iface || iface;
|
|
278
|
+
ifaceName = detail.name;
|
|
279
|
+
dhcp = detail.dhcp;
|
|
280
|
+
operstate = detail.operstate;
|
|
281
|
+
speed = operstate === 'up' ? detail.speed : 0;
|
|
282
|
+
type = detail.type;
|
|
283
|
+
if (!mac) {
|
|
284
|
+
mac = detail.mac;
|
|
293
285
|
}
|
|
294
|
-
}
|
|
286
|
+
}
|
|
295
287
|
if (dev.toLowerCase().indexOf('wlan') >= 0 ||
|
|
296
288
|
ifaceName.toLowerCase().indexOf('wlan') >= 0 ||
|
|
297
289
|
ifaceName.toLowerCase().indexOf('802.11n') >= 0 ||
|
|
@@ -32,7 +32,7 @@ const parseLinesWindowsPerfData = (sections) => {
|
|
|
32
32
|
};
|
|
33
33
|
const networkStatsSingle = async (iface) => {
|
|
34
34
|
await (0, common_1.nextTick)();
|
|
35
|
-
const defaults = defaults_1.initNetworkSpeed;
|
|
35
|
+
const defaults = { ...defaults_1.initNetworkSpeed, iface };
|
|
36
36
|
if (!_network[iface] || (_network[iface] && !_network[iface].ms) || (_network[iface] && _network[iface].ms && Date.now() - _network[iface].ms >= 500)) {
|
|
37
37
|
let operstate = 'unknown';
|
|
38
38
|
let rx_bytes = 0;
|
|
@@ -43,6 +43,7 @@ const networkStatsSingle = async (iface) => {
|
|
|
43
43
|
let tx_errors = 0;
|
|
44
44
|
let perfData = [];
|
|
45
45
|
let ifaceName = iface;
|
|
46
|
+
let found = false;
|
|
46
47
|
try {
|
|
47
48
|
const stdout = String((await windows_1.ps.exec('Get-NetAdapterStatistics | select Name,InterfaceDescription,ReceivedBytes,ReceivedPacketErrors,ReceivedDiscardedPackets,SentBytes,OutboundPacketErrors,OutboundDiscardedPackets | fl')) || '');
|
|
48
49
|
if (stdout) {
|
|
@@ -73,6 +74,7 @@ const networkStatsSingle = async (iface) => {
|
|
|
73
74
|
.replace(/[()[\] ]+/g, '')
|
|
74
75
|
.replace(/#|\//g, '_')
|
|
75
76
|
.toLowerCase() === detail.desc)) {
|
|
77
|
+
found = true;
|
|
76
78
|
ifaceName = det.iface;
|
|
77
79
|
rx_bytes = detail.rx_bytes;
|
|
78
80
|
rx_dropped = detail.rx_dropped;
|
|
@@ -84,7 +86,7 @@ const networkStatsSingle = async (iface) => {
|
|
|
84
86
|
}
|
|
85
87
|
});
|
|
86
88
|
});
|
|
87
|
-
if (
|
|
89
|
+
if (found) {
|
|
88
90
|
return (0, network_1.calcNetworkSpeed)(ifaceName, rx_bytes, tx_bytes, rx_dropped, rx_errors, tx_dropped, tx_errors, operstate, _network);
|
|
89
91
|
}
|
|
90
92
|
return defaults;
|
package/dist/windows/services.js
CHANGED
|
@@ -36,6 +36,7 @@ const services = async (srv) => {
|
|
|
36
36
|
name: srvName,
|
|
37
37
|
running: started.toLowerCase() === 'true',
|
|
38
38
|
startmode: startMode,
|
|
39
|
+
lastChanged: null,
|
|
39
40
|
pids: [pid],
|
|
40
41
|
cpu: 0,
|
|
41
42
|
mem: 0
|
|
@@ -54,6 +55,7 @@ const services = async (srv) => {
|
|
|
54
55
|
name: srvName,
|
|
55
56
|
running: false,
|
|
56
57
|
startmode: '',
|
|
58
|
+
lastChanged: null,
|
|
57
59
|
pids: [],
|
|
58
60
|
cpu: 0,
|
|
59
61
|
mem: 0
|
|
@@ -68,6 +70,7 @@ const services = async (srv) => {
|
|
|
68
70
|
name: srvName,
|
|
69
71
|
running: false,
|
|
70
72
|
startmode: '',
|
|
73
|
+
lastChanged: null,
|
|
71
74
|
pids: [],
|
|
72
75
|
cpu: 0,
|
|
73
76
|
mem: 0
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "systeminformation",
|
|
3
|
-
"version": "6.0.0-beta.
|
|
3
|
+
"version": "6.0.0-beta.3",
|
|
4
4
|
"description": "Advanced, lightweight system and OS information library",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Sebastian Hildebrandt <hildebrandt@plus-innovations.com> (https://plus-innovations.com)",
|