code-poltergeist-system-monitor 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of code-poltergeist-system-monitor might be problematic. Click here for more details.
- package/index.js +74 -0
- package/package.json +21 -0
- package/te/node_modules/.package-lock.json +44 -0
- package/te/node_modules/code-poltergeist-system-monitor/index.js +74 -0
- package/te/node_modules/code-poltergeist-system-monitor/package.json +21 -0
- package/te/node_modules/systeminformation/LICENSE +20 -0
- package/te/node_modules/systeminformation/README.md +1116 -0
- package/te/node_modules/systeminformation/lib/audio.js +222 -0
- package/te/node_modules/systeminformation/lib/battery.js +311 -0
- package/te/node_modules/systeminformation/lib/bluetooth.js +231 -0
- package/te/node_modules/systeminformation/lib/cli.js +91 -0
- package/te/node_modules/systeminformation/lib/cpu.js +1834 -0
- package/te/node_modules/systeminformation/lib/docker.js +758 -0
- package/te/node_modules/systeminformation/lib/dockerSocket.js +327 -0
- package/te/node_modules/systeminformation/lib/filesystem.js +1510 -0
- package/te/node_modules/systeminformation/lib/graphics.js +1125 -0
- package/te/node_modules/systeminformation/lib/index.d.ts +1041 -0
- package/te/node_modules/systeminformation/lib/index.js +504 -0
- package/te/node_modules/systeminformation/lib/internet.js +237 -0
- package/te/node_modules/systeminformation/lib/memory.js +575 -0
- package/te/node_modules/systeminformation/lib/network.js +1783 -0
- package/te/node_modules/systeminformation/lib/osinfo.js +1179 -0
- package/te/node_modules/systeminformation/lib/printer.js +210 -0
- package/te/node_modules/systeminformation/lib/processes.js +1296 -0
- package/te/node_modules/systeminformation/lib/system.js +742 -0
- package/te/node_modules/systeminformation/lib/usb.js +279 -0
- package/te/node_modules/systeminformation/lib/users.js +363 -0
- package/te/node_modules/systeminformation/lib/util.js +1373 -0
- package/te/node_modules/systeminformation/lib/virtualbox.js +107 -0
- package/te/node_modules/systeminformation/lib/wifi.js +834 -0
- package/te/node_modules/systeminformation/package.json +99 -0
- package/te/package-lock.json +52 -0
- package/te/package.json +15 -0
@@ -0,0 +1,742 @@
|
|
1
|
+
'use strict';
|
2
|
+
// @ts-check
|
3
|
+
// ==================================================================================
|
4
|
+
// system.js
|
5
|
+
// ----------------------------------------------------------------------------------
|
6
|
+
// Description: System Information - library
|
7
|
+
// for Node.js
|
8
|
+
// Copyright: (c) 2014 - 2024
|
9
|
+
// Author: Sebastian Hildebrandt
|
10
|
+
// ----------------------------------------------------------------------------------
|
11
|
+
// License: MIT
|
12
|
+
// ==================================================================================
|
13
|
+
// 2. System (Hardware, BIOS, Base Board)
|
14
|
+
// ----------------------------------------------------------------------------------
|
15
|
+
|
16
|
+
const fs = require('fs');
|
17
|
+
const os = require('os');
|
18
|
+
const util = require('./util');
|
19
|
+
const exec = require('child_process').exec;
|
20
|
+
const execSync = require('child_process').execSync;
|
21
|
+
const execPromise = util.promisify(require('child_process').exec);
|
22
|
+
|
23
|
+
let _platform = process.platform;
|
24
|
+
|
25
|
+
const _linux = (_platform === 'linux' || _platform === 'android');
|
26
|
+
const _darwin = (_platform === 'darwin');
|
27
|
+
const _windows = (_platform === 'win32');
|
28
|
+
const _freebsd = (_platform === 'freebsd');
|
29
|
+
const _openbsd = (_platform === 'openbsd');
|
30
|
+
const _netbsd = (_platform === 'netbsd');
|
31
|
+
const _sunos = (_platform === 'sunos');
|
32
|
+
|
33
|
+
function system(callback) {
|
34
|
+
|
35
|
+
return new Promise((resolve) => {
|
36
|
+
process.nextTick(() => {
|
37
|
+
|
38
|
+
let result = {
|
39
|
+
manufacturer: '',
|
40
|
+
model: 'Computer',
|
41
|
+
version: '',
|
42
|
+
serial: '-',
|
43
|
+
uuid: '-',
|
44
|
+
sku: '-',
|
45
|
+
virtual: false
|
46
|
+
};
|
47
|
+
|
48
|
+
if (_linux || _freebsd || _openbsd || _netbsd) {
|
49
|
+
exec('export LC_ALL=C; dmidecode -t system 2>/dev/null; unset LC_ALL', function (error, stdout) {
|
50
|
+
let lines = stdout.toString().split('\n');
|
51
|
+
result.manufacturer = util.getValue(lines, 'manufacturer');
|
52
|
+
result.model = util.getValue(lines, 'product name');
|
53
|
+
result.version = util.getValue(lines, 'version');
|
54
|
+
result.serial = util.getValue(lines, 'serial number');
|
55
|
+
result.uuid = util.getValue(lines, 'uuid').toLowerCase();
|
56
|
+
result.sku = util.getValue(lines, 'sku number');
|
57
|
+
// Non-Root values
|
58
|
+
const cmd = `echo -n "product_name: "; cat /sys/devices/virtual/dmi/id/product_name 2>/dev/null; echo;
|
59
|
+
echo -n "product_serial: "; cat /sys/devices/virtual/dmi/id/product_serial 2>/dev/null; echo;
|
60
|
+
echo -n "product_uuid: "; cat /sys/devices/virtual/dmi/id/product_uuid 2>/dev/null; echo;
|
61
|
+
echo -n "product_version: "; cat /sys/devices/virtual/dmi/id/product_version 2>/dev/null; echo;
|
62
|
+
echo -n "sys_vendor: "; cat /sys/devices/virtual/dmi/id/sys_vendor 2>/dev/null; echo;`;
|
63
|
+
try {
|
64
|
+
lines = execSync(cmd, util.execOptsLinux).toString().split('\n');
|
65
|
+
result.manufacturer = result.manufacturer === '' ? util.getValue(lines, 'sys_vendor') : result.manufacturer;
|
66
|
+
result.model = result.model === '' ? util.getValue(lines, 'product_name') : result.model;
|
67
|
+
result.version = result.version === '' ? util.getValue(lines, 'product_version') : result.version;
|
68
|
+
result.serial = result.serial === '' ? util.getValue(lines, 'product_serial') : result.serial;
|
69
|
+
result.uuid = result.uuid === '' ? util.getValue(lines, 'product_uuid').toLowerCase() : result.uuid;
|
70
|
+
} catch (e) {
|
71
|
+
util.noop();
|
72
|
+
}
|
73
|
+
if (!result.serial || result.serial.toLowerCase().indexOf('o.e.m.') !== -1) { result.serial = '-'; }
|
74
|
+
if (!result.manufacturer || result.manufacturer.toLowerCase().indexOf('o.e.m.') !== -1) { result.manufacturer = ''; }
|
75
|
+
if (!result.model || result.model.toLowerCase().indexOf('o.e.m.') !== -1) { result.model = 'Computer'; }
|
76
|
+
if (!result.version || result.version.toLowerCase().indexOf('o.e.m.') !== -1) { result.version = ''; }
|
77
|
+
if (!result.sku || result.sku.toLowerCase().indexOf('o.e.m.') !== -1) { result.sku = '-'; }
|
78
|
+
|
79
|
+
// detect virtual (1)
|
80
|
+
if (result.model.toLowerCase() === 'virtualbox' || result.model.toLowerCase() === 'kvm' || result.model.toLowerCase() === 'virtual machine' || result.model.toLowerCase() === 'bochs' || result.model.toLowerCase().startsWith('vmware') || result.model.toLowerCase().startsWith('droplet')) {
|
81
|
+
result.virtual = true;
|
82
|
+
switch (result.model.toLowerCase()) {
|
83
|
+
case 'virtualbox':
|
84
|
+
result.virtualHost = 'VirtualBox';
|
85
|
+
break;
|
86
|
+
case 'vmware':
|
87
|
+
result.virtualHost = 'VMware';
|
88
|
+
break;
|
89
|
+
case 'kvm':
|
90
|
+
result.virtualHost = 'KVM';
|
91
|
+
break;
|
92
|
+
case 'bochs':
|
93
|
+
result.virtualHost = 'bochs';
|
94
|
+
break;
|
95
|
+
}
|
96
|
+
}
|
97
|
+
if (result.manufacturer.toLowerCase().startsWith('vmware') || result.manufacturer.toLowerCase() === 'xen') {
|
98
|
+
result.virtual = true;
|
99
|
+
switch (result.manufacturer.toLowerCase()) {
|
100
|
+
case 'vmware':
|
101
|
+
result.virtualHost = 'VMware';
|
102
|
+
break;
|
103
|
+
case 'xen':
|
104
|
+
result.virtualHost = 'Xen';
|
105
|
+
break;
|
106
|
+
}
|
107
|
+
}
|
108
|
+
if (!result.virtual) {
|
109
|
+
try {
|
110
|
+
const disksById = execSync('ls -1 /dev/disk/by-id/ 2>/dev/null', util.execOptsLinux).toString();
|
111
|
+
if (disksById.indexOf('_QEMU_') >= 0) {
|
112
|
+
result.virtual = true;
|
113
|
+
result.virtualHost = 'QEMU';
|
114
|
+
}
|
115
|
+
if (disksById.indexOf('_VBOX_') >= 0) {
|
116
|
+
result.virtual = true;
|
117
|
+
result.virtualHost = 'VirtualBox';
|
118
|
+
}
|
119
|
+
} catch (e) {
|
120
|
+
util.noop();
|
121
|
+
}
|
122
|
+
}
|
123
|
+
if (!result.virtual && (os.release().toLowerCase().indexOf('microsoft') >= 0 || os.release().toLowerCase().endsWith('wsl2'))) {
|
124
|
+
const kernelVersion = parseFloat(os.release().toLowerCase());
|
125
|
+
result.virtual = true;
|
126
|
+
result.manufacturer = 'Microsoft';
|
127
|
+
result.model = 'WSL';
|
128
|
+
result.version = kernelVersion < 4.19 ? '1' : '2';
|
129
|
+
}
|
130
|
+
if ((_freebsd || _openbsd || _netbsd) && !result.virtualHost) {
|
131
|
+
try {
|
132
|
+
const procInfo = execSync('dmidecode -t 4', util.execOptsLinux);
|
133
|
+
const procLines = procInfo.toString().split('\n');
|
134
|
+
const procManufacturer = util.getValue(procLines, 'manufacturer', ':', true);
|
135
|
+
switch (procManufacturer.toLowerCase()) {
|
136
|
+
case 'virtualbox':
|
137
|
+
result.virtualHost = 'VirtualBox';
|
138
|
+
break;
|
139
|
+
case 'vmware':
|
140
|
+
result.virtualHost = 'VMware';
|
141
|
+
break;
|
142
|
+
case 'kvm':
|
143
|
+
result.virtualHost = 'KVM';
|
144
|
+
break;
|
145
|
+
case 'bochs':
|
146
|
+
result.virtualHost = 'bochs';
|
147
|
+
break;
|
148
|
+
}
|
149
|
+
} catch (e) {
|
150
|
+
util.noop();
|
151
|
+
}
|
152
|
+
}
|
153
|
+
// detect docker
|
154
|
+
if (fs.existsSync('/.dockerenv') || fs.existsSync('/.dockerinit')) {
|
155
|
+
result.model = 'Docker Container';
|
156
|
+
}
|
157
|
+
try {
|
158
|
+
const stdout = execSync('dmesg 2>/dev/null | grep -iE "virtual|hypervisor" | grep -iE "vmware|qemu|kvm|xen" | grep -viE "Nested Virtualization|/virtual/"');
|
159
|
+
// detect virtual machines
|
160
|
+
let lines = stdout.toString().split('\n');
|
161
|
+
if (lines.length > 0) {
|
162
|
+
if (result.model === 'Computer') { result.model = 'Virtual machine'; }
|
163
|
+
result.virtual = true;
|
164
|
+
if (stdout.toString().toLowerCase().indexOf('vmware') >= 0 && !result.virtualHost) {
|
165
|
+
result.virtualHost = 'VMware';
|
166
|
+
}
|
167
|
+
if (stdout.toString().toLowerCase().indexOf('qemu') >= 0 && !result.virtualHost) {
|
168
|
+
result.virtualHost = 'QEMU';
|
169
|
+
}
|
170
|
+
if (stdout.toString().toLowerCase().indexOf('xen') >= 0 && !result.virtualHost) {
|
171
|
+
result.virtualHost = 'Xen';
|
172
|
+
}
|
173
|
+
if (stdout.toString().toLowerCase().indexOf('kvm') >= 0 && !result.virtualHost) {
|
174
|
+
result.virtualHost = 'KVM';
|
175
|
+
}
|
176
|
+
}
|
177
|
+
} catch (e) {
|
178
|
+
util.noop();
|
179
|
+
}
|
180
|
+
|
181
|
+
if (result.manufacturer === '' && result.model === 'Computer' && result.version === '') {
|
182
|
+
// Check Raspberry Pi
|
183
|
+
fs.readFile('/proc/cpuinfo', function (error, stdout) {
|
184
|
+
if (!error) {
|
185
|
+
let lines = stdout.toString().split('\n');
|
186
|
+
result.model = util.getValue(lines, 'hardware', ':', true).toUpperCase();
|
187
|
+
result.version = util.getValue(lines, 'revision', ':', true).toLowerCase();
|
188
|
+
result.serial = util.getValue(lines, 'serial', ':', true);
|
189
|
+
const model = util.getValue(lines, 'model:', ':', true);
|
190
|
+
// reference values: https://elinux.org/RPi_HardwareHistory
|
191
|
+
// https://www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes/README.md
|
192
|
+
if ((result.model === 'BCM2835' || result.model === 'BCM2708' || result.model === 'BCM2709' || result.model === 'BCM2710' || result.model === 'BCM2711' || result.model === 'BCM2836' || result.model === 'BCM2837') && model.toLowerCase().indexOf('raspberry') >= 0) {
|
193
|
+
const rPIRevision = util.decodePiCpuinfo(lines);
|
194
|
+
result.model = rPIRevision.model;
|
195
|
+
result.version = rPIRevision.revisionCode;
|
196
|
+
result.manufacturer = 'Raspberry Pi Foundation';
|
197
|
+
result.raspberry = {
|
198
|
+
manufacturer: rPIRevision.manufacturer,
|
199
|
+
processor: rPIRevision.processor,
|
200
|
+
type: rPIRevision.type,
|
201
|
+
revision: rPIRevision.revision
|
202
|
+
};
|
203
|
+
}
|
204
|
+
}
|
205
|
+
if (callback) { callback(result); }
|
206
|
+
resolve(result);
|
207
|
+
});
|
208
|
+
} else {
|
209
|
+
if (callback) { callback(result); }
|
210
|
+
resolve(result);
|
211
|
+
}
|
212
|
+
});
|
213
|
+
}
|
214
|
+
if (_darwin) {
|
215
|
+
exec('ioreg -c IOPlatformExpertDevice -d 2', function (error, stdout) {
|
216
|
+
if (!error) {
|
217
|
+
let lines = stdout.toString().replace(/[<>"]/g, '').split('\n');
|
218
|
+
const model = util.splitByNumber(util.getValue(lines, 'model', '=', true));
|
219
|
+
const version = util.getValue(lines, 'version', '=', true);
|
220
|
+
result.manufacturer = util.getValue(lines, 'manufacturer', '=', true);
|
221
|
+
result.model = version ? util.getValue(lines, 'model', '=', true) : model[0];
|
222
|
+
result.version = version || model[1];
|
223
|
+
result.serial = util.getValue(lines, 'ioplatformserialnumber', '=', true);
|
224
|
+
result.uuid = util.getValue(lines, 'ioplatformuuid', '=', true).toLowerCase();
|
225
|
+
result.sku = util.getValue(lines, 'board-id', '=', true) || util.getValue(lines, 'target-sub-type', '=', true);
|
226
|
+
}
|
227
|
+
if (callback) { callback(result); }
|
228
|
+
resolve(result);
|
229
|
+
});
|
230
|
+
}
|
231
|
+
if (_sunos) {
|
232
|
+
if (callback) { callback(result); }
|
233
|
+
resolve(result);
|
234
|
+
}
|
235
|
+
if (_windows) {
|
236
|
+
try {
|
237
|
+
util.powerShell('Get-CimInstance Win32_ComputerSystemProduct | select Name,Vendor,Version,IdentifyingNumber,UUID | fl').then((stdout, error) => {
|
238
|
+
if (!error) {
|
239
|
+
let lines = stdout.split('\r\n');
|
240
|
+
result.manufacturer = util.getValue(lines, 'vendor', ':');
|
241
|
+
result.model = util.getValue(lines, 'name', ':');
|
242
|
+
result.version = util.getValue(lines, 'version', ':');
|
243
|
+
result.serial = util.getValue(lines, 'identifyingnumber', ':');
|
244
|
+
result.uuid = util.getValue(lines, 'uuid', ':').toLowerCase();
|
245
|
+
// detect virtual (1)
|
246
|
+
const model = result.model.toLowerCase();
|
247
|
+
if (model === 'virtualbox' || model === 'kvm' || model === 'virtual machine' || model === 'bochs' || model.startsWith('vmware') || model.startsWith('qemu') || model.startsWith('parallels')) {
|
248
|
+
result.virtual = true;
|
249
|
+
if (model.startsWith('virtualbox')) { result.virtualHost = 'VirtualBox'; }
|
250
|
+
if (model.startsWith('vmware')) { result.virtualHost = 'VMware'; }
|
251
|
+
if (model.startsWith('kvm')) { result.virtualHost = 'KVM'; }
|
252
|
+
if (model.startsWith('bochs')) { result.virtualHost = 'bochs'; }
|
253
|
+
if (model.startsWith('qemu')) { result.virtualHost = 'KVM'; }
|
254
|
+
if (model.startsWith('parallels')) { result.virtualHost = 'Parallels'; }
|
255
|
+
}
|
256
|
+
const manufacturer = result.manufacturer.toLowerCase();
|
257
|
+
if (manufacturer.startsWith('vmware') || manufacturer.startsWith('qemu') || manufacturer === 'xen' || manufacturer.startsWith('parallels')) {
|
258
|
+
result.virtual = true;
|
259
|
+
if (manufacturer.startsWith('vmware')) { result.virtualHost = 'VMware'; }
|
260
|
+
if (manufacturer.startsWith('xen')) { result.virtualHost = 'Xen'; }
|
261
|
+
if (manufacturer.startsWith('qemu')) { result.virtualHost = 'KVM'; }
|
262
|
+
if (manufacturer.startsWith('parallels')) { result.virtualHost = 'Parallels'; }
|
263
|
+
}
|
264
|
+
util.powerShell('Get-CimInstance MS_Systeminformation -Namespace "root/wmi" | select systemsku | fl ').then((stdout, error) => {
|
265
|
+
if (!error) {
|
266
|
+
let lines = stdout.split('\r\n');
|
267
|
+
result.sku = util.getValue(lines, 'systemsku', ':');
|
268
|
+
}
|
269
|
+
if (!result.virtual) {
|
270
|
+
util.powerShell('Get-CimInstance Win32_bios | select Version, SerialNumber, SMBIOSBIOSVersion').then((stdout, error) => {
|
271
|
+
if (!error) {
|
272
|
+
let lines = stdout.toString();
|
273
|
+
if (lines.indexOf('VRTUAL') >= 0 || lines.indexOf('A M I ') >= 0 || lines.indexOf('VirtualBox') >= 0 || lines.indexOf('VMWare') >= 0 || lines.indexOf('Xen') >= 0 || lines.indexOf('Parallels') >= 0) {
|
274
|
+
result.virtual = true;
|
275
|
+
if (lines.indexOf('VirtualBox') >= 0 && !result.virtualHost) {
|
276
|
+
result.virtualHost = 'VirtualBox';
|
277
|
+
}
|
278
|
+
if (lines.indexOf('VMware') >= 0 && !result.virtualHost) {
|
279
|
+
result.virtualHost = 'VMware';
|
280
|
+
}
|
281
|
+
if (lines.indexOf('Xen') >= 0 && !result.virtualHost) {
|
282
|
+
result.virtualHost = 'Xen';
|
283
|
+
}
|
284
|
+
if (lines.indexOf('VRTUAL') >= 0 && !result.virtualHost) {
|
285
|
+
result.virtualHost = 'Hyper-V';
|
286
|
+
}
|
287
|
+
if (lines.indexOf('A M I') >= 0 && !result.virtualHost) {
|
288
|
+
result.virtualHost = 'Virtual PC';
|
289
|
+
}
|
290
|
+
if (lines.indexOf('Parallels') >= 0 && !result.virtualHost) {
|
291
|
+
result.virtualHost = 'Parallels';
|
292
|
+
}
|
293
|
+
}
|
294
|
+
if (callback) { callback(result); }
|
295
|
+
resolve(result);
|
296
|
+
} else {
|
297
|
+
if (callback) { callback(result); }
|
298
|
+
resolve(result);
|
299
|
+
}
|
300
|
+
});
|
301
|
+
} else {
|
302
|
+
if (callback) { callback(result); }
|
303
|
+
resolve(result);
|
304
|
+
}
|
305
|
+
});
|
306
|
+
} else {
|
307
|
+
if (callback) { callback(result); }
|
308
|
+
resolve(result);
|
309
|
+
}
|
310
|
+
});
|
311
|
+
} catch (e) {
|
312
|
+
if (callback) { callback(result); }
|
313
|
+
resolve(result);
|
314
|
+
}
|
315
|
+
}
|
316
|
+
});
|
317
|
+
});
|
318
|
+
}
|
319
|
+
|
320
|
+
exports.system = system;
|
321
|
+
|
322
|
+
function cleanDefaults(s) {
|
323
|
+
const cmpStr = s.toLowerCase();
|
324
|
+
if (cmpStr.indexOf('o.e.m.') === -1 && cmpStr.indexOf('default string') === -1 && cmpStr !== 'default') {
|
325
|
+
return s || '';
|
326
|
+
}
|
327
|
+
return '';
|
328
|
+
}
|
329
|
+
function bios(callback) {
|
330
|
+
|
331
|
+
return new Promise((resolve) => {
|
332
|
+
process.nextTick(() => {
|
333
|
+
|
334
|
+
let result = {
|
335
|
+
vendor: '',
|
336
|
+
version: '',
|
337
|
+
releaseDate: '',
|
338
|
+
revision: '',
|
339
|
+
};
|
340
|
+
let cmd = '';
|
341
|
+
if (_linux || _freebsd || _openbsd || _netbsd) {
|
342
|
+
if (process.arch === 'arm') {
|
343
|
+
cmd = 'cat /proc/cpuinfo | grep Serial';
|
344
|
+
} else {
|
345
|
+
cmd = 'export LC_ALL=C; dmidecode -t bios 2>/dev/null; unset LC_ALL';
|
346
|
+
}
|
347
|
+
exec(cmd, function (error, stdout) {
|
348
|
+
let lines = stdout.toString().split('\n');
|
349
|
+
result.vendor = util.getValue(lines, 'Vendor');
|
350
|
+
result.version = util.getValue(lines, 'Version');
|
351
|
+
let datetime = util.getValue(lines, 'Release Date');
|
352
|
+
result.releaseDate = util.parseDateTime(datetime).date;
|
353
|
+
result.revision = util.getValue(lines, 'BIOS Revision');
|
354
|
+
result.serial = util.getValue(lines, 'SerialNumber');
|
355
|
+
let language = util.getValue(lines, 'Currently Installed Language').split('|')[0];
|
356
|
+
if (language) {
|
357
|
+
result.language = language;
|
358
|
+
}
|
359
|
+
if (lines.length && stdout.toString().indexOf('Characteristics:') >= 0) {
|
360
|
+
const features = [];
|
361
|
+
lines.forEach(line => {
|
362
|
+
if (line.indexOf(' is supported') >= 0) {
|
363
|
+
const feature = line.split(' is supported')[0].trim();
|
364
|
+
features.push(feature);
|
365
|
+
}
|
366
|
+
});
|
367
|
+
result.features = features;
|
368
|
+
}
|
369
|
+
// Non-Root values
|
370
|
+
const cmd = `echo -n "bios_date: "; cat /sys/devices/virtual/dmi/id/bios_date 2>/dev/null; echo;
|
371
|
+
echo -n "bios_vendor: "; cat /sys/devices/virtual/dmi/id/bios_vendor 2>/dev/null; echo;
|
372
|
+
echo -n "bios_version: "; cat /sys/devices/virtual/dmi/id/bios_version 2>/dev/null; echo;`;
|
373
|
+
try {
|
374
|
+
lines = execSync(cmd, util.execOptsLinux).toString().split('\n');
|
375
|
+
result.vendor = !result.vendor ? util.getValue(lines, 'bios_vendor') : result.vendor;
|
376
|
+
result.version = !result.version ? util.getValue(lines, 'bios_version') : result.version;
|
377
|
+
datetime = util.getValue(lines, 'bios_date');
|
378
|
+
result.releaseDate = !result.releaseDate ? util.parseDateTime(datetime).date : result.releaseDate;
|
379
|
+
} catch (e) {
|
380
|
+
util.noop();
|
381
|
+
}
|
382
|
+
if (callback) { callback(result); }
|
383
|
+
resolve(result);
|
384
|
+
});
|
385
|
+
}
|
386
|
+
if (_darwin) {
|
387
|
+
result.vendor = 'Apple Inc.';
|
388
|
+
exec(
|
389
|
+
'system_profiler SPHardwareDataType -json', function (error, stdout) {
|
390
|
+
try {
|
391
|
+
const hardwareData = JSON.parse(stdout.toString());
|
392
|
+
if (hardwareData && hardwareData.SPHardwareDataType && hardwareData.SPHardwareDataType.length) {
|
393
|
+
let bootRomVersion = hardwareData.SPHardwareDataType[0].boot_rom_version;
|
394
|
+
bootRomVersion = bootRomVersion ? bootRomVersion.split('(')[0].trim() : null;
|
395
|
+
result.version = bootRomVersion;
|
396
|
+
}
|
397
|
+
} catch (e) {
|
398
|
+
util.noop();
|
399
|
+
}
|
400
|
+
if (callback) { callback(result); }
|
401
|
+
resolve(result);
|
402
|
+
});
|
403
|
+
}
|
404
|
+
if (_sunos) {
|
405
|
+
result.vendor = 'Sun Microsystems';
|
406
|
+
if (callback) { callback(result); }
|
407
|
+
resolve(result);
|
408
|
+
}
|
409
|
+
if (_windows) {
|
410
|
+
try {
|
411
|
+
util.powerShell('Get-CimInstance Win32_bios | select Description,Version,Manufacturer,@{n="ReleaseDate";e={$_.ReleaseDate.ToString("yyyy-MM-dd")}},BuildNumber,SerialNumber,SMBIOSBIOSVersion | fl').then((stdout, error) => {
|
412
|
+
if (!error) {
|
413
|
+
let lines = stdout.toString().split('\r\n');
|
414
|
+
const description = util.getValue(lines, 'description', ':');
|
415
|
+
const version = util.getValue(lines, 'SMBIOSBIOSVersion', ':');
|
416
|
+
if (description.indexOf(' Version ') !== -1) {
|
417
|
+
// ... Phoenix ROM BIOS PLUS Version 1.10 A04
|
418
|
+
result.vendor = description.split(' Version ')[0].trim();
|
419
|
+
result.version = description.split(' Version ')[1].trim();
|
420
|
+
} else if (description.indexOf(' Ver: ') !== -1) {
|
421
|
+
// ... BIOS Date: 06/27/16 17:50:16 Ver: 1.4.5
|
422
|
+
result.vendor = util.getValue(lines, 'manufacturer', ':');
|
423
|
+
result.version = description.split(' Ver: ')[1].trim();
|
424
|
+
} else {
|
425
|
+
result.vendor = util.getValue(lines, 'manufacturer', ':');
|
426
|
+
result.version = version || util.getValue(lines, 'version', ':');
|
427
|
+
}
|
428
|
+
result.releaseDate = util.getValue(lines, 'releasedate', ':');
|
429
|
+
result.revision = util.getValue(lines, 'buildnumber', ':');
|
430
|
+
result.serial = cleanDefaults(util.getValue(lines, 'serialnumber', ':'));
|
431
|
+
}
|
432
|
+
|
433
|
+
if (callback) { callback(result); }
|
434
|
+
resolve(result);
|
435
|
+
});
|
436
|
+
} catch (e) {
|
437
|
+
if (callback) { callback(result); }
|
438
|
+
resolve(result);
|
439
|
+
}
|
440
|
+
}
|
441
|
+
});
|
442
|
+
});
|
443
|
+
}
|
444
|
+
|
445
|
+
exports.bios = bios;
|
446
|
+
|
447
|
+
function baseboard(callback) {
|
448
|
+
|
449
|
+
return new Promise((resolve) => {
|
450
|
+
process.nextTick(() => {
|
451
|
+
|
452
|
+
let result = {
|
453
|
+
manufacturer: '',
|
454
|
+
model: '',
|
455
|
+
version: '',
|
456
|
+
serial: '-',
|
457
|
+
assetTag: '-',
|
458
|
+
memMax: null,
|
459
|
+
memSlots: null
|
460
|
+
};
|
461
|
+
let cmd = '';
|
462
|
+
if (_linux || _freebsd || _openbsd || _netbsd) {
|
463
|
+
if (process.arch === 'arm') {
|
464
|
+
cmd = 'cat /proc/cpuinfo | grep Serial';
|
465
|
+
// 'BCM2709', 'BCM2835', 'BCM2708' -->
|
466
|
+
} else {
|
467
|
+
cmd = 'export LC_ALL=C; dmidecode -t 2 2>/dev/null; unset LC_ALL';
|
468
|
+
}
|
469
|
+
const workload = [];
|
470
|
+
workload.push(execPromise(cmd));
|
471
|
+
workload.push(execPromise('export LC_ALL=C; dmidecode -t memory 2>/dev/null'));
|
472
|
+
util.promiseAll(
|
473
|
+
workload
|
474
|
+
).then((data) => {
|
475
|
+
let lines = data.results[0] ? data.results[0].toString().split('\n') : [''];
|
476
|
+
result.manufacturer = cleanDefaults(util.getValue(lines, 'Manufacturer'));
|
477
|
+
result.model = cleanDefaults(util.getValue(lines, 'Product Name'));
|
478
|
+
result.version = cleanDefaults(util.getValue(lines, 'Version'));
|
479
|
+
result.serial = cleanDefaults(util.getValue(lines, 'Serial Number'));
|
480
|
+
result.assetTag = cleanDefaults(util.getValue(lines, 'Asset Tag'));
|
481
|
+
// Non-Root values
|
482
|
+
const cmd = `echo -n "board_asset_tag: "; cat /sys/devices/virtual/dmi/id/board_asset_tag 2>/dev/null; echo;
|
483
|
+
echo -n "board_name: "; cat /sys/devices/virtual/dmi/id/board_name 2>/dev/null; echo;
|
484
|
+
echo -n "board_serial: "; cat /sys/devices/virtual/dmi/id/board_serial 2>/dev/null; echo;
|
485
|
+
echo -n "board_vendor: "; cat /sys/devices/virtual/dmi/id/board_vendor 2>/dev/null; echo;
|
486
|
+
echo -n "board_version: "; cat /sys/devices/virtual/dmi/id/board_version 2>/dev/null; echo;`;
|
487
|
+
try {
|
488
|
+
lines = execSync(cmd, util.execOptsLinux).toString().split('\n');
|
489
|
+
result.manufacturer = cleanDefaults(!result.manufacturer ? util.getValue(lines, 'board_vendor') : result.manufacturer);
|
490
|
+
result.model = cleanDefaults(!result.model ? util.getValue(lines, 'board_name') : result.model);
|
491
|
+
result.version = cleanDefaults(!result.version ? util.getValue(lines, 'board_version') : result.version);
|
492
|
+
result.serial = cleanDefaults(!result.serial ? util.getValue(lines, 'board_serial') : result.serial);
|
493
|
+
result.assetTag = cleanDefaults(!result.assetTag ? util.getValue(lines, 'board_asset_tag') : result.assetTag);
|
494
|
+
} catch (e) {
|
495
|
+
util.noop();
|
496
|
+
}
|
497
|
+
|
498
|
+
// mem
|
499
|
+
lines = data.results[1] ? data.results[1].toString().split('\n') : [''];
|
500
|
+
result.memMax = util.toInt(util.getValue(lines, 'Maximum Capacity')) * 1024 * 1024 * 1024 || null;
|
501
|
+
result.memSlots = util.toInt(util.getValue(lines, 'Number Of Devices')) || null;
|
502
|
+
|
503
|
+
// raspberry
|
504
|
+
let linesRpi = '';
|
505
|
+
try {
|
506
|
+
linesRpi = fs.readFileSync('/proc/cpuinfo').toString().split('\n');
|
507
|
+
} catch (e) {
|
508
|
+
util.noop();
|
509
|
+
}
|
510
|
+
if (linesRpi) {
|
511
|
+
const hardware = util.getValue(linesRpi, 'hardware');
|
512
|
+
if (hardware.startsWith('BCM')) {
|
513
|
+
const rpi = util.decodePiCpuinfo(linesRpi);
|
514
|
+
result.manufacturer = rpi.manufacturer;
|
515
|
+
result.model = 'Raspberry Pi';
|
516
|
+
result.serial = rpi.serial;
|
517
|
+
result.version = rpi.type + ' - ' + rpi.revision;
|
518
|
+
result.memMax = os.totalmem();
|
519
|
+
result.memSlots = 0;
|
520
|
+
}
|
521
|
+
}
|
522
|
+
|
523
|
+
if (callback) { callback(result); }
|
524
|
+
resolve(result);
|
525
|
+
});
|
526
|
+
}
|
527
|
+
if (_darwin) {
|
528
|
+
const workload = [];
|
529
|
+
workload.push(execPromise('ioreg -c IOPlatformExpertDevice -d 2'));
|
530
|
+
workload.push(execPromise('system_profiler SPMemoryDataType'));
|
531
|
+
util.promiseAll(
|
532
|
+
workload
|
533
|
+
).then((data) => {
|
534
|
+
let lines = data.results[0] ? data.results[0].toString().replace(/[<>"]/g, '').split('\n') : [''];
|
535
|
+
result.manufacturer = util.getValue(lines, 'manufacturer', '=', true);
|
536
|
+
result.model = util.getValue(lines, 'model', '=', true);
|
537
|
+
result.version = util.getValue(lines, 'version', '=', true);
|
538
|
+
result.serial = util.getValue(lines, 'ioplatformserialnumber', '=', true);
|
539
|
+
result.assetTag = util.getValue(lines, 'board-id', '=', true);
|
540
|
+
|
541
|
+
// mem
|
542
|
+
let devices = data.results[1] ? data.results[1].toString().split(' BANK ') : [''];
|
543
|
+
if (devices.length === 1) {
|
544
|
+
devices = data.results[1] ? data.results[1].toString().split(' DIMM') : [''];
|
545
|
+
}
|
546
|
+
devices.shift();
|
547
|
+
result.memSlots = devices.length;
|
548
|
+
|
549
|
+
if (os.arch() === 'arm64') {
|
550
|
+
result.memSlots = 0;
|
551
|
+
result.memMax = os.totalmem();
|
552
|
+
}
|
553
|
+
|
554
|
+
if (callback) { callback(result); }
|
555
|
+
resolve(result);
|
556
|
+
});
|
557
|
+
}
|
558
|
+
if (_sunos) {
|
559
|
+
if (callback) { callback(result); }
|
560
|
+
resolve(result);
|
561
|
+
}
|
562
|
+
if (_windows) {
|
563
|
+
try {
|
564
|
+
const workload = [];
|
565
|
+
const win10plus = parseInt(os.release()) >= 10;
|
566
|
+
const maxCapacityAttribute = win10plus ? 'MaxCapacityEx' : 'MaxCapacity';
|
567
|
+
workload.push(util.powerShell('Get-CimInstance Win32_baseboard | select Model,Manufacturer,Product,Version,SerialNumber,PartNumber,SKU | fl'));
|
568
|
+
workload.push(util.powerShell(`Get-CimInstance Win32_physicalmemoryarray | select ${maxCapacityAttribute}, MemoryDevices | fl`));
|
569
|
+
util.promiseAll(
|
570
|
+
workload
|
571
|
+
).then((data) => {
|
572
|
+
let lines = data.results[0] ? data.results[0].toString().split('\r\n') : [''];
|
573
|
+
|
574
|
+
result.manufacturer = cleanDefaults(util.getValue(lines, 'manufacturer', ':'));
|
575
|
+
result.model = cleanDefaults(util.getValue(lines, 'model', ':'));
|
576
|
+
if (!result.model) {
|
577
|
+
result.model = cleanDefaults(util.getValue(lines, 'product', ':'));
|
578
|
+
}
|
579
|
+
result.version = cleanDefaults(util.getValue(lines, 'version', ':'));
|
580
|
+
result.serial = cleanDefaults(util.getValue(lines, 'serialnumber', ':'));
|
581
|
+
result.assetTag = cleanDefaults(util.getValue(lines, 'partnumber', ':'));
|
582
|
+
if (!result.assetTag) {
|
583
|
+
result.assetTag = cleanDefaults(util.getValue(lines, 'sku', ':'));
|
584
|
+
}
|
585
|
+
|
586
|
+
// memphysical
|
587
|
+
lines = data.results[1] ? data.results[1].toString().split('\r\n') : [''];
|
588
|
+
result.memMax = util.toInt(util.getValue(lines, maxCapacityAttribute, ':')) * (win10plus ? 1024 : 1) || null;
|
589
|
+
result.memSlots = util.toInt(util.getValue(lines, 'MemoryDevices', ':')) || null;
|
590
|
+
|
591
|
+
if (callback) { callback(result); }
|
592
|
+
resolve(result);
|
593
|
+
});
|
594
|
+
} catch (e) {
|
595
|
+
if (callback) { callback(result); }
|
596
|
+
resolve(result);
|
597
|
+
}
|
598
|
+
}
|
599
|
+
});
|
600
|
+
});
|
601
|
+
}
|
602
|
+
|
603
|
+
exports.baseboard = baseboard;
|
604
|
+
|
605
|
+
function macOsChassisType(model) {
|
606
|
+
model = model.toLowerCase();
|
607
|
+
if (model.startsWith('macbookair')) { return 'Notebook'; }
|
608
|
+
if (model.startsWith('macbookpro')) { return 'Laptop'; }
|
609
|
+
if (model.startsWith('macbook')) { return 'Notebook'; }
|
610
|
+
if (model.startsWith('macmini')) { return 'Desktop'; }
|
611
|
+
if (model.startsWith('imac')) { return 'Desktop'; }
|
612
|
+
if (model.startsWith('macstudio')) { return 'Desktop'; }
|
613
|
+
if (model.startsWith('macpro')) { return 'Tower'; }
|
614
|
+
return 'Other';
|
615
|
+
}
|
616
|
+
|
617
|
+
function chassis(callback) {
|
618
|
+
const chassisTypes = ['Other',
|
619
|
+
'Unknown',
|
620
|
+
'Desktop',
|
621
|
+
'Low Profile Desktop',
|
622
|
+
'Pizza Box',
|
623
|
+
'Mini Tower',
|
624
|
+
'Tower',
|
625
|
+
'Portable',
|
626
|
+
'Laptop',
|
627
|
+
'Notebook',
|
628
|
+
'Hand Held',
|
629
|
+
'Docking Station',
|
630
|
+
'All in One',
|
631
|
+
'Sub Notebook',
|
632
|
+
'Space-Saving',
|
633
|
+
'Lunch Box',
|
634
|
+
'Main System Chassis',
|
635
|
+
'Expansion Chassis',
|
636
|
+
'SubChassis',
|
637
|
+
'Bus Expansion Chassis',
|
638
|
+
'Peripheral Chassis',
|
639
|
+
'Storage Chassis',
|
640
|
+
'Rack Mount Chassis',
|
641
|
+
'Sealed-Case PC',
|
642
|
+
'Multi-System Chassis',
|
643
|
+
'Compact PCI',
|
644
|
+
'Advanced TCA',
|
645
|
+
'Blade',
|
646
|
+
'Blade Enclosure',
|
647
|
+
'Tablet',
|
648
|
+
'Convertible',
|
649
|
+
'Detachable',
|
650
|
+
'IoT Gateway ',
|
651
|
+
'Embedded PC',
|
652
|
+
'Mini PC',
|
653
|
+
'Stick PC',
|
654
|
+
];
|
655
|
+
|
656
|
+
return new Promise((resolve) => {
|
657
|
+
process.nextTick(() => {
|
658
|
+
|
659
|
+
let result = {
|
660
|
+
manufacturer: '',
|
661
|
+
model: '',
|
662
|
+
type: '',
|
663
|
+
version: '',
|
664
|
+
serial: '-',
|
665
|
+
assetTag: '-',
|
666
|
+
sku: '',
|
667
|
+
};
|
668
|
+
if (_linux || _freebsd || _openbsd || _netbsd) {
|
669
|
+
const cmd = `echo -n "chassis_asset_tag: "; cat /sys/devices/virtual/dmi/id/chassis_asset_tag 2>/dev/null; echo;
|
670
|
+
echo -n "chassis_serial: "; cat /sys/devices/virtual/dmi/id/chassis_serial 2>/dev/null; echo;
|
671
|
+
echo -n "chassis_type: "; cat /sys/devices/virtual/dmi/id/chassis_type 2>/dev/null; echo;
|
672
|
+
echo -n "chassis_vendor: "; cat /sys/devices/virtual/dmi/id/chassis_vendor 2>/dev/null; echo;
|
673
|
+
echo -n "chassis_version: "; cat /sys/devices/virtual/dmi/id/chassis_version 2>/dev/null; echo;`;
|
674
|
+
exec(cmd, function (error, stdout) {
|
675
|
+
let lines = stdout.toString().split('\n');
|
676
|
+
result.manufacturer = cleanDefaults(util.getValue(lines, 'chassis_vendor'));
|
677
|
+
const ctype = parseInt(util.getValue(lines, 'chassis_type').replace(/\D/g, ''));
|
678
|
+
result.type = cleanDefaults((ctype && !isNaN(ctype) && ctype < chassisTypes.length) ? chassisTypes[ctype - 1] : '');
|
679
|
+
result.version = cleanDefaults(util.getValue(lines, 'chassis_version'));
|
680
|
+
result.serial = cleanDefaults(util.getValue(lines, 'chassis_serial'));
|
681
|
+
result.assetTag = cleanDefaults(util.getValue(lines, 'chassis_asset_tag'));
|
682
|
+
|
683
|
+
if (callback) { callback(result); }
|
684
|
+
resolve(result);
|
685
|
+
});
|
686
|
+
}
|
687
|
+
if (_darwin) {
|
688
|
+
exec('ioreg -c IOPlatformExpertDevice -d 2', function (error, stdout) {
|
689
|
+
if (!error) {
|
690
|
+
let lines = stdout.toString().replace(/[<>"]/g, '').split('\n');
|
691
|
+
const model = util.getValue(lines, 'model', '=', true);
|
692
|
+
const modelParts = util.splitByNumber(model);
|
693
|
+
const version = util.getValue(lines, 'version', '=', true);
|
694
|
+
result.manufacturer = util.getValue(lines, 'manufacturer', '=', true);
|
695
|
+
result.model = version ? util.getValue(lines, 'model', '=', true) : modelParts[0];
|
696
|
+
result.type = macOsChassisType(result.model);
|
697
|
+
result.version = version || model;
|
698
|
+
result.serial = util.getValue(lines, 'ioplatformserialnumber', '=', true);
|
699
|
+
result.assetTag = util.getValue(lines, 'board-id', '=', true) || util.getValue(lines, 'target-type', '=', true);
|
700
|
+
result.sku = util.getValue(lines, 'target-sub-type', '=', true);
|
701
|
+
}
|
702
|
+
|
703
|
+
if (callback) { callback(result); }
|
704
|
+
resolve(result);
|
705
|
+
});
|
706
|
+
}
|
707
|
+
if (_sunos) {
|
708
|
+
if (callback) { callback(result); }
|
709
|
+
resolve(result);
|
710
|
+
}
|
711
|
+
if (_windows) {
|
712
|
+
try {
|
713
|
+
util.powerShell('Get-CimInstance Win32_SystemEnclosure | select Model,Manufacturer,ChassisTypes,Version,SerialNumber,PartNumber,SKU,SMBIOSAssetTag | fl').then((stdout, error) => {
|
714
|
+
if (!error) {
|
715
|
+
let lines = stdout.toString().split('\r\n');
|
716
|
+
|
717
|
+
result.manufacturer = cleanDefaults(util.getValue(lines, 'manufacturer', ':'));
|
718
|
+
result.model = cleanDefaults(util.getValue(lines, 'model', ':'));
|
719
|
+
const ctype = parseInt(util.getValue(lines, 'ChassisTypes', ':').replace(/\D/g, ''));
|
720
|
+
result.type = (ctype && !isNaN(ctype) && ctype < chassisTypes.length) ? chassisTypes[ctype - 1] : '';
|
721
|
+
result.version = cleanDefaults(util.getValue(lines, 'version', ':'));
|
722
|
+
result.serial = cleanDefaults(util.getValue(lines, 'serialnumber', ':'));
|
723
|
+
result.assetTag = cleanDefaults(util.getValue(lines, 'partnumber', ':'));
|
724
|
+
if (!result.assetTag) {
|
725
|
+
result.assetTag = cleanDefaults(util.getValue(lines, 'SMBIOSAssetTag', ':'));
|
726
|
+
}
|
727
|
+
result.sku = cleanDefaults(util.getValue(lines, 'sku', ':'));
|
728
|
+
}
|
729
|
+
|
730
|
+
if (callback) { callback(result); }
|
731
|
+
resolve(result);
|
732
|
+
});
|
733
|
+
} catch (e) {
|
734
|
+
if (callback) { callback(result); }
|
735
|
+
resolve(result);
|
736
|
+
}
|
737
|
+
}
|
738
|
+
});
|
739
|
+
});
|
740
|
+
}
|
741
|
+
|
742
|
+
exports.chassis = chassis;
|