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/darwin/mouse.js
CHANGED
|
@@ -61,11 +61,11 @@ const filterBluetooth = (data) => {
|
|
|
61
61
|
const mouse = async () => {
|
|
62
62
|
await (0, common_1.nextTick)();
|
|
63
63
|
try {
|
|
64
|
-
const { stdout } = await (0, exec_1.exec)('system_profiler SPSPIDataType SPUSBDataType SPBluetoothDataType -xml');
|
|
64
|
+
const { stdout } = await (0, exec_1.exec)('system_profiler SPSPIDataType SPUSBDataType SPUSBHostDataType SPBluetoothDataType -xml');
|
|
65
65
|
const data = (0, darwin_1.plistParser)(stdout, false);
|
|
66
|
-
const spiData =
|
|
67
|
-
const usbData =
|
|
68
|
-
const bluetoothData =
|
|
66
|
+
const spiData = (0, darwin_1.spItems)(data, 'SPSPIDataType');
|
|
67
|
+
const usbData = (0, darwin_1.spItems)(data, darwin_1.USB_DATA_TYPES);
|
|
68
|
+
const bluetoothData = (0, darwin_1.spItems)(data, 'SPBluetoothDataType');
|
|
69
69
|
let result = parseKeyboard(spiData);
|
|
70
70
|
result = result.concat(parseUsb(usbData));
|
|
71
71
|
result = result.concat(filterBluetooth((0, bluetooth_1.parseBluetooth)(bluetoothData)));
|
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
import type { NetworkInterfacesData } from '../common/types';
|
|
2
|
+
export declare const parseBsdGateways: (stdout: string) => {
|
|
3
|
+
[iface: string]: string;
|
|
4
|
+
};
|
|
2
5
|
export declare const networkInterfaces: (defaultString?: string, rescan?: boolean) => Promise<NetworkInterfacesData[]>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.networkInterfaces = void 0;
|
|
3
|
+
exports.networkInterfaces = exports.parseBsdGateways = void 0;
|
|
4
4
|
const node_os_1 = require("node:os");
|
|
5
5
|
const common_1 = require("../common");
|
|
6
6
|
const const_1 = require("../common/const");
|
|
@@ -97,6 +97,79 @@ const getBsdNics = async () => {
|
|
|
97
97
|
return [];
|
|
98
98
|
}
|
|
99
99
|
};
|
|
100
|
+
const parseBsdGateways = (stdout) => {
|
|
101
|
+
const result = {};
|
|
102
|
+
let ifaceColumn = -1;
|
|
103
|
+
for (const line of stdout.split('\n')) {
|
|
104
|
+
const parts = line.trim().split(/\s+/);
|
|
105
|
+
if (parts[0] === 'Destination') {
|
|
106
|
+
ifaceColumn = parts.findIndex((part) => /^(netif|interface|iface)$/i.test(part));
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
if (parts[0] !== 'default' || parts.length < 3 || !parts[1].includes('.')) {
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
const iface = ifaceColumn > 0 ? parts[ifaceColumn] : parts.slice(2).reverse().find((part) => /^[a-z][a-z0-9]*\d$/.test(part));
|
|
113
|
+
if (iface && !result[iface]) {
|
|
114
|
+
result[iface] = parts[1];
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return result;
|
|
118
|
+
};
|
|
119
|
+
exports.parseBsdGateways = parseBsdGateways;
|
|
120
|
+
const getBsdGateways = async () => {
|
|
121
|
+
try {
|
|
122
|
+
const { stdout } = await (0, exec_1.exec)('netstat -rn -f inet', { maxBuffer: const_1.MAX_BUFFER_SIZE });
|
|
123
|
+
return (0, exports.parseBsdGateways)(stdout);
|
|
124
|
+
}
|
|
125
|
+
catch {
|
|
126
|
+
return {};
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
let _nicVendors = null;
|
|
130
|
+
const getBsdNicVendors = async () => {
|
|
131
|
+
if (_nicVendors) {
|
|
132
|
+
return _nicVendors;
|
|
133
|
+
}
|
|
134
|
+
const result = {};
|
|
135
|
+
if (!const_1.DARWIN) {
|
|
136
|
+
_nicVendors = result;
|
|
137
|
+
return result;
|
|
138
|
+
}
|
|
139
|
+
let complete = false;
|
|
140
|
+
try {
|
|
141
|
+
const { stdout } = await (0, exec_1.exec)('ioreg -r -c IONetworkController -d 2 -w 0', { maxBuffer: const_1.MAX_BUFFER_SIZE });
|
|
142
|
+
let vendor = '';
|
|
143
|
+
let model = '';
|
|
144
|
+
for (const line of stdout.split('\n')) {
|
|
145
|
+
if (line.startsWith('+-o ')) {
|
|
146
|
+
vendor = '';
|
|
147
|
+
model = '';
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
const value = line.match(/"IO(Vendor|Model)" = "(.*)"/);
|
|
151
|
+
if (value) {
|
|
152
|
+
if (value[1] === 'Vendor') {
|
|
153
|
+
vendor = value[2];
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
model = value[2];
|
|
157
|
+
}
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
const child = line.match(/^\s+\+-o (\S+)\s+<class \S*Interface/);
|
|
161
|
+
if (child && (vendor || model)) {
|
|
162
|
+
result[child[1]] = { vendor, model };
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
complete = true;
|
|
166
|
+
}
|
|
167
|
+
catch { }
|
|
168
|
+
if (complete) {
|
|
169
|
+
_nicVendors = result;
|
|
170
|
+
}
|
|
171
|
+
return result;
|
|
172
|
+
};
|
|
100
173
|
const getBsdIfaceDHCPstatus = async (iface) => {
|
|
101
174
|
let result = false;
|
|
102
175
|
try {
|
|
@@ -113,13 +186,12 @@ const networkInterfaces = async (defaultString = '', rescan = true) => {
|
|
|
113
186
|
await (0, common_1.nextTick)();
|
|
114
187
|
const interfaces = (0, node_os_1.networkInterfaces)();
|
|
115
188
|
if (JSON.stringify(interfaces) === JSON.stringify(_interfaces) && !rescan) {
|
|
116
|
-
return _networkInterfaces;
|
|
189
|
+
return (0, network_1.filterDefaultInterface)(_networkInterfaces, defaultString);
|
|
117
190
|
}
|
|
118
191
|
_interfaces = (0, index_1.cloneObj)(interfaces);
|
|
119
192
|
let result = [];
|
|
120
193
|
try {
|
|
121
|
-
const nics = await getBsdNics();
|
|
122
|
-
const defaultInterface = await (0, network_interface_default_1.networkInterfaceDefault)();
|
|
194
|
+
const [nics, defaultInterface, gateways, vendors] = await Promise.all([getBsdNics(), (0, network_interface_default_1.networkInterfaceDefault)(), getBsdGateways(), getBsdNicVendors()]);
|
|
123
195
|
for (const nic of nics) {
|
|
124
196
|
let ip4link = '';
|
|
125
197
|
let ip4linksubnet = '';
|
|
@@ -168,11 +240,14 @@ const networkInterfaces = async (defaultString = '', rescan = true) => {
|
|
|
168
240
|
result.push({
|
|
169
241
|
iface: nic.iface,
|
|
170
242
|
ifaceName: nic.iface,
|
|
243
|
+
vendor: vendors[nic.iface]?.vendor || '',
|
|
244
|
+
model: vendors[nic.iface]?.model || '',
|
|
171
245
|
default: nic.iface === defaultInterface,
|
|
172
246
|
ip4: nic.ip4,
|
|
173
247
|
ip4subnet: nic.ip4subnet || '',
|
|
174
248
|
ip6: nic.ip6,
|
|
175
249
|
ip6subnet: nic.ip6subnet || '',
|
|
250
|
+
gateway: gateways[nic.iface] || '',
|
|
176
251
|
mac: nic.mac,
|
|
177
252
|
internal: nic.internal,
|
|
178
253
|
virtual: nic.internal ? false : (0, network_1.testVirtualNic)(nic.iface, nic.iface, nic.mac),
|
|
@@ -187,17 +262,9 @@ const networkInterfaces = async (defaultString = '', rescan = true) => {
|
|
|
187
262
|
ieee8021xState: '',
|
|
188
263
|
carrierChanges: 0
|
|
189
264
|
});
|
|
190
|
-
_networkInterfaces = result;
|
|
191
|
-
if (defaultString.toLowerCase().indexOf('default') >= 0) {
|
|
192
|
-
result = result.filter((item) => item.default);
|
|
193
|
-
if (result.length > 0) {
|
|
194
|
-
return [result[0]];
|
|
195
|
-
}
|
|
196
|
-
else {
|
|
197
|
-
result = [];
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
265
|
}
|
|
266
|
+
_networkInterfaces = result;
|
|
267
|
+
return (0, network_1.filterDefaultInterface)(result, defaultString);
|
|
201
268
|
}
|
|
202
269
|
catch { }
|
|
203
270
|
return result;
|
|
@@ -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[]>;
|
|
@@ -7,35 +7,40 @@ const exec_1 = require("../common/exec");
|
|
|
7
7
|
const network_1 = require("../common/network");
|
|
8
8
|
const security_1 = require("../common/security");
|
|
9
9
|
const darwin_1 = require("../darwin");
|
|
10
|
-
const
|
|
10
|
+
const EXEC_OPTS = { timeout: 5000 };
|
|
11
|
+
const _network = Object.create(null);
|
|
11
12
|
const networkStatsSingle = async (iface) => {
|
|
12
13
|
await (0, common_1.nextTick)();
|
|
13
|
-
const defaults = defaults_1.initNetworkSpeed;
|
|
14
|
+
const defaults = { ...defaults_1.initNetworkSpeed, iface };
|
|
14
15
|
if (!_network[iface] || (_network[iface] && !_network[iface].ms) || (_network[iface] && _network[iface].ms && Date.now() - _network[iface].ms >= 500)) {
|
|
15
16
|
let operstate = 'unknown';
|
|
16
17
|
let rx_bytes = 0;
|
|
17
18
|
let tx_bytes = 0;
|
|
19
|
+
let rx_packets = 0;
|
|
20
|
+
let tx_packets = 0;
|
|
18
21
|
let rx_dropped = 0;
|
|
19
22
|
let rx_errors = 0;
|
|
20
23
|
let tx_dropped = 0;
|
|
21
24
|
let tx_errors = 0;
|
|
22
|
-
let stdout = '';
|
|
23
|
-
|
|
24
|
-
operstate = (
|
|
25
|
+
let stdout = await (0, exec_1.execSecure)('ifconfig', [iface], EXEC_OPTS);
|
|
26
|
+
const statusLine = stdout.split('\n').find((l) => l.includes('status')) || '';
|
|
27
|
+
operstate = (statusLine.split(':')[1] || '').trim().toLowerCase();
|
|
25
28
|
operstate = operstate === 'active' ? 'up' : operstate === 'inactive' ? 'down' : 'unknown';
|
|
26
|
-
|
|
29
|
+
stdout = await (0, exec_1.execSecure)('netstat', ['-bdnI', iface], EXEC_OPTS);
|
|
27
30
|
if (stdout) {
|
|
28
31
|
const lines = stdout.toString().split('\n');
|
|
29
32
|
if (lines.length > 1 && lines[1].trim() !== '') {
|
|
30
33
|
const stats = lines[1].replace(/ +/g, ' ').split(' ');
|
|
31
34
|
const offset = stats.length > 11 ? 1 : 0;
|
|
32
35
|
rx_bytes = (0, common_1.toInt)(stats[offset + 5]);
|
|
36
|
+
rx_packets = (0, common_1.toInt)(stats[offset + 3]);
|
|
33
37
|
rx_dropped = (0, common_1.toInt)(stats[offset + 10]);
|
|
34
38
|
rx_errors = (0, common_1.toInt)(stats[offset + 4]);
|
|
35
39
|
tx_bytes = (0, common_1.toInt)(stats[offset + 8]);
|
|
40
|
+
tx_packets = (0, common_1.toInt)(stats[offset + 6]);
|
|
36
41
|
tx_dropped = (0, common_1.toInt)(stats[offset + 10]);
|
|
37
42
|
tx_errors = (0, common_1.toInt)(stats[offset + 7]);
|
|
38
|
-
return (0, network_1.calcNetworkSpeed)(iface, rx_bytes, tx_bytes, rx_dropped, rx_errors, tx_dropped, tx_errors, operstate, _network);
|
|
43
|
+
return (0, network_1.calcNetworkSpeed)({ iface, rx_bytes, tx_bytes, rx_packets, tx_packets, rx_dropped, rx_errors, tx_dropped, tx_errors, operstate }, _network);
|
|
39
44
|
}
|
|
40
45
|
}
|
|
41
46
|
return defaults;
|
|
@@ -45,6 +50,8 @@ const networkStatsSingle = async (iface) => {
|
|
|
45
50
|
...defaults,
|
|
46
51
|
rx_bytes: _network[iface].rx_bytes,
|
|
47
52
|
tx_bytes: _network[iface].tx_bytes,
|
|
53
|
+
rx_packets: _network[iface].rx_packets,
|
|
54
|
+
tx_packets: _network[iface].tx_packets,
|
|
48
55
|
rx_sec: _network[iface].rx_sec,
|
|
49
56
|
tx_sec: _network[iface].tx_sec,
|
|
50
57
|
rx_dropped: _network[iface].rx_dropped,
|
package/dist/darwin/os-info.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
import type { OsSecurityData } from '../common/types';
|
|
1
2
|
export declare const parseLastUpdate: (stdout: string) => Date | null;
|
|
3
|
+
export declare const parseSip: (stdout: string) => OsSecurityData;
|
|
2
4
|
export declare const osInfo: () => Promise<import("../common/types").OsData>;
|
package/dist/darwin/os-info.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.osInfo = exports.parseLastUpdate = void 0;
|
|
3
|
+
exports.osInfo = exports.parseSip = exports.parseLastUpdate = void 0;
|
|
4
4
|
const common_1 = require("../common");
|
|
5
5
|
const codepage_1 = require("../common/codepage");
|
|
6
6
|
const defaults_1 = require("../common/defaults");
|
|
@@ -110,6 +110,27 @@ const getCodename = (release) => {
|
|
|
110
110
|
}
|
|
111
111
|
return codename;
|
|
112
112
|
};
|
|
113
|
+
const parseSip = (stdout) => {
|
|
114
|
+
const status = (stdout.toString().split(':')[1] || '').trim().toLowerCase();
|
|
115
|
+
if (!status) {
|
|
116
|
+
return { module: '', enabled: false, mode: '', policy: '' };
|
|
117
|
+
}
|
|
118
|
+
if (status.includes('custom')) {
|
|
119
|
+
return { module: 'sip', enabled: false, mode: 'custom', policy: '' };
|
|
120
|
+
}
|
|
121
|
+
const enabled = status.startsWith('enabled');
|
|
122
|
+
return {
|
|
123
|
+
module: 'sip',
|
|
124
|
+
enabled,
|
|
125
|
+
mode: enabled ? 'enforcing' : status.startsWith('disabled') ? 'disabled' : 'custom',
|
|
126
|
+
policy: ''
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
exports.parseSip = parseSip;
|
|
130
|
+
const getSecurity = async () => {
|
|
131
|
+
const { stdout } = await (0, exec_1.execSave)('csrutil status');
|
|
132
|
+
return (0, exports.parseSip)(stdout);
|
|
133
|
+
};
|
|
113
134
|
const osInfo = async () => {
|
|
114
135
|
await (0, common_1.nextTick)();
|
|
115
136
|
const defaults = await (0, defaults_1.initOsInfo)();
|
|
@@ -131,7 +152,8 @@ const osInfo = async () => {
|
|
|
131
152
|
installDate: await getInstallDate(),
|
|
132
153
|
lastUpdate: await getLastUpdate(),
|
|
133
154
|
displayServer: await getDisplayServer(),
|
|
134
|
-
awake: await getAwake()
|
|
155
|
+
awake: await getAwake(),
|
|
156
|
+
security: await getSecurity()
|
|
135
157
|
};
|
|
136
158
|
}
|
|
137
159
|
catch { }
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.processFocused = exports.parseLsappinfo = void 0;
|
|
4
|
+
const common_1 = require("../common");
|
|
5
|
+
const exec_1 = require("../common/exec");
|
|
6
|
+
const EXEC_OPTS = { timeout: 5000 };
|
|
7
|
+
const parseLsappinfo = (stdout) => {
|
|
8
|
+
const pid = (0, common_1.toInt)((stdout.match(/pid\s*=\s*(\d+)/) || [])[1]);
|
|
9
|
+
if (!pid) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
pid,
|
|
14
|
+
name: (stdout.match(/^"([^"]+)"/) || [])[1] || '',
|
|
15
|
+
path: (stdout.match(/executable path="([^"]+)"/) || [])[1] || ''
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
exports.parseLsappinfo = parseLsappinfo;
|
|
19
|
+
const processFocused = async () => {
|
|
20
|
+
const asn = (await (0, exec_1.execSecure)('lsappinfo', ['front'], EXEC_OPTS)).trim();
|
|
21
|
+
if (!/^ASN:0x[0-9a-f]+-0x[0-9a-f]+:$/i.test(asn)) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
return (0, exports.parseLsappinfo)(await (0, exec_1.execSecure)('lsappinfo', ['info', '-only', 'pid,name,executablepath', asn], EXEC_OPTS));
|
|
25
|
+
};
|
|
26
|
+
exports.processFocused = processFocused;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.serialPorts = void 0;
|
|
4
|
+
const promises_1 = require("fs/promises");
|
|
5
|
+
const common_1 = require("../common");
|
|
6
|
+
const defaults_1 = require("../common/defaults");
|
|
7
|
+
const exec_1 = require("../common/exec");
|
|
8
|
+
const security_1 = require("../common/security");
|
|
9
|
+
const toHex4 = (value) => {
|
|
10
|
+
const num = Number.parseInt(value, 10);
|
|
11
|
+
return Number.isNaN(num) ? null : num.toString(16).padStart(4, '0');
|
|
12
|
+
};
|
|
13
|
+
const parseUsbPorts = (stdout) => {
|
|
14
|
+
const ports = new Map();
|
|
15
|
+
let usb = {};
|
|
16
|
+
for (const raw of stdout.split('\n')) {
|
|
17
|
+
const line = raw.replace(/\|/g, '').trim();
|
|
18
|
+
if (line.startsWith('+-o')) {
|
|
19
|
+
if (line.includes('class IOUSBHostDevice')) {
|
|
20
|
+
usb = {};
|
|
21
|
+
}
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
const entry = /^"([^"]+)" = (.+)$/.exec(line);
|
|
25
|
+
if (!entry) {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
const key = entry[1];
|
|
29
|
+
const value = (entry[2] || '').replace(/^"|"$/g, '').trim();
|
|
30
|
+
switch (key) {
|
|
31
|
+
case 'idVendor':
|
|
32
|
+
usb.vendorId = toHex4(value);
|
|
33
|
+
break;
|
|
34
|
+
case 'idProduct':
|
|
35
|
+
usb.productId = toHex4(value);
|
|
36
|
+
break;
|
|
37
|
+
case 'USB Vendor Name':
|
|
38
|
+
usb.manufacturer = value || null;
|
|
39
|
+
break;
|
|
40
|
+
case 'USB Product Name':
|
|
41
|
+
usb.name = value || null;
|
|
42
|
+
break;
|
|
43
|
+
case 'USB Serial Number':
|
|
44
|
+
usb.serialNumber = value || null;
|
|
45
|
+
break;
|
|
46
|
+
case 'IOCalloutDevice':
|
|
47
|
+
ports.set(value, { ...usb });
|
|
48
|
+
break;
|
|
49
|
+
default:
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return ports;
|
|
54
|
+
};
|
|
55
|
+
const calloutDevices = (stdout) => {
|
|
56
|
+
const devices = new Set();
|
|
57
|
+
const regex = /"IOCalloutDevice" = "([^"]+)"/g;
|
|
58
|
+
let match = regex.exec(stdout);
|
|
59
|
+
while (match) {
|
|
60
|
+
if (match[1]) {
|
|
61
|
+
devices.add(match[1]);
|
|
62
|
+
}
|
|
63
|
+
match = regex.exec(stdout);
|
|
64
|
+
}
|
|
65
|
+
return devices;
|
|
66
|
+
};
|
|
67
|
+
const serialPorts = async () => {
|
|
68
|
+
await (0, common_1.nextTick)();
|
|
69
|
+
const result = [];
|
|
70
|
+
let devices = [];
|
|
71
|
+
try {
|
|
72
|
+
devices = (await (0, promises_1.readdir)('/dev')).filter((device) => device.startsWith('cu.') && (0, security_1.isSafePathSegment)(device));
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
return result;
|
|
76
|
+
}
|
|
77
|
+
const [usbTree, bluetoothTree] = await Promise.all([(0, exec_1.execSave)('ioreg -r -c IOUSBHostDevice -l -w0'), (0, exec_1.execSave)('ioreg -r -c IOBluetoothDevice -l -w0')]);
|
|
78
|
+
const usbPorts = parseUsbPorts(usbTree.stdout);
|
|
79
|
+
const bluetoothPorts = calloutDevices(bluetoothTree.stdout);
|
|
80
|
+
for (const device of devices.sort()) {
|
|
81
|
+
const path = `/dev/${device}`;
|
|
82
|
+
const usb = usbPorts.get(path);
|
|
83
|
+
const name = device.substring(3);
|
|
84
|
+
result.push({
|
|
85
|
+
...(0, common_1.cloneObj)(defaults_1.initSerialPortResult),
|
|
86
|
+
...usb,
|
|
87
|
+
device: path,
|
|
88
|
+
name: usb?.name || name,
|
|
89
|
+
type: usb ? 'usb' : bluetoothPorts.has(path) ? 'bluetooth' : 'unknown'
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
return result;
|
|
93
|
+
};
|
|
94
|
+
exports.serialPorts = serialPorts;
|
package/dist/darwin/users.js
CHANGED
|
@@ -7,7 +7,7 @@ const exec_1 = require("../common/exec");
|
|
|
7
7
|
const users = async () => {
|
|
8
8
|
await (0, common_1.nextTick)();
|
|
9
9
|
let stdout = '';
|
|
10
|
-
({ stdout } = await (0, exec_1.execSave)('export LC_ALL=C; who; echo "---"; w -ih; unset LC_ALL'));
|
|
10
|
+
({ stdout } = await (0, exec_1.execSave)('export LC_ALL=C.UTF-8; who; echo "---"; w -ih; unset LC_ALL'));
|
|
11
11
|
return (0, darwin_1.parseUsersDarwin)(stdout);
|
|
12
12
|
};
|
|
13
13
|
exports.users = users;
|
package/dist/docker.js
CHANGED
|
@@ -505,9 +505,9 @@ const dockerAll = async () => {
|
|
|
505
505
|
await (0, common_1.nextTick)();
|
|
506
506
|
const result = await (0, exports.dockerContainers)(true);
|
|
507
507
|
if (result && Object.prototype.toString.call(result) === '[object Array]' && result.length > 0) {
|
|
508
|
-
result.
|
|
508
|
+
await Promise.all(result.map(async (element) => {
|
|
509
509
|
const res = await (0, exports.dockerContainerStats)(element.id);
|
|
510
|
-
if (res) {
|
|
510
|
+
if (res && res[0]) {
|
|
511
511
|
element.memUsage = res[0].memUsage;
|
|
512
512
|
element.memLimit = res[0].memLimit;
|
|
513
513
|
element.memPercent = res[0].memPercent;
|
|
@@ -520,9 +520,8 @@ const dockerAll = async () => {
|
|
|
520
520
|
element.memoryStats = res[0].memoryStats;
|
|
521
521
|
element.networks = res[0].networks;
|
|
522
522
|
}
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
});
|
|
523
|
+
element.processes = await (0, exports.dockerContainerProcesses)(element.id);
|
|
524
|
+
}));
|
|
526
525
|
return result;
|
|
527
526
|
}
|
|
528
527
|
else {
|
package/dist/fans.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const fans: () => Promise<import("./common/types").FanData[] | null>;
|
package/dist/fans.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fans = void 0;
|
|
4
|
+
const const_1 = require("./common/const");
|
|
5
|
+
const fans = async () => {
|
|
6
|
+
switch (true) {
|
|
7
|
+
case const_1.LINUX || const_1.ANDROID:
|
|
8
|
+
return (await import('./linux/fans.js')).fans();
|
|
9
|
+
case const_1.DARWIN:
|
|
10
|
+
return (await import('./darwin/fans.js')).fans();
|
|
11
|
+
case const_1.WINDOWS:
|
|
12
|
+
return (await import('./windows/fans.js')).fans();
|
|
13
|
+
default:
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
exports.fans = fans;
|
package/dist/get-data.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export declare const getStaticData: () => Promise<{
|
|
|
16
16
|
audio: import("./common/types").AudioData[] | null;
|
|
17
17
|
bluetooth: import("./common/types").BluetoothObject[] | null;
|
|
18
18
|
usb: import("./common/types").UsbData[] | null;
|
|
19
|
+
serialPorts: import("./common/types").SerialPortData[] | null;
|
|
19
20
|
printer: import("./common/types").PrinterData[] | null;
|
|
20
21
|
camera: import("./common/types").Camera[] | null;
|
|
21
22
|
keyboard: import("./common/types").Keyboard[] | null;
|
|
@@ -40,6 +41,7 @@ export declare const getDynamicData: (srv?: string, iface?: string) => Promise<{
|
|
|
40
41
|
processes: import("./common/types").ProcessesData | null;
|
|
41
42
|
currentLoad: import("./common/types").CurrentLoadData;
|
|
42
43
|
temp: any;
|
|
44
|
+
fans: import("./common/types").FanData[] | null;
|
|
43
45
|
networkStats: import("./common/types").NetworkStatsData[] | null;
|
|
44
46
|
networkConnections: import("./common/types").NetworkConnectionsData[] | null;
|
|
45
47
|
mem: any;
|
|
@@ -68,6 +70,7 @@ export declare const getAllData: (srv?: string, iface?: string) => Promise<{
|
|
|
68
70
|
processes: import("./common/types").ProcessesData | null;
|
|
69
71
|
currentLoad: import("./common/types").CurrentLoadData;
|
|
70
72
|
temp: any;
|
|
73
|
+
fans: import("./common/types").FanData[] | null;
|
|
71
74
|
networkStats: import("./common/types").NetworkStatsData[] | null;
|
|
72
75
|
networkConnections: import("./common/types").NetworkConnectionsData[] | null;
|
|
73
76
|
mem: any;
|
|
@@ -98,6 +101,7 @@ export declare const getAllData: (srv?: string, iface?: string) => Promise<{
|
|
|
98
101
|
audio: import("./common/types").AudioData[] | null;
|
|
99
102
|
bluetooth: import("./common/types").BluetoothObject[] | null;
|
|
100
103
|
usb: import("./common/types").UsbData[] | null;
|
|
104
|
+
serialPorts: import("./common/types").SerialPortData[] | null;
|
|
101
105
|
printer: import("./common/types").PrinterData[] | null;
|
|
102
106
|
camera: import("./common/types").Camera[] | null;
|
|
103
107
|
keyboard: import("./common/types").Keyboard[] | null;
|
package/dist/get-data.js
CHANGED
|
@@ -38,7 +38,7 @@ const common_1 = require("./common");
|
|
|
38
38
|
const si = __importStar(require("./index"));
|
|
39
39
|
const getStaticData = async () => {
|
|
40
40
|
await (0, common_1.nextTick)();
|
|
41
|
-
const [version, system, bios, baseboard, chassis, os, uuid, versions, cpu, cpuFlags, gpu, displays, net, memLayout, diskLayout, audio, bluetooth, usb, printer, camera, keyboard, mouse, pci, thunderbolt, npu, wifiInterfaces, software] = await Promise.all([
|
|
41
|
+
const [version, system, bios, baseboard, chassis, os, uuid, versions, cpu, cpuFlags, gpu, displays, net, memLayout, diskLayout, audio, bluetooth, usb, serialPorts, printer, camera, keyboard, mouse, pci, thunderbolt, npu, wifiInterfaces, software] = await Promise.all([
|
|
42
42
|
si.version(),
|
|
43
43
|
si.system(),
|
|
44
44
|
si.bios(),
|
|
@@ -57,6 +57,7 @@ const getStaticData = async () => {
|
|
|
57
57
|
si.audio(),
|
|
58
58
|
si.bluetoothDevices(),
|
|
59
59
|
si.usb(),
|
|
60
|
+
si.serialPorts(),
|
|
60
61
|
si.printer(),
|
|
61
62
|
si.camera(),
|
|
62
63
|
si.keyboard(),
|
|
@@ -85,6 +86,7 @@ const getStaticData = async () => {
|
|
|
85
86
|
audio,
|
|
86
87
|
bluetooth,
|
|
87
88
|
usb,
|
|
89
|
+
serialPorts,
|
|
88
90
|
printer,
|
|
89
91
|
camera,
|
|
90
92
|
keyboard,
|
|
@@ -99,13 +101,14 @@ const getStaticData = async () => {
|
|
|
99
101
|
exports.getStaticData = getStaticData;
|
|
100
102
|
const getDynamicData = async (srv = '', iface = '') => {
|
|
101
103
|
await (0, common_1.nextTick)();
|
|
102
|
-
const [time, cpuCurrentSpeed, users, processes, currentLoad, temp, networkStats, networkConnections, mem, battery, services, fsSize, fsStats, disksIO, wifiNetworks, wifiConnections, fsOpenFiles, blockDevices, inetLatency] = await Promise.all([
|
|
104
|
+
const [time, cpuCurrentSpeed, users, processes, currentLoad, temp, fans, networkStats, networkConnections, mem, battery, services, fsSize, fsStats, disksIO, wifiNetworks, wifiConnections, fsOpenFiles, blockDevices, inetLatency] = await Promise.all([
|
|
103
105
|
si.time(),
|
|
104
106
|
si.cpuCurrentSpeed(),
|
|
105
107
|
si.users(),
|
|
106
108
|
si.processes(),
|
|
107
109
|
si.currentLoad(),
|
|
108
110
|
si.cpuTemperature(),
|
|
111
|
+
si.fans(),
|
|
109
112
|
(async () => si.networkStats(iface || (await si.networkInterfaceDefault()) || '*'))(),
|
|
110
113
|
si.networkConnections(),
|
|
111
114
|
si.mem(),
|
|
@@ -129,6 +132,7 @@ const getDynamicData = async (srv = '', iface = '') => {
|
|
|
129
132
|
processes,
|
|
130
133
|
currentLoad,
|
|
131
134
|
temp,
|
|
135
|
+
fans,
|
|
132
136
|
networkStats,
|
|
133
137
|
networkConnections,
|
|
134
138
|
mem,
|
package/dist/get.js
CHANGED
|
@@ -103,7 +103,12 @@ const get = async (valueObject) => {
|
|
|
103
103
|
const data = await Promise.all(keys.map((func) => {
|
|
104
104
|
const value = valueObject[func];
|
|
105
105
|
const params = value.substring(value.lastIndexOf('(') + 1, value.lastIndexOf(')'));
|
|
106
|
-
|
|
106
|
+
try {
|
|
107
|
+
return Promise.resolve(params ? lib[func](params) : lib[func]()).catch(() => null);
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
return Promise.resolve(null);
|
|
111
|
+
}
|
|
107
112
|
}));
|
|
108
113
|
const result = {};
|
|
109
114
|
keys.forEach((key, i) => {
|
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export { cpuCache } from './cpu-cache';
|
|
|
11
11
|
export { cpuCurrentSpeed } from './cpu-current-speed';
|
|
12
12
|
export { cpuFlags } from './cpu-flags';
|
|
13
13
|
export { cpuTemperature } from './cpu-temperature';
|
|
14
|
+
export { fans } from './fans';
|
|
14
15
|
export { currentLoad } from './cpu-current-load';
|
|
15
16
|
export { diskLayout } from './disk-layout';
|
|
16
17
|
export { disksIO } from './disks-io';
|
|
@@ -43,6 +44,8 @@ export { pci } from './pci';
|
|
|
43
44
|
export { printer } from './printer';
|
|
44
45
|
export { processes } from './processes';
|
|
45
46
|
export { processLoad } from './process-load';
|
|
47
|
+
export { processFocused } from './process-focused';
|
|
48
|
+
export { serialPorts } from './serial-ports';
|
|
46
49
|
export { services } from './services';
|
|
47
50
|
export { shell } from './shell';
|
|
48
51
|
export { software } from './software';
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.wifiNetworks = exports.wifiInterfaces = exports.wifiConnections = exports.versions = exports.version = exports.vboxInfo = exports.uuid = exports.users = exports.usb = exports.time = exports.thunderbolt = exports.system = exports.software = exports.shell = exports.services = exports.processLoad = exports.processes = exports.printer = void 0;
|
|
3
|
+
exports.osInfo = exports.observe = exports.npu = exports.npm = exports.networkStats = exports.networkInterfaces = exports.networkInterfaceDefault = exports.networkGatewayDefault = exports.networkConnections = exports.mouse = exports.memLayout = exports.mem = exports.keyboard = exports.inetPublicIp = exports.inetLatency = exports.inetChecksite = exports.gpu = exports.getAllData = exports.getDynamicData = exports.getStaticData = exports.get = exports.fullLoad = exports.fsStats = exports.fsSize = exports.fsOpenFiles = exports.dockerAll = exports.dockerVolumes = exports.dockerContainerProcesses = exports.dockerContainerStats = exports.dockerContainers = exports.dockerImages = exports.dockerInfo = exports.displays = exports.disksIO = exports.diskLayout = exports.currentLoad = exports.fans = exports.cpuTemperature = exports.cpuFlags = exports.cpuCurrentSpeed = exports.cpuCache = exports.cpu = exports.chassis = exports.camera = exports.bluetoothDevices = exports.blockDevices = exports.bios = exports.battery = exports.baseboard = exports.audio = void 0;
|
|
4
|
+
exports.wifiNetworks = exports.wifiInterfaces = exports.wifiConnections = exports.versions = exports.version = exports.vboxInfo = exports.uuid = exports.users = exports.usb = exports.time = exports.thunderbolt = exports.system = exports.software = exports.shell = exports.services = exports.serialPorts = exports.processFocused = exports.processLoad = exports.processes = exports.printer = exports.pci = void 0;
|
|
5
5
|
var audio_1 = require("./audio");
|
|
6
6
|
Object.defineProperty(exports, "audio", { enumerable: true, get: function () { return audio_1.audio; } });
|
|
7
7
|
var baseboard_1 = require("./baseboard");
|
|
@@ -28,6 +28,8 @@ var cpu_flags_1 = require("./cpu-flags");
|
|
|
28
28
|
Object.defineProperty(exports, "cpuFlags", { enumerable: true, get: function () { return cpu_flags_1.cpuFlags; } });
|
|
29
29
|
var cpu_temperature_1 = require("./cpu-temperature");
|
|
30
30
|
Object.defineProperty(exports, "cpuTemperature", { enumerable: true, get: function () { return cpu_temperature_1.cpuTemperature; } });
|
|
31
|
+
var fans_1 = require("./fans");
|
|
32
|
+
Object.defineProperty(exports, "fans", { enumerable: true, get: function () { return fans_1.fans; } });
|
|
31
33
|
var cpu_current_load_1 = require("./cpu-current-load");
|
|
32
34
|
Object.defineProperty(exports, "currentLoad", { enumerable: true, get: function () { return cpu_current_load_1.currentLoad; } });
|
|
33
35
|
var disk_layout_1 = require("./disk-layout");
|
|
@@ -100,6 +102,10 @@ var processes_1 = require("./processes");
|
|
|
100
102
|
Object.defineProperty(exports, "processes", { enumerable: true, get: function () { return processes_1.processes; } });
|
|
101
103
|
var process_load_1 = require("./process-load");
|
|
102
104
|
Object.defineProperty(exports, "processLoad", { enumerable: true, get: function () { return process_load_1.processLoad; } });
|
|
105
|
+
var process_focused_1 = require("./process-focused");
|
|
106
|
+
Object.defineProperty(exports, "processFocused", { enumerable: true, get: function () { return process_focused_1.processFocused; } });
|
|
107
|
+
var serial_ports_1 = require("./serial-ports");
|
|
108
|
+
Object.defineProperty(exports, "serialPorts", { enumerable: true, get: function () { return serial_ports_1.serialPorts; } });
|
|
103
109
|
var services_1 = require("./services");
|
|
104
110
|
Object.defineProperty(exports, "services", { enumerable: true, get: function () { return services_1.services; } });
|
|
105
111
|
var shell_1 = require("./shell");
|
package/dist/inet-public-ip.js
CHANGED
|
@@ -5,6 +5,7 @@ const common_1 = require("./common");
|
|
|
5
5
|
const internet_1 = require("./common/internet");
|
|
6
6
|
const inetPublicIp = async (timeout) => {
|
|
7
7
|
await (0, common_1.nextTick)();
|
|
8
|
-
|
|
8
|
+
const t = Number(timeout);
|
|
9
|
+
return (0, internet_1.publicIp)(Number.isFinite(t) && t > 0 ? t : undefined);
|
|
9
10
|
};
|
|
10
11
|
exports.inetPublicIp = inetPublicIp;
|