systeminformation 6.0.0-beta.0 → 6.0.0-beta.10
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 +37 -7
- package/dist/bsd/network-stats.js +2 -2
- package/dist/bsd/os-info.d.ts +3 -0
- package/dist/bsd/os-info.js +9 -0
- package/dist/common/acceleration.d.ts +8 -0
- package/dist/common/acceleration.js +86 -0
- package/dist/common/defaults.d.ts +2 -1
- package/dist/common/defaults.js +23 -6
- package/dist/common/exec.js +1 -1
- package/dist/common/files.d.ts +9 -0
- package/dist/common/files.js +67 -3
- package/dist/common/filesys.d.ts +10 -0
- package/dist/common/filesys.js +41 -10
- package/dist/common/internet.d.ts +5 -0
- package/dist/common/internet.js +46 -1
- package/dist/common/mappings.d.ts +1 -1
- package/dist/common/mappings.js +1134 -1134
- package/dist/common/network.js +4 -4
- 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 +1 -0
- package/dist/common/security.js +3 -1
- package/dist/common/types.d.ts +79 -23
- package/dist/cpu-current-load.js +28 -6
- package/dist/cpu-current-speed.js +5 -3
- package/dist/darwin/disk-layout.js +10 -6
- package/dist/darwin/disks-io.js +3 -3
- package/dist/darwin/displays.js +3 -1
- package/dist/darwin/fans.d.ts +2 -0
- package/dist/darwin/fans.js +28 -0
- package/dist/darwin/index.d.ts +2 -0
- package/dist/darwin/index.js +6 -2
- package/dist/darwin/network-interfaces.js +5 -10
- package/dist/darwin/network-stats.js +5 -5
- package/dist/darwin/os-info.d.ts +1 -0
- package/dist/darwin/os-info.js +32 -2
- package/dist/darwin/serial-ports.d.ts +2 -0
- package/dist/darwin/serial-ports.js +94 -0
- package/dist/fans.d.ts +1 -0
- package/dist/fans.js +17 -0
- package/dist/get-data.d.ts +6 -2
- package/dist/get-data.js +6 -2
- package/dist/index.d.ts +3 -0
- package/dist/index.js +8 -2
- package/dist/inet-public-ip.d.ts +2 -0
- package/dist/inet-public-ip.js +10 -0
- package/dist/linux/audio.js +59 -0
- package/dist/linux/baseboard.js +9 -20
- package/dist/linux/bios.js +6 -15
- 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 +7 -10
- package/dist/linux/disks-io.js +9 -9
- package/dist/linux/displays.js +6 -1
- package/dist/linux/fans.d.ts +2 -0
- package/dist/linux/fans.js +92 -0
- package/dist/linux/fs-size.js +160 -34
- package/dist/linux/fs-stats.js +6 -9
- package/dist/linux/gpu.d.ts +13 -0
- package/dist/linux/gpu.js +111 -1
- package/dist/linux/index.d.ts +2 -0
- package/dist/linux/index.js +6 -2
- package/dist/linux/mem-layout.js +2 -2
- package/dist/linux/network-interfaces.js +36 -39
- package/dist/linux/network-stats.js +8 -36
- package/dist/linux/npu.js +2 -1
- package/dist/linux/os-info.js +35 -10
- package/dist/linux/printer.js +4 -4
- package/dist/linux/process-load.js +9 -12
- 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 +179 -47
- package/dist/linux/system.js +1 -7
- package/dist/linux/time.d.ts +2 -2
- package/dist/linux/time.js +3 -3
- package/dist/linux/uuid.js +4 -10
- package/dist/serial-ports.d.ts +1 -0
- package/dist/serial-ports.js +17 -0
- package/dist/time.d.ts +1 -1
- package/dist/versions.js +60 -77
- package/dist/windows/block-devices.d.ts +1 -0
- package/dist/windows/block-devices.js +15 -5
- package/dist/windows/disk-layout.js +21 -1
- package/dist/windows/disks-io.js +8 -5
- package/dist/windows/displays.js +29 -12
- package/dist/windows/fans.d.ts +2 -0
- package/dist/windows/fans.js +71 -0
- package/dist/windows/index.d.ts +2 -0
- package/dist/windows/index.js +6 -2
- package/dist/windows/network-interfaces.js +20 -29
- package/dist/windows/network-stats.js +4 -2
- package/dist/windows/os-info.js +5 -0
- package/dist/windows/process-load.js +7 -5
- package/dist/windows/processes.js +17 -11
- package/dist/windows/serial-ports.d.ts +3 -0
- package/dist/windows/serial-ports.js +73 -0
- package/dist/windows/services.js +3 -0
- package/package.json +1 -1
package/dist/linux/services.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.services = void 0;
|
|
|
4
4
|
const common_1 = require("../common");
|
|
5
5
|
const const_1 = require("../common/const");
|
|
6
6
|
const exec_1 = require("../common/exec");
|
|
7
|
+
const files_1 = require("../common/files");
|
|
7
8
|
const parse_1 = require("../common/parse");
|
|
8
9
|
const security_1 = require("../common/security");
|
|
9
10
|
const _services_cpu = {
|
|
@@ -82,15 +83,179 @@ const darwinGetServices = async () => {
|
|
|
82
83
|
catch { }
|
|
83
84
|
return srvs;
|
|
84
85
|
};
|
|
86
|
+
const calcServicesCpuLinux = async (result) => {
|
|
87
|
+
result.forEach((item) => {
|
|
88
|
+
item.cpu = 0;
|
|
89
|
+
});
|
|
90
|
+
const pids = [];
|
|
91
|
+
for (const i in result) {
|
|
92
|
+
pids.push(...result[i].pids);
|
|
93
|
+
}
|
|
94
|
+
const cpuBaseline = { ..._services_cpu };
|
|
95
|
+
const stats = await (0, files_1.readProcStats)(pids);
|
|
96
|
+
const all = (0, parse_1.parseProcStat)(stats.all);
|
|
97
|
+
const curr_processes = stats.procs;
|
|
98
|
+
const list_new = {};
|
|
99
|
+
curr_processes.forEach((element) => {
|
|
100
|
+
const resultProcess = (0, parse_1.calcProcStatLinux)(element, all, cpuBaseline);
|
|
101
|
+
if (resultProcess.pid) {
|
|
102
|
+
let listPos = -1;
|
|
103
|
+
for (let i = 0; i < result.length; i++) {
|
|
104
|
+
for (let j = 0; j < result[i].pids.length; j++) {
|
|
105
|
+
if (result[i].pids[j] === resultProcess.pid) {
|
|
106
|
+
listPos = i;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (listPos >= 0) {
|
|
111
|
+
result[listPos].cpu += resultProcess.cpuu + resultProcess.cpus;
|
|
112
|
+
}
|
|
113
|
+
list_new[resultProcess.pid] = {
|
|
114
|
+
cpuu: resultProcess.cpuu,
|
|
115
|
+
cpus: resultProcess.cpus,
|
|
116
|
+
utime: resultProcess.utime,
|
|
117
|
+
stime: resultProcess.stime
|
|
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/linux/system.js
CHANGED
|
@@ -21,14 +21,8 @@ const system = async () => {
|
|
|
21
21
|
result.serial = (0, common_1.getValue)(lines, 'serial number');
|
|
22
22
|
result.uuid = (0, common_1.getValue)(lines, 'uuid').toLowerCase();
|
|
23
23
|
result.sku = (0, common_1.getValue)(lines, 'sku number');
|
|
24
|
-
const cmd = `echo -n "product_name: "; cat /sys/devices/virtual/dmi/id/product_name 2>/dev/null; echo;
|
|
25
|
-
echo -n "product_serial: "; cat /sys/devices/virtual/dmi/id/product_serial 2>/dev/null; echo;
|
|
26
|
-
echo -n "product_uuid: "; cat /sys/devices/virtual/dmi/id/product_uuid 2>/dev/null; echo;
|
|
27
|
-
echo -n "product_version: "; cat /sys/devices/virtual/dmi/id/product_version 2>/dev/null; echo;
|
|
28
|
-
echo -n "sys_vendor: "; cat /sys/devices/virtual/dmi/id/sys_vendor 2>/dev/null; echo;`;
|
|
29
24
|
try {
|
|
30
|
-
|
|
31
|
-
lines = stdout.split('\n');
|
|
25
|
+
lines = await (0, files_1.readSysfsMany)(files_1.DMI_PATH, ['product_name', 'product_serial', 'product_uuid', 'product_version', 'sys_vendor']);
|
|
32
26
|
result.manufacturer = result.manufacturer === '' ? (0, common_1.getValue)(lines, 'sys_vendor') : result.manufacturer;
|
|
33
27
|
result.model = result.model === '' ? (0, common_1.getValue)(lines, 'product_name') : result.model;
|
|
34
28
|
result.version = result.version === '' ? (0, common_1.getValue)(lines, 'product_version') : result.version;
|
package/dist/linux/time.d.ts
CHANGED
package/dist/linux/time.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.nixTime = void 0;
|
|
4
4
|
const node_os_1 = require("node:os");
|
|
5
|
-
const
|
|
6
|
-
const nixTime = () => {
|
|
5
|
+
const exec_1 = require("../common/exec");
|
|
6
|
+
const nixTime = async () => {
|
|
7
7
|
try {
|
|
8
|
-
const stdout = (0,
|
|
8
|
+
const { stdout } = await (0, exec_1.execSave)('date +%Z && date +%z && ls -l /etc/localtime 2>/dev/null');
|
|
9
9
|
const lines = stdout.toString().split(node_os_1.EOL);
|
|
10
10
|
if (lines.length > 3 && !lines[0]) {
|
|
11
11
|
lines.shift();
|
package/dist/linux/uuid.js
CHANGED
|
@@ -4,21 +4,15 @@ exports.uuid = void 0;
|
|
|
4
4
|
const promises_1 = require("fs/promises");
|
|
5
5
|
const common_1 = require("../common");
|
|
6
6
|
const defaults_1 = require("../common/defaults");
|
|
7
|
-
const
|
|
7
|
+
const files_1 = require("../common/files");
|
|
8
8
|
const disk_layout_1 = require("./disk-layout");
|
|
9
9
|
const uuid = async () => {
|
|
10
10
|
await (0, common_1.nextTick)();
|
|
11
11
|
const defaults = defaults_1.initUUID;
|
|
12
12
|
try {
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
echo -n "systemuuid: "; cat /sys/devices/virtual/dmi/id/product_uuid 2>/dev/null; echo;`;
|
|
17
|
-
const { stdout } = await (0, exec_1.execSave)(cmd);
|
|
18
|
-
const lines = stdout.toString().split('\n');
|
|
19
|
-
const os = (0, common_1.getValue)(lines, 'os').toLowerCase();
|
|
20
|
-
let hardware = (0, common_1.getValue)(lines, 'hardware').toLowerCase();
|
|
21
|
-
const systemuuid = (0, common_1.getValue)(lines, 'systemuuid').toLowerCase();
|
|
13
|
+
const os = ((await (0, files_1.readSysfs)('/var/lib/dbus/machine-id')) || (await (0, files_1.readSysfs)('/etc/machine-id'))).toLowerCase();
|
|
14
|
+
let hardware = (await (0, files_1.readSysfs)('/sys/class/dmi/id/product_uuid')).toLowerCase();
|
|
15
|
+
const systemuuid = (await (0, files_1.readSysfs)(`${files_1.DMI_PATH}/product_uuid`)).toLowerCase();
|
|
22
16
|
if (!hardware) {
|
|
23
17
|
const lines = (await (0, promises_1.readFile)('/proc/cpuinfo')).toString().split('\n');
|
|
24
18
|
const serial = (0, common_1.getValue)(lines, 'serial');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const serialPorts: () => Promise<import("./common/types").SerialPortData[] | null>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.serialPorts = void 0;
|
|
4
|
+
const const_1 = require("./common/const");
|
|
5
|
+
const serialPorts = async () => {
|
|
6
|
+
switch (true) {
|
|
7
|
+
case const_1.LINUX || const_1.ANDROID:
|
|
8
|
+
return (await import('./linux/serial-ports.js')).serialPorts();
|
|
9
|
+
case const_1.DARWIN:
|
|
10
|
+
return (await import('./darwin/serial-ports.js')).serialPorts();
|
|
11
|
+
case const_1.WINDOWS:
|
|
12
|
+
return (await import('./windows/serial-ports.js')).serialPorts();
|
|
13
|
+
default:
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
exports.serialPorts = serialPorts;
|
package/dist/time.d.ts
CHANGED
package/dist/versions.js
CHANGED
|
@@ -54,6 +54,7 @@ const versions = async (apps) => {
|
|
|
54
54
|
powershell: '',
|
|
55
55
|
python3: '',
|
|
56
56
|
python: '',
|
|
57
|
+
rails: '',
|
|
57
58
|
redis: '',
|
|
58
59
|
ruby: '',
|
|
59
60
|
rust: '',
|
|
@@ -61,6 +62,7 @@ const versions = async (apps) => {
|
|
|
61
62
|
tsc: '',
|
|
62
63
|
virtualbox: '',
|
|
63
64
|
vi: '',
|
|
65
|
+
vim: '',
|
|
64
66
|
vue: '',
|
|
65
67
|
yarn: '',
|
|
66
68
|
zsh: ''
|
|
@@ -412,90 +414,45 @@ const versions = async (apps) => {
|
|
|
412
414
|
});
|
|
413
415
|
}
|
|
414
416
|
if (Object.keys(appsObj.versions).includes('postgresql')) {
|
|
415
|
-
if (const_1.
|
|
416
|
-
|
|
417
|
-
.then((
|
|
418
|
-
const
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
417
|
+
if (const_1.WINDOWS) {
|
|
418
|
+
windows_1.ps.exec('Get-CimInstance Win32_Service | select caption | fl')
|
|
419
|
+
.then((stdout) => {
|
|
420
|
+
const serviceSections = (stdout ? stdout.toString() : '').split(/\n\s*\n/);
|
|
421
|
+
serviceSections.forEach((item) => {
|
|
422
|
+
const lines = item.trim().split('\r\n');
|
|
423
|
+
const srvCaption = (0, common_1.getValue)(lines, 'caption', ':', true).toLowerCase();
|
|
424
|
+
if (srvCaption.indexOf('postgresql') > -1) {
|
|
425
|
+
const parts = srvCaption.split(' server ');
|
|
426
|
+
if (parts.length > 1) {
|
|
427
|
+
appsObj.versions.postgresql = parts[1];
|
|
425
428
|
}
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
functionProcessed();
|
|
430
|
-
});
|
|
431
|
-
}
|
|
432
|
-
else {
|
|
433
|
-
functionProcessed();
|
|
434
|
-
}
|
|
429
|
+
}
|
|
430
|
+
});
|
|
431
|
+
functionProcessed();
|
|
435
432
|
})
|
|
436
433
|
.catch(() => {
|
|
437
|
-
(
|
|
438
|
-
.then((res) => {
|
|
439
|
-
const postgresql = res.stdout.split('\n')[0].split(' ') || [];
|
|
440
|
-
appsObj.versions.postgresql = postgresql.length ? postgresql[postgresql.length - 1] : '';
|
|
441
|
-
appsObj.versions.postgresql = appsObj.versions.postgresql.split('-')[0];
|
|
442
|
-
functionProcessed();
|
|
443
|
-
})
|
|
444
|
-
.catch(() => {
|
|
445
|
-
functionProcessed();
|
|
446
|
-
});
|
|
434
|
+
functionProcessed();
|
|
447
435
|
});
|
|
448
436
|
}
|
|
449
437
|
else {
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
functionProcessed();
|
|
465
|
-
})
|
|
466
|
-
.catch(() => {
|
|
467
|
-
functionProcessed();
|
|
468
|
-
});
|
|
469
|
-
}
|
|
470
|
-
else {
|
|
471
|
-
(0, exec_1.exec)('postgres -V')
|
|
472
|
-
.then((res) => {
|
|
473
|
-
if (res.stdout) {
|
|
474
|
-
const postgresql = res.stdout.split('\n')[0].split(' ') || [];
|
|
475
|
-
appsObj.versions.postgresql = postgresql.length ? postgresql[postgresql.length - 1] : '';
|
|
476
|
-
if (appsObj.versions.postgresql.includes('(') && postgresql.length >= 2 && !postgresql[postgresql.length - 2].includes('(')) {
|
|
477
|
-
appsObj.versions.postgresql = postgresql[postgresql.length - 2];
|
|
478
|
-
}
|
|
438
|
+
const parsePostgres = (stdout) => {
|
|
439
|
+
const postgresql = stdout.split('\n')[0].split(' ') || [];
|
|
440
|
+
let version = postgresql.length ? postgresql[postgresql.length - 1] : '';
|
|
441
|
+
if (version.includes('(') && postgresql.length >= 2 && !postgresql[postgresql.length - 2].includes('(')) {
|
|
442
|
+
version = postgresql[postgresql.length - 2];
|
|
443
|
+
}
|
|
444
|
+
return version.split('-')[0];
|
|
445
|
+
};
|
|
446
|
+
(async () => {
|
|
447
|
+
for (const cmd of ['postgres -V', 'pg_config --version', 'psql -V']) {
|
|
448
|
+
const { stdout } = await (0, exec_1.execSave)(cmd);
|
|
449
|
+
if (stdout) {
|
|
450
|
+
appsObj.versions.postgresql = parsePostgres(stdout);
|
|
451
|
+
break;
|
|
479
452
|
}
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
(0, exec_1.exec)('pg_config --version 2> /dev/null')
|
|
484
|
-
.then((res) => {
|
|
485
|
-
if (res.stdout) {
|
|
486
|
-
const postgresql = res.stdout.toString().split('\n')[0].split(' ') || [];
|
|
487
|
-
appsObj.versions.postgresql = postgresql.length ? postgresql[postgresql.length - 1] : '';
|
|
488
|
-
if (appsObj.versions.postgresql.includes('(') && postgresql.length >= 2 && !postgresql[postgresql.length - 2].includes('(')) {
|
|
489
|
-
appsObj.versions.postgresql = postgresql[postgresql.length - 2];
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
})
|
|
493
|
-
.catch(() => { })
|
|
494
|
-
.finally(() => {
|
|
495
|
-
functionProcessed();
|
|
496
|
-
});
|
|
497
|
-
});
|
|
498
|
-
}
|
|
453
|
+
}
|
|
454
|
+
functionProcessed();
|
|
455
|
+
})();
|
|
499
456
|
}
|
|
500
457
|
}
|
|
501
458
|
if (Object.keys(appsObj.versions).includes('perl')) {
|
|
@@ -1112,6 +1069,32 @@ const versions = async (apps) => {
|
|
|
1112
1069
|
functionProcessed();
|
|
1113
1070
|
});
|
|
1114
1071
|
}
|
|
1072
|
+
if (Object.keys(appsObj.versions).includes('rails')) {
|
|
1073
|
+
(0, exec_1.exec)('rails -v')
|
|
1074
|
+
.then((res) => {
|
|
1075
|
+
if (res.stdout) {
|
|
1076
|
+
const version = res.stdout.split('\n')[0].match(/^Rails\s+(\d+(\.\d+)*)/i);
|
|
1077
|
+
appsObj.versions.rails = version ? version[1] : '';
|
|
1078
|
+
}
|
|
1079
|
+
functionProcessed();
|
|
1080
|
+
})
|
|
1081
|
+
.catch(() => {
|
|
1082
|
+
functionProcessed();
|
|
1083
|
+
});
|
|
1084
|
+
}
|
|
1085
|
+
if (Object.keys(appsObj.versions).includes('vim')) {
|
|
1086
|
+
(0, exec_1.exec)('vim --version')
|
|
1087
|
+
.then((res) => {
|
|
1088
|
+
if (res.stdout) {
|
|
1089
|
+
const version = res.stdout.split('\n')[0].match(/\d+(\.\d+)+/);
|
|
1090
|
+
appsObj.versions.vim = version ? version[0] : '';
|
|
1091
|
+
}
|
|
1092
|
+
functionProcessed();
|
|
1093
|
+
})
|
|
1094
|
+
.catch(() => {
|
|
1095
|
+
functionProcessed();
|
|
1096
|
+
});
|
|
1097
|
+
}
|
|
1115
1098
|
}
|
|
1116
1099
|
catch (e) {
|
|
1117
1100
|
return appsObj.versions;
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.blockDevices = void 0;
|
|
3
|
+
exports.blockDevices = exports.parseBlockDevices = void 0;
|
|
4
4
|
const common_1 = require("../common");
|
|
5
5
|
const filesys_1 = require("../common/filesys");
|
|
6
6
|
const windows_1 = require("../common/windows");
|
|
7
|
-
const parseBlockDevices = (logicalDisks) => {
|
|
7
|
+
const parseBlockDevices = (logicalDisks, volumes) => {
|
|
8
8
|
const drivetypes = ['Unknown', 'NoRoot', 'Removable', 'Local', 'Network', 'CD/DVD', 'RAM'];
|
|
9
|
+
const guids = {};
|
|
10
|
+
volumes.forEach((volume) => {
|
|
11
|
+
const driveLetter = String(volume?.DriveLetter || '').toUpperCase();
|
|
12
|
+
if (driveLetter && volume.DeviceID) {
|
|
13
|
+
guids[driveLetter] = volume.DeviceID;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
9
16
|
const data = [];
|
|
10
17
|
logicalDisks.forEach((logicalDisk) => {
|
|
11
18
|
if (logicalDisk && logicalDisk.DriveType != null) {
|
|
@@ -19,6 +26,7 @@ const parseBlockDevices = (logicalDisks) => {
|
|
|
19
26
|
size: (0, common_1.toInt)(logicalDisk.Size),
|
|
20
27
|
physical: drivetype >= 0 && drivetype <= 6 ? drivetypes[drivetype] : drivetypes[0],
|
|
21
28
|
uuid: logicalDisk.VolumeSerialNumber || '',
|
|
29
|
+
guid: guids[String(logicalDisk.Caption || '').toUpperCase()] || '',
|
|
22
30
|
label: logicalDisk.VolumeName || '',
|
|
23
31
|
model: '',
|
|
24
32
|
serial: logicalDisk.VolumeSerialNumber || '',
|
|
@@ -31,14 +39,16 @@ const parseBlockDevices = (logicalDisks) => {
|
|
|
31
39
|
});
|
|
32
40
|
return data;
|
|
33
41
|
};
|
|
42
|
+
exports.parseBlockDevices = parseBlockDevices;
|
|
34
43
|
const blockDevices = async () => {
|
|
35
44
|
await (0, common_1.nextTick)();
|
|
36
45
|
try {
|
|
37
|
-
const [logicalDisks, diskDrives] = await Promise.all([
|
|
46
|
+
const [logicalDisks, diskDrives, volumes] = await Promise.all([
|
|
38
47
|
windows_1.ps.exec('Get-CimInstance -ClassName Win32_LogicalDisk | select Caption,DriveType,Name,FileSystem,Size,VolumeSerialNumber,VolumeName | ConvertTo-Json'),
|
|
39
|
-
windows_1.ps.exec("Get-WmiObject -Class Win32_diskdrive | Select-Object -Property PNPDeviceId,DeviceID, Model, Size, @{L='Partitions'; E={$_.GetRelated('Win32_DiskPartition').GetRelated('Win32_LogicalDisk') | Select-Object -Property DeviceID, VolumeName, Size, FreeSpace}} | fl")
|
|
48
|
+
windows_1.ps.exec("Get-WmiObject -Class Win32_diskdrive | Select-Object -Property PNPDeviceId,DeviceID, Model, Size, @{L='Partitions'; E={$_.GetRelated('Win32_DiskPartition').GetRelated('Win32_LogicalDisk') | Select-Object -Property DeviceID, VolumeName, Size, FreeSpace}} | fl"),
|
|
49
|
+
windows_1.ps.exec('Get-CimInstance -ClassName Win32_Volume | select DriveLetter,DeviceID | ConvertTo-Json').catch(() => null)
|
|
40
50
|
]);
|
|
41
|
-
const data = parseBlockDevices((0, windows_1.psArray)(logicalDisks));
|
|
51
|
+
const data = (0, exports.parseBlockDevices)((0, windows_1.psArray)(logicalDisks), (0, windows_1.psArray)(volumes));
|
|
42
52
|
return (0, filesys_1.matchDevicesWin)(data, String(diskDrives).split(/\n\s*\n/));
|
|
43
53
|
}
|
|
44
54
|
catch {
|
|
@@ -7,6 +7,23 @@ 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 windows_1 = require("../common/windows");
|
|
10
|
+
const hasControlCharacters = (str) => /\p{Cc}/u.test(str);
|
|
11
|
+
const diskSerialNum = (device) => {
|
|
12
|
+
const serialNum = String(device.SerialNumber || '').trim();
|
|
13
|
+
if (!hasControlCharacters(serialNum)) {
|
|
14
|
+
return serialNum;
|
|
15
|
+
}
|
|
16
|
+
const instanceId = String(device.PNPDeviceId || '')
|
|
17
|
+
.trim()
|
|
18
|
+
.split('\\')[2];
|
|
19
|
+
if (instanceId) {
|
|
20
|
+
const parts = instanceId.split('&');
|
|
21
|
+
if (parts.length === 2 && parts[1] === '0') {
|
|
22
|
+
return parts[0];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return serialNum;
|
|
26
|
+
};
|
|
10
27
|
const diskLayout = async () => {
|
|
11
28
|
await (0, common_1.nextTick)();
|
|
12
29
|
const result = [];
|
|
@@ -35,7 +52,7 @@ const diskLayout = async () => {
|
|
|
35
52
|
tracksPerCylinder: (0, common_1.toInt)(device.TracksPerCylinder),
|
|
36
53
|
sectorsPerTrack: (0, common_1.toInt)(device.SectorsPerTrack),
|
|
37
54
|
firmwareRevision: String(device.FirmwareRevision || '').trim(),
|
|
38
|
-
serialNum:
|
|
55
|
+
serialNum: diskSerialNum(device),
|
|
39
56
|
interfaceType: String(device.InterfaceType || '').trim(),
|
|
40
57
|
smartStatus: status === 'ok' ? 'Ok' : status === 'degraded' ? 'Degraded' : status === 'pred fail' ? 'Predicted Failure' : 'Unknown',
|
|
41
58
|
temperature: null
|
|
@@ -82,6 +99,9 @@ const diskLayout = async () => {
|
|
|
82
99
|
const smartDev = JSON.parse(stdout.trim());
|
|
83
100
|
if (smartDev?.devices && smartDev.devices.length > 0) {
|
|
84
101
|
for (const dev of smartDev.devices) {
|
|
102
|
+
if (!/^[\w/.,:\\-]+$/.test(String(dev.name || ''))) {
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
85
105
|
try {
|
|
86
106
|
const { stdout: smartOut } = await (0, exec_1.execSave)(`smartctl -j -a ${dev.name}`, const_1.execOptsWin);
|
|
87
107
|
const smartData = JSON.parse(smartOut);
|