systeminformation 6.0.0-beta.11 → 6.0.0-beta.13
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 +17 -7
- package/dist/bsd/network-stats.js +2 -1
- package/dist/common/defaults.js +7 -1
- package/dist/common/filesys.d.ts +19 -0
- package/dist/common/filesys.js +167 -2
- package/dist/common/mappings.d.ts +0 -3
- package/dist/common/mappings.js +1 -13
- package/dist/common/types.d.ts +11 -0
- 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 +26 -2
- package/dist/darwin/displays.d.ts +1 -0
- package/dist/darwin/displays.js +30 -1
- package/dist/darwin/index.d.ts +1 -0
- package/dist/darwin/index.js +4 -2
- package/dist/darwin/network-interfaces.d.ts +3 -0
- package/dist/darwin/network-interfaces.js +78 -3
- package/dist/darwin/network-stats.js +3 -2
- package/dist/darwin/process-focused.d.ts +3 -0
- package/dist/darwin/process-focused.js +26 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/linux/block-devices.js +3 -1
- package/dist/linux/displays.d.ts +8 -0
- package/dist/linux/displays.js +112 -3
- package/dist/linux/index.d.ts +1 -0
- package/dist/linux/index.js +4 -2
- package/dist/linux/network-interfaces.d.ts +1 -0
- package/dist/linux/network-interfaces.js +69 -2
- package/dist/linux/process-focused.d.ts +4 -0
- package/dist/linux/process-focused.js +32 -0
- package/dist/linux/process-load.js +2 -1
- package/dist/linux/services.js +5 -4
- package/dist/process-focused.d.ts +1 -0
- package/dist/process-focused.js +17 -0
- package/dist/windows/audio.d.ts +29 -0
- package/dist/windows/audio.js +151 -11
- package/dist/windows/displays.d.ts +5 -0
- package/dist/windows/displays.js +59 -5
- package/dist/windows/gpu.js +3 -2
- package/dist/windows/index.d.ts +1 -0
- package/dist/windows/index.js +3 -1
- package/dist/windows/network-interfaces.js +14 -1
- package/dist/windows/process-focused.d.ts +3 -0
- package/dist/windows/process-focused.js +36 -0
- package/dist/windows/processes.d.ts +1 -0
- package/dist/windows/processes.js +37 -15
- package/package.json +1 -1
package/dist/darwin/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.serialPorts = exports.time = exports.thunderbolt = exports.system = exports.software = void 0;
|
|
3
|
+
exports.services = exports.processFocused = exports.processLoad = exports.processes = exports.printer = exports.pci = exports.osInfo = exports.npu = exports.npm = exports.networkStats = exports.networkInterfaces = exports.networkInterfaceDefault = exports.networkGatewayDefault = exports.networkConnections = exports.mouse = exports.memLayout = exports.mem = exports.keyboard = exports.inetLatency = exports.inetChecksite = exports.gpu = exports.fullLoad = exports.fsStats = exports.fsSize = exports.fsOpenFiles = exports.dockerAll = exports.dockerVolumes = exports.dockerContainerProcesses = exports.dockerContainerStats = exports.dockerContainers = exports.dockerImages = exports.dockerInfo = exports.displays = exports.disksIO = exports.diskLayout = exports.currentLoad = exports.fans = exports.cpuTemperature = exports.cpuFlags = exports.cpuCurrentSpeed = exports.cpuCache = exports.cpu = exports.chassis = exports.camera = exports.bluetoothDevices = exports.blockDevices = exports.bios = exports.battery = exports.baseboard = exports.audio = void 0;
|
|
4
|
+
exports.wifiNetworks = exports.wifiInterfaces = exports.wifiConnections = exports.versions = exports.version = exports.vboxInfo = exports.uuid = exports.users = exports.usb = exports.serialPorts = exports.time = exports.thunderbolt = exports.system = exports.software = exports.shell = 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");
|
|
@@ -92,6 +92,8 @@ var processes_1 = require("../linux/processes");
|
|
|
92
92
|
Object.defineProperty(exports, "processes", { enumerable: true, get: function () { return processes_1.processes; } });
|
|
93
93
|
var process_load_1 = require("../linux/process-load");
|
|
94
94
|
Object.defineProperty(exports, "processLoad", { enumerable: true, get: function () { return process_load_1.processLoad; } });
|
|
95
|
+
var process_focused_1 = require("./process-focused");
|
|
96
|
+
Object.defineProperty(exports, "processFocused", { enumerable: true, get: function () { return process_focused_1.processFocused; } });
|
|
95
97
|
var services_1 = require("../linux/services");
|
|
96
98
|
Object.defineProperty(exports, "services", { enumerable: true, get: function () { return services_1.services; } });
|
|
97
99
|
var shell_1 = require("../shell");
|
|
@@ -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 {
|
|
@@ -118,8 +191,7 @@ const networkInterfaces = async (defaultString = '', rescan = true) => {
|
|
|
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),
|
|
@@ -7,6 +7,7 @@ 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 EXEC_OPTS = { timeout: 5000 };
|
|
10
11
|
const _network = {};
|
|
11
12
|
const networkStatsSingle = async (iface) => {
|
|
12
13
|
await (0, common_1.nextTick)();
|
|
@@ -19,11 +20,11 @@ const networkStatsSingle = async (iface) => {
|
|
|
19
20
|
let rx_errors = 0;
|
|
20
21
|
let tx_dropped = 0;
|
|
21
22
|
let tx_errors = 0;
|
|
22
|
-
let stdout = await (0, exec_1.execSecure)('ifconfig', [iface]);
|
|
23
|
+
let stdout = await (0, exec_1.execSecure)('ifconfig', [iface], EXEC_OPTS);
|
|
23
24
|
const statusLine = stdout.split('\n').find((l) => l.includes('status')) || '';
|
|
24
25
|
operstate = (statusLine.split(':')[1] || '').trim().toLowerCase();
|
|
25
26
|
operstate = operstate === 'active' ? 'up' : operstate === 'inactive' ? 'down' : 'unknown';
|
|
26
|
-
stdout = await (0, exec_1.execSecure)('netstat', ['-bdnI', iface]);
|
|
27
|
+
stdout = await (0, exec_1.execSecure)('netstat', ['-bdnI', iface], EXEC_OPTS);
|
|
27
28
|
if (stdout) {
|
|
28
29
|
const lines = stdout.toString().split('\n');
|
|
29
30
|
if (lines.length > 1 && lines[1].trim() !== '') {
|
|
@@ -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;
|
package/dist/index.d.ts
CHANGED
|
@@ -44,6 +44,7 @@ export { pci } from './pci';
|
|
|
44
44
|
export { printer } from './printer';
|
|
45
45
|
export { processes } from './processes';
|
|
46
46
|
export { processLoad } from './process-load';
|
|
47
|
+
export { processFocused } from './process-focused';
|
|
47
48
|
export { serialPorts } from './serial-ports';
|
|
48
49
|
export { services } from './services';
|
|
49
50
|
export { shell } from './shell';
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
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.processLoad = exports.processes = exports.printer = exports.pci = 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");
|
|
@@ -102,6 +102,8 @@ var processes_1 = require("./processes");
|
|
|
102
102
|
Object.defineProperty(exports, "processes", { enumerable: true, get: function () { return processes_1.processes; } });
|
|
103
103
|
var process_load_1 = require("./process-load");
|
|
104
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; } });
|
|
105
107
|
var serial_ports_1 = require("./serial-ports");
|
|
106
108
|
Object.defineProperty(exports, "serialPorts", { enumerable: true, get: function () { return serial_ports_1.serialPorts; } });
|
|
107
109
|
var services_1 = require("./services");
|
|
@@ -5,6 +5,7 @@ const exec_1 = require("../common/exec");
|
|
|
5
5
|
const common_1 = require("../common");
|
|
6
6
|
const filesys_1 = require("../common/filesys");
|
|
7
7
|
const const_1 = require("../common/const");
|
|
8
|
+
const poolMatchLinux = async (data) => (0, filesys_1.applyPoolsLinux)(data, [...(await (0, filesys_1.zfsPoolsLinux)(data)), ...(await (0, filesys_1.btrfsPoolsLinux)(data))]);
|
|
8
9
|
const blockDevices = async () => {
|
|
9
10
|
await (0, common_1.nextTick)();
|
|
10
11
|
let stdout = '';
|
|
@@ -13,6 +14,7 @@ const blockDevices = async () => {
|
|
|
13
14
|
const lines = (0, filesys_1.blkStdoutToObject)(stdout).split('\n');
|
|
14
15
|
let data = (0, filesys_1.parseLinuxBlk)(lines);
|
|
15
16
|
data = await (0, filesys_1.raidMatchLinux)(data);
|
|
17
|
+
data = await poolMatchLinux(data);
|
|
16
18
|
return (0, filesys_1.matchDevicesLinux)(data);
|
|
17
19
|
}
|
|
18
20
|
catch {
|
|
@@ -20,7 +22,7 @@ const blockDevices = async () => {
|
|
|
20
22
|
({ stdout } = await (0, exec_1.exec)('lsblk -bPo NAME,TYPE,SIZE,FSTYPE,MOUNTPOINT,UUID,ROTA,RO,RM,LABEL,MODEL,OWNER 2>/dev/null', const_1.execOptsLinux));
|
|
21
23
|
const lines = (0, filesys_1.blkStdoutToObject)(stdout).split('\n');
|
|
22
24
|
const data = (0, filesys_1.parseLinuxBlk)(lines);
|
|
23
|
-
return await (0, filesys_1.raidMatchLinux)(data);
|
|
25
|
+
return await poolMatchLinux(await (0, filesys_1.raidMatchLinux)(data));
|
|
24
26
|
}
|
|
25
27
|
catch {
|
|
26
28
|
return [];
|
package/dist/linux/displays.d.ts
CHANGED
|
@@ -1,2 +1,10 @@
|
|
|
1
1
|
import { DisplayData } from '../common/types';
|
|
2
|
+
export declare const dpmsToPowerState: (value: string) => "" | "on" | "off" | "standby" | "suspend";
|
|
3
|
+
export declare const normalizeDrmConnector: (name: string) => string;
|
|
4
|
+
export declare const parseDrmDevicePath: (target: string) => string;
|
|
5
|
+
export declare const drmConnectorInfo: (path?: string) => Promise<Map<string, {
|
|
6
|
+
powerState: string;
|
|
7
|
+
gpuBusAddress: string;
|
|
8
|
+
}>>;
|
|
9
|
+
export declare const drmDisplays: (path?: string) => Promise<DisplayData[]>;
|
|
2
10
|
export declare const displays: () => Promise<DisplayData[]>;
|
package/dist/linux/displays.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.displays = void 0;
|
|
3
|
+
exports.displays = exports.drmDisplays = exports.drmConnectorInfo = exports.parseDrmDevicePath = exports.normalizeDrmConnector = exports.dpmsToPowerState = void 0;
|
|
4
|
+
const promises_1 = require("node:fs/promises");
|
|
5
|
+
const node_path_1 = require("node:path");
|
|
4
6
|
const common_1 = require("../common");
|
|
5
7
|
const const_1 = require("../common/const");
|
|
6
8
|
const defaults_1 = require("../common/defaults");
|
|
7
9
|
const exec_1 = require("../common/exec");
|
|
10
|
+
const files_1 = require("../common/files");
|
|
8
11
|
const index_1 = require("../common/index");
|
|
9
12
|
const raspberry_1 = require("../common/raspberry");
|
|
13
|
+
const security_1 = require("../common/security");
|
|
10
14
|
const parseLinesLinuxEdid = (edid) => {
|
|
11
15
|
const result = (0, index_1.cloneObj)(defaults_1.initDisplay);
|
|
12
16
|
let start = 108;
|
|
@@ -169,6 +173,104 @@ const getWorkAreaLinux = async (displays) => {
|
|
|
169
173
|
catch { }
|
|
170
174
|
return displays;
|
|
171
175
|
};
|
|
176
|
+
const dpmsToPowerState = (value) => {
|
|
177
|
+
const state = value.trim().toLowerCase();
|
|
178
|
+
return state === 'on' || state === 'off' || state === 'standby' || state === 'suspend' ? state : '';
|
|
179
|
+
};
|
|
180
|
+
exports.dpmsToPowerState = dpmsToPowerState;
|
|
181
|
+
const normalizeDrmConnector = (name) => name.replace(/^card\d+-/, '').replace(/^(HDMI|DVI)-[AB]-/i, '$1-').toLowerCase();
|
|
182
|
+
exports.normalizeDrmConnector = normalizeDrmConnector;
|
|
183
|
+
const parseDrmDevicePath = (target) => {
|
|
184
|
+
const address = (target.split('/').pop() || '').replace(/^0000:/, '');
|
|
185
|
+
return /^[\da-f]{2}:[\da-f]{2}\.[\da-f]$/i.test(address) ? address : '';
|
|
186
|
+
};
|
|
187
|
+
exports.parseDrmDevicePath = parseDrmDevicePath;
|
|
188
|
+
const drmConnectorInfo = async (path = '/sys/class/drm') => {
|
|
189
|
+
const result = new Map();
|
|
190
|
+
let connectors = [];
|
|
191
|
+
try {
|
|
192
|
+
connectors = (await (0, promises_1.readdir)(path)).filter((name) => /^card\d+-/.test(name) && (0, security_1.isSafePathSegment)(name));
|
|
193
|
+
}
|
|
194
|
+
catch {
|
|
195
|
+
return result;
|
|
196
|
+
}
|
|
197
|
+
const busAddresses = new Map();
|
|
198
|
+
for (const connector of connectors) {
|
|
199
|
+
const card = connector.replace(/-.*$/, '');
|
|
200
|
+
if (!busAddresses.has(card)) {
|
|
201
|
+
busAddresses.set(card, (0, exports.parseDrmDevicePath)(await (0, promises_1.readlink)((0, node_path_1.join)(path, card, 'device')).catch(() => '')));
|
|
202
|
+
}
|
|
203
|
+
result.set((0, exports.normalizeDrmConnector)(connector), {
|
|
204
|
+
powerState: (0, exports.dpmsToPowerState)(await (0, files_1.readSysfs)((0, node_path_1.join)(path, connector, 'dpms'))),
|
|
205
|
+
gpuBusAddress: busAddresses.get(card) || ''
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
return result;
|
|
209
|
+
};
|
|
210
|
+
exports.drmConnectorInfo = drmConnectorInfo;
|
|
211
|
+
const applyDrmInfo = async (displays) => {
|
|
212
|
+
const info = await (0, exports.drmConnectorInfo)();
|
|
213
|
+
if (!info.size) {
|
|
214
|
+
return displays;
|
|
215
|
+
}
|
|
216
|
+
const single = (pick) => {
|
|
217
|
+
const values = new Set([...info.values()].map(pick).filter(Boolean));
|
|
218
|
+
return values.size === 1 ? [...values][0] : '';
|
|
219
|
+
};
|
|
220
|
+
const powerStateFallback = single((entry) => entry.powerState);
|
|
221
|
+
const busAddressFallback = single((entry) => entry.gpuBusAddress);
|
|
222
|
+
for (const display of displays) {
|
|
223
|
+
const entry = info.get((0, exports.normalizeDrmConnector)(display.connection || ''));
|
|
224
|
+
display.powerState = (entry && entry.powerState) || powerStateFallback;
|
|
225
|
+
display.gpuBusAddress = (entry && entry.gpuBusAddress) || busAddressFallback;
|
|
226
|
+
}
|
|
227
|
+
return displays;
|
|
228
|
+
};
|
|
229
|
+
const drmDisplays = async (path = '/sys/class/drm') => {
|
|
230
|
+
const result = [];
|
|
231
|
+
let connectors = [];
|
|
232
|
+
try {
|
|
233
|
+
connectors = (await (0, promises_1.readdir)(path)).filter((name) => /^card\d+-/.test(name) && (0, security_1.isSafePathSegment)(name)).sort();
|
|
234
|
+
}
|
|
235
|
+
catch {
|
|
236
|
+
return result;
|
|
237
|
+
}
|
|
238
|
+
for (const connector of connectors) {
|
|
239
|
+
const dir = (0, node_path_1.join)(path, connector);
|
|
240
|
+
if ((await (0, files_1.readSysfs)((0, node_path_1.join)(dir, 'status'))) !== 'connected') {
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
243
|
+
const display = (0, index_1.cloneObj)(defaults_1.initDisplay);
|
|
244
|
+
display.connection = connector.replace(/^card\d+-/, '');
|
|
245
|
+
display.builtin = /^(edp|lvds|dsi)/i.test(display.connection);
|
|
246
|
+
display.positionX = 0;
|
|
247
|
+
display.positionY = 0;
|
|
248
|
+
const mode = (await (0, files_1.readSysfs)((0, node_path_1.join)(dir, 'modes'))).split('\n')[0].split('x');
|
|
249
|
+
if (mode.length === 2) {
|
|
250
|
+
display.currentResX = (0, common_1.toInt)(mode[0]);
|
|
251
|
+
display.currentResY = (0, common_1.toInt)(mode[1]);
|
|
252
|
+
}
|
|
253
|
+
try {
|
|
254
|
+
const edid = (await (0, promises_1.readFile)((0, node_path_1.join)(dir, 'edid'))).toString('hex');
|
|
255
|
+
if (edid) {
|
|
256
|
+
const decoded = parseLinesLinuxEdid(edid);
|
|
257
|
+
display.model = decoded.model;
|
|
258
|
+
display.resolutionX = decoded.resolutionX;
|
|
259
|
+
display.resolutionY = decoded.resolutionY;
|
|
260
|
+
display.sizeX = decoded.sizeX;
|
|
261
|
+
display.sizeY = decoded.sizeY;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
catch { }
|
|
265
|
+
result.push(display);
|
|
266
|
+
}
|
|
267
|
+
const main = result.find((display) => display.builtin) || result[0];
|
|
268
|
+
if (main) {
|
|
269
|
+
main.main = true;
|
|
270
|
+
}
|
|
271
|
+
return result;
|
|
272
|
+
};
|
|
273
|
+
exports.drmDisplays = drmDisplays;
|
|
172
274
|
const displays = async () => {
|
|
173
275
|
await (0, common_1.nextTick)();
|
|
174
276
|
const result = [];
|
|
@@ -180,6 +282,9 @@ const displays = async () => {
|
|
|
180
282
|
const parts = lines[0].replace('mode', '').replace(/"/g, '').trim().split('x');
|
|
181
283
|
if (parts.length === 2) {
|
|
182
284
|
result.push({
|
|
285
|
+
powerState: '',
|
|
286
|
+
gpu: '',
|
|
287
|
+
gpuBusAddress: '',
|
|
183
288
|
vendor: '',
|
|
184
289
|
vendorId: null,
|
|
185
290
|
model: (0, common_1.getValue)(lines, 'device_name', '='),
|
|
@@ -219,13 +324,17 @@ const displays = async () => {
|
|
|
219
324
|
try {
|
|
220
325
|
({ stdout } = await (0, exec_1.exec)('xrandr --verbose 2>/dev/null', const_1.execOptsLinux));
|
|
221
326
|
const lines = stdout.toString().split('\n');
|
|
222
|
-
|
|
327
|
+
const xrandrDisplays = parseLinesLinuxDisplays(lines, depth);
|
|
328
|
+
if (xrandrDisplays.length) {
|
|
329
|
+
return await applyDrmInfo(await getWorkAreaLinux(xrandrDisplays));
|
|
330
|
+
}
|
|
223
331
|
}
|
|
224
332
|
catch { }
|
|
225
333
|
}
|
|
226
334
|
catch { }
|
|
227
335
|
}
|
|
228
336
|
catch { }
|
|
229
|
-
|
|
337
|
+
const drm = await (0, exports.drmDisplays)();
|
|
338
|
+
return await applyDrmInfo(drm.length ? drm : result);
|
|
230
339
|
};
|
|
231
340
|
exports.displays = displays;
|
package/dist/linux/index.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ export { pci } from './pci';
|
|
|
40
40
|
export { printer } from './printer';
|
|
41
41
|
export { processes } from './processes';
|
|
42
42
|
export { processLoad } from './process-load';
|
|
43
|
+
export { processFocused } from './process-focused';
|
|
43
44
|
export { services } from './services';
|
|
44
45
|
export { shell } from '../shell';
|
|
45
46
|
export { software } from './software';
|
package/dist/linux/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.wifiNetworks = exports.wifiInterfaces = exports.wifiConnections = exports.versions = exports.version = exports.vboxInfo = exports.uuid = exports.users = exports.usb = exports.serialPorts = exports.time = exports.thunderbolt = exports.system = exports.software = void 0;
|
|
3
|
+
exports.services = exports.processFocused = exports.processLoad = exports.processes = exports.printer = exports.pci = exports.osInfo = exports.npu = exports.npm = exports.networkStats = exports.networkInterfaces = exports.networkInterfaceDefault = exports.networkGatewayDefault = exports.networkConnections = exports.mouse = exports.memLayout = exports.mem = exports.keyboard = exports.inetLatency = exports.inetChecksite = exports.gpu = exports.fullLoad = exports.fsStats = exports.fsSize = exports.fsOpenFiles = exports.dockerAll = exports.dockerVolumes = exports.dockerContainerProcesses = exports.dockerContainerStats = exports.dockerContainers = exports.dockerImages = exports.dockerInfo = exports.displays = exports.disksIO = exports.diskLayout = exports.currentLoad = exports.fans = exports.cpuTemperature = exports.cpuFlags = exports.cpuCurrentSpeed = exports.cpuCache = exports.cpu = exports.chassis = exports.camera = exports.bluetoothDevices = exports.blockDevices = exports.bios = exports.battery = exports.baseboard = exports.audio = void 0;
|
|
4
|
+
exports.wifiNetworks = exports.wifiInterfaces = exports.wifiConnections = exports.versions = exports.version = exports.vboxInfo = exports.uuid = exports.users = exports.usb = exports.serialPorts = exports.time = exports.thunderbolt = exports.system = exports.software = exports.shell = 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");
|
|
@@ -92,6 +92,8 @@ var processes_1 = require("./processes");
|
|
|
92
92
|
Object.defineProperty(exports, "processes", { enumerable: true, get: function () { return processes_1.processes; } });
|
|
93
93
|
var process_load_1 = require("./process-load");
|
|
94
94
|
Object.defineProperty(exports, "processLoad", { enumerable: true, get: function () { return process_load_1.processLoad; } });
|
|
95
|
+
var process_focused_1 = require("./process-focused");
|
|
96
|
+
Object.defineProperty(exports, "processFocused", { enumerable: true, get: function () { return process_focused_1.processFocused; } });
|
|
95
97
|
var services_1 = require("./services");
|
|
96
98
|
Object.defineProperty(exports, "services", { enumerable: true, get: function () { return services_1.services; } });
|
|
97
99
|
var shell_1 = require("../shell");
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { NetworkInterfacesData } from '../common/types';
|
|
2
2
|
export declare const checkLinuxDCHPInterfaces: (file: string, depth?: number) => Promise<any[]>;
|
|
3
|
+
export declare const pciSlotFromPath: (path: string) => string | null;
|
|
3
4
|
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 = exports.checkLinuxDCHPInterfaces = void 0;
|
|
3
|
+
exports.networkInterfaces = exports.pciSlotFromPath = exports.checkLinuxDCHPInterfaces = void 0;
|
|
4
4
|
const promises_1 = require("node:fs/promises");
|
|
5
5
|
const node_os_1 = require("node:os");
|
|
6
6
|
const node_path_1 = require("node:path");
|
|
@@ -13,6 +13,8 @@ const index_1 = require("../common/index");
|
|
|
13
13
|
const network_1 = require("../common/network");
|
|
14
14
|
const security_1 = require("../common/security");
|
|
15
15
|
const network_interface_default_1 = require("./network-interface-default");
|
|
16
|
+
const pci_1 = require("./pci");
|
|
17
|
+
const EXEC_OPTS = { timeout: 5000 };
|
|
16
18
|
let _interfaces = {};
|
|
17
19
|
let _networkInterfaces = [];
|
|
18
20
|
const splitSectionsNics = (lines) => {
|
|
@@ -194,6 +196,66 @@ const getLinuxIfaceIEEE8021xState = (authenticationProtocol) => {
|
|
|
194
196
|
return 'Unknown';
|
|
195
197
|
}
|
|
196
198
|
};
|
|
199
|
+
const getLinuxGateways = async () => {
|
|
200
|
+
const result = {};
|
|
201
|
+
try {
|
|
202
|
+
const { stdout } = await (0, exec_1.exec)('ip -4 route show default 2> /dev/null', const_1.execOptsLinux);
|
|
203
|
+
for (const line of stdout.split('\n')) {
|
|
204
|
+
for (const match of line.matchAll(/(?:via\s+(\S+)\s+)?dev\s+(\S+)/g)) {
|
|
205
|
+
if (!result[match[2]]) {
|
|
206
|
+
result[match[2]] = match[1] || '';
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
catch { }
|
|
212
|
+
return result;
|
|
213
|
+
};
|
|
214
|
+
const PCI_SLOT = /^[0-9a-f]{4}:[0-9a-f]{2}:[0-9a-f]{2}\.[0-9a-f]$/i;
|
|
215
|
+
const pciSlotFromPath = (path) => {
|
|
216
|
+
const segments = path.split('/');
|
|
217
|
+
return segments.slice(-2).reverse().find((segment) => PCI_SLOT.test(segment)) || null;
|
|
218
|
+
};
|
|
219
|
+
exports.pciSlotFromPath = pciSlotFromPath;
|
|
220
|
+
const _nicHardware = {};
|
|
221
|
+
const _nicHardwareChecked = new Set();
|
|
222
|
+
const getLinuxNicHardware = async (devices) => {
|
|
223
|
+
let pciDevices = null;
|
|
224
|
+
for (const device of devices) {
|
|
225
|
+
const dev = device.split(':')[0];
|
|
226
|
+
if (!(0, security_1.isSafePathSegment)(dev) || _nicHardwareChecked.has(dev)) {
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
let target = '';
|
|
230
|
+
try {
|
|
231
|
+
target = await (0, promises_1.realpath)(`/sys/class/net/${dev}/device`);
|
|
232
|
+
}
|
|
233
|
+
catch {
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
236
|
+
const [vendor, model] = await Promise.all([(0, files_1.readSysfs)((0, node_path_1.join)(target, '..', 'manufacturer')), (0, files_1.readSysfs)((0, node_path_1.join)(target, '..', 'product'))]);
|
|
237
|
+
if (vendor || model) {
|
|
238
|
+
_nicHardware[dev] = { vendor, model };
|
|
239
|
+
_nicHardwareChecked.add(dev);
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
const slot = (0, exports.pciSlotFromPath)(target);
|
|
243
|
+
if (!slot) {
|
|
244
|
+
_nicHardwareChecked.add(dev);
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
pciDevices = pciDevices || (await (0, pci_1.pci)());
|
|
248
|
+
if (!pciDevices.length) {
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
const entry = pciDevices.find((item) => item.slot && slot.endsWith(item.slot));
|
|
252
|
+
if (entry) {
|
|
253
|
+
_nicHardware[dev] = { vendor: entry.vendor, model: entry.model };
|
|
254
|
+
}
|
|
255
|
+
_nicHardwareChecked.add(dev);
|
|
256
|
+
}
|
|
257
|
+
return _nicHardware;
|
|
258
|
+
};
|
|
197
259
|
const networkInterfaces = async (defaultString = '', rescan = true) => {
|
|
198
260
|
await (0, common_1.nextTick)();
|
|
199
261
|
const interfaces = (0, node_os_1.networkInterfaces)();
|
|
@@ -215,6 +277,8 @@ const networkInterfaces = async (defaultString = '', rescan = true) => {
|
|
|
215
277
|
}
|
|
216
278
|
}
|
|
217
279
|
catch { }
|
|
280
|
+
const gateways = await getLinuxGateways();
|
|
281
|
+
const hardware = await getLinuxNicHardware(devices);
|
|
218
282
|
for (const dev of devices) {
|
|
219
283
|
const iface = dev;
|
|
220
284
|
let ip4 = '';
|
|
@@ -274,7 +338,7 @@ const networkInterfaces = async (defaultString = '', rescan = true) => {
|
|
|
274
338
|
const [sysfsLines, wirelessLines, iwOut] = await Promise.all([
|
|
275
339
|
(0, security_1.isSafePathSegment)(ifaceSanitized) ? (0, files_1.readSysfsMany)(`/sys/class/net/${ifaceSanitized}`, ['address', 'carrier_changes', 'duplex', 'mtu', 'operstate', 'speed', 'type']) : [],
|
|
276
340
|
(0, files_1.readFileLines)('/proc/net/wireless'),
|
|
277
|
-
(0, exec_1.execSecure)('iw', ['dev', ifaceSanitized, 'link'])
|
|
341
|
+
(0, exec_1.execSecure)('iw', ['dev', ifaceSanitized, 'link'], EXEC_OPTS)
|
|
278
342
|
]);
|
|
279
343
|
lines = sysfsLines;
|
|
280
344
|
lines.push(`wireless: ${wirelessLines.find((line) => line.indexOf(ifaceSanitized) >= 0) || ''}`);
|
|
@@ -313,11 +377,14 @@ const networkInterfaces = async (defaultString = '', rescan = true) => {
|
|
|
313
377
|
...defaults_1.initNetworkInterface,
|
|
314
378
|
iface: ifaceSanitized,
|
|
315
379
|
ifaceName,
|
|
380
|
+
vendor: hardware[ifaceSanitized]?.vendor || '',
|
|
381
|
+
model: hardware[ifaceSanitized]?.model || '',
|
|
316
382
|
default: iface === defaultInterface,
|
|
317
383
|
ip4,
|
|
318
384
|
ip4subnet,
|
|
319
385
|
ip6,
|
|
320
386
|
ip6subnet,
|
|
387
|
+
gateway: gateways[ifaceSanitized] || '',
|
|
321
388
|
mac,
|
|
322
389
|
internal,
|
|
323
390
|
virtual,
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ProcessFocusedData } from '../common/types';
|
|
2
|
+
export declare const parseXpropWindowId: (stdout: string) => string;
|
|
3
|
+
export declare const parseXpropPid: (stdout: string) => number;
|
|
4
|
+
export declare const processFocused: () => Promise<ProcessFocusedData | null>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.processFocused = exports.parseXpropPid = exports.parseXpropWindowId = void 0;
|
|
4
|
+
const promises_1 = require("node:fs/promises");
|
|
5
|
+
const common_1 = require("../common");
|
|
6
|
+
const exec_1 = require("../common/exec");
|
|
7
|
+
const EXEC_OPTS = { timeout: 5000 };
|
|
8
|
+
const parseXpropWindowId = (stdout) => {
|
|
9
|
+
const id = (stdout.match(/window id # (0x[0-9a-f]+)/i) || [])[1] || '';
|
|
10
|
+
return Number(id) ? id : '';
|
|
11
|
+
};
|
|
12
|
+
exports.parseXpropWindowId = parseXpropWindowId;
|
|
13
|
+
const parseXpropPid = (stdout) => (0, common_1.toInt)((stdout.match(/_NET_WM_PID\(CARDINAL\) = (\d+)/) || [])[1]);
|
|
14
|
+
exports.parseXpropPid = parseXpropPid;
|
|
15
|
+
const activeWindowPid = async () => {
|
|
16
|
+
const pid = (0, common_1.toInt)(await (0, exec_1.execSecure)('xdotool', ['getactivewindow', 'getwindowpid'], EXEC_OPTS));
|
|
17
|
+
if (pid) {
|
|
18
|
+
return pid;
|
|
19
|
+
}
|
|
20
|
+
const windowId = (0, exports.parseXpropWindowId)(await (0, exec_1.execSecure)('xprop', ['-root', '_NET_ACTIVE_WINDOW'], EXEC_OPTS));
|
|
21
|
+
return windowId ? (0, exports.parseXpropPid)(await (0, exec_1.execSecure)('xprop', ['-id', windowId, '_NET_WM_PID'], EXEC_OPTS)) : 0;
|
|
22
|
+
};
|
|
23
|
+
const processFocused = async () => {
|
|
24
|
+
const pid = await activeWindowPid();
|
|
25
|
+
if (!pid) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
const path = await (0, promises_1.readlink)(`/proc/${pid}/exe`).catch(() => '');
|
|
29
|
+
const name = path ? path.split('/').pop() || '' : (await (0, promises_1.readFile)(`/proc/${pid}/comm`, 'utf8').catch(() => '')).trim();
|
|
30
|
+
return { pid, name, path };
|
|
31
|
+
};
|
|
32
|
+
exports.processFocused = processFocused;
|
|
@@ -7,6 +7,7 @@ const common_1 = require("../common");
|
|
|
7
7
|
const security_1 = require("../common/security");
|
|
8
8
|
const parse_1 = require("../common/parse");
|
|
9
9
|
const files_1 = require("../common/files");
|
|
10
|
+
const EXEC_OPTS = { timeout: 5000 };
|
|
10
11
|
const _process_cpu = {
|
|
11
12
|
all: 0,
|
|
12
13
|
all_utime: 0,
|
|
@@ -23,7 +24,7 @@ const processLoad = async (proc) => {
|
|
|
23
24
|
const processes = (0, security_1.sanitizeServiceString)(proc);
|
|
24
25
|
if (processes.length) {
|
|
25
26
|
const args = ['-axo', 'pid,ppid,pcpu,pmem,comm'];
|
|
26
|
-
stdout = await (0, exec_1.execSecure)('ps', args);
|
|
27
|
+
stdout = await (0, exec_1.execSecure)('ps', args, EXEC_OPTS);
|
|
27
28
|
if (stdout) {
|
|
28
29
|
const procStats = [];
|
|
29
30
|
const lines = stdout.split('\n').filter((line) => {
|