systeminformation 5.27.16 → 5.28.0
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 +2 -1
- package/lib/cpu.js +232 -39
- package/lib/graphics.js +348 -241
- package/lib/network.js +1 -1
- package/lib/system.js +246 -143
- package/lib/util.js +52 -51
- package/lib/wifi.js +120 -129
- package/package.json +1 -1
package/lib/system.js
CHANGED
|
@@ -21,21 +21,19 @@ const exec = require('child_process').exec;
|
|
|
21
21
|
const execSync = require('child_process').execSync;
|
|
22
22
|
const execPromise = util.promisify(require('child_process').exec);
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
const _platform = process.platform;
|
|
25
25
|
|
|
26
|
-
const _linux =
|
|
27
|
-
const _darwin =
|
|
28
|
-
const _windows =
|
|
29
|
-
const _freebsd =
|
|
30
|
-
const _openbsd =
|
|
31
|
-
const _netbsd =
|
|
32
|
-
const _sunos =
|
|
26
|
+
const _linux = _platform === 'linux' || _platform === 'android';
|
|
27
|
+
const _darwin = _platform === 'darwin';
|
|
28
|
+
const _windows = _platform === 'win32';
|
|
29
|
+
const _freebsd = _platform === 'freebsd';
|
|
30
|
+
const _openbsd = _platform === 'openbsd';
|
|
31
|
+
const _netbsd = _platform === 'netbsd';
|
|
32
|
+
const _sunos = _platform === 'sunos';
|
|
33
33
|
|
|
34
34
|
function system(callback) {
|
|
35
|
-
|
|
36
35
|
return new Promise((resolve) => {
|
|
37
36
|
process.nextTick(() => {
|
|
38
|
-
|
|
39
37
|
let result = {
|
|
40
38
|
manufacturer: '',
|
|
41
39
|
model: 'Computer',
|
|
@@ -47,13 +45,13 @@ function system(callback) {
|
|
|
47
45
|
};
|
|
48
46
|
|
|
49
47
|
if (_linux || _freebsd || _openbsd || _netbsd) {
|
|
50
|
-
exec('export LC_ALL=C; dmidecode -t system 2>/dev/null; unset LC_ALL',
|
|
48
|
+
exec('export LC_ALL=C; dmidecode -t system 2>/dev/null; unset LC_ALL', (error, stdout) => {
|
|
51
49
|
let lines = stdout.toString().split('\n');
|
|
52
50
|
result.manufacturer = cleanDefaults(util.getValue(lines, 'manufacturer'));
|
|
53
51
|
result.model = cleanDefaults(util.getValue(lines, 'product name'));
|
|
54
52
|
result.version = cleanDefaults(util.getValue(lines, 'version'));
|
|
55
53
|
result.serial = cleanDefaults(util.getValue(lines, 'serial number'));
|
|
56
|
-
result.uuid = cleanDefaults(
|
|
54
|
+
result.uuid = cleanDefaults(util.getValue(lines, 'uuid')).toLowerCase();
|
|
57
55
|
result.sku = cleanDefaults(util.getValue(lines, 'sku number'));
|
|
58
56
|
// Non-Root values
|
|
59
57
|
const cmd = `echo -n "product_name: "; cat /sys/devices/virtual/dmi/id/product_name 2>/dev/null; echo;
|
|
@@ -68,17 +66,34 @@ function system(callback) {
|
|
|
68
66
|
result.version = cleanDefaults(result.version === '' ? util.getValue(lines, 'product_version') : result.version);
|
|
69
67
|
result.serial = cleanDefaults(result.serial === '' ? util.getValue(lines, 'product_serial') : result.serial);
|
|
70
68
|
result.uuid = cleanDefaults(result.uuid === '' ? util.getValue(lines, 'product_uuid').toLowerCase() : result.uuid);
|
|
71
|
-
} catch
|
|
69
|
+
} catch {
|
|
72
70
|
util.noop();
|
|
73
71
|
}
|
|
74
|
-
if (!result.serial) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
if (!result.
|
|
78
|
-
|
|
72
|
+
if (!result.serial) {
|
|
73
|
+
result.serial = '-';
|
|
74
|
+
}
|
|
75
|
+
if (!result.manufacturer) {
|
|
76
|
+
result.manufacturer = '';
|
|
77
|
+
}
|
|
78
|
+
if (!result.model) {
|
|
79
|
+
result.model = 'Computer';
|
|
80
|
+
}
|
|
81
|
+
if (!result.version) {
|
|
82
|
+
result.version = '';
|
|
83
|
+
}
|
|
84
|
+
if (!result.sku) {
|
|
85
|
+
result.sku = '-';
|
|
86
|
+
}
|
|
79
87
|
|
|
80
88
|
// detect virtual (1)
|
|
81
|
-
if (
|
|
89
|
+
if (
|
|
90
|
+
result.model.toLowerCase() === 'virtualbox' ||
|
|
91
|
+
result.model.toLowerCase() === 'kvm' ||
|
|
92
|
+
result.model.toLowerCase() === 'virtual machine' ||
|
|
93
|
+
result.model.toLowerCase() === 'bochs' ||
|
|
94
|
+
result.model.toLowerCase().startsWith('vmware') ||
|
|
95
|
+
result.model.toLowerCase().startsWith('droplet')
|
|
96
|
+
) {
|
|
82
97
|
result.virtual = true;
|
|
83
98
|
switch (result.model.toLowerCase()) {
|
|
84
99
|
case 'virtualbox':
|
|
@@ -117,7 +132,7 @@ function system(callback) {
|
|
|
117
132
|
result.virtual = true;
|
|
118
133
|
result.virtualHost = 'VirtualBox';
|
|
119
134
|
}
|
|
120
|
-
} catch
|
|
135
|
+
} catch {
|
|
121
136
|
util.noop();
|
|
122
137
|
}
|
|
123
138
|
}
|
|
@@ -133,7 +148,7 @@ function system(callback) {
|
|
|
133
148
|
if (!result.model || result.model === 'Computer') {
|
|
134
149
|
result.model = util.getValue(lines, 'hw.model', ':').trim();
|
|
135
150
|
}
|
|
136
|
-
} catch
|
|
151
|
+
} catch {
|
|
137
152
|
util.noop();
|
|
138
153
|
}
|
|
139
154
|
}
|
|
@@ -163,7 +178,7 @@ function system(callback) {
|
|
|
163
178
|
result.virtualHost = 'bochs';
|
|
164
179
|
break;
|
|
165
180
|
}
|
|
166
|
-
} catch
|
|
181
|
+
} catch {
|
|
167
182
|
util.noop();
|
|
168
183
|
}
|
|
169
184
|
}
|
|
@@ -174,9 +189,11 @@ function system(callback) {
|
|
|
174
189
|
try {
|
|
175
190
|
const stdout = execSync('dmesg 2>/dev/null | grep -iE "virtual|hypervisor" | grep -iE "vmware|qemu|kvm|xen" | grep -viE "Nested Virtualization|/virtual/"');
|
|
176
191
|
// detect virtual machines
|
|
177
|
-
|
|
192
|
+
const lines = stdout.toString().split('\n');
|
|
178
193
|
if (lines.length > 0) {
|
|
179
|
-
if (result.model === 'Computer') {
|
|
194
|
+
if (result.model === 'Computer') {
|
|
195
|
+
result.model = 'Virtual machine';
|
|
196
|
+
}
|
|
180
197
|
result.virtual = true;
|
|
181
198
|
if (stdout.toString().toLowerCase().indexOf('vmware') >= 0 && !result.virtualHost) {
|
|
182
199
|
result.virtualHost = 'VMware';
|
|
@@ -191,13 +208,13 @@ function system(callback) {
|
|
|
191
208
|
result.virtualHost = 'KVM';
|
|
192
209
|
}
|
|
193
210
|
}
|
|
194
|
-
} catch
|
|
211
|
+
} catch {
|
|
195
212
|
util.noop();
|
|
196
213
|
}
|
|
197
214
|
|
|
198
215
|
if (result.manufacturer === '' && result.model === 'Computer' && result.version === '') {
|
|
199
216
|
// Check Raspberry Pi
|
|
200
|
-
fs.readFile('/proc/cpuinfo',
|
|
217
|
+
fs.readFile('/proc/cpuinfo', (error, stdout) => {
|
|
201
218
|
if (!error) {
|
|
202
219
|
let lines = stdout.toString().split('\n');
|
|
203
220
|
result.model = util.getValue(lines, 'hardware', ':', true).toUpperCase();
|
|
@@ -219,23 +236,25 @@ function system(callback) {
|
|
|
219
236
|
};
|
|
220
237
|
}
|
|
221
238
|
}
|
|
222
|
-
if (callback) {
|
|
239
|
+
if (callback) {
|
|
240
|
+
callback(result);
|
|
241
|
+
}
|
|
223
242
|
resolve(result);
|
|
224
243
|
});
|
|
225
244
|
} else {
|
|
226
|
-
if (callback) {
|
|
245
|
+
if (callback) {
|
|
246
|
+
callback(result);
|
|
247
|
+
}
|
|
227
248
|
resolve(result);
|
|
228
249
|
}
|
|
229
250
|
});
|
|
230
251
|
}
|
|
231
252
|
if (_darwin) {
|
|
232
|
-
exec('ioreg -c IOPlatformExpertDevice -d 2',
|
|
253
|
+
exec('ioreg -c IOPlatformExpertDevice -d 2', (error, stdout) => {
|
|
233
254
|
if (!error) {
|
|
234
|
-
|
|
255
|
+
const lines = stdout.toString().replace(/[<>"]/g, '').split('\n');
|
|
235
256
|
|
|
236
257
|
const model = util.getAppleModel(util.getValue(lines, 'model', '=', true));
|
|
237
|
-
// const modelParts = util.splitByNumber(model);
|
|
238
|
-
// const version = util.getValue(lines, 'version', '=', true);
|
|
239
258
|
result.manufacturer = util.getValue(lines, 'manufacturer', '=', true);
|
|
240
259
|
result.model = model.key;
|
|
241
260
|
result.type = macOsChassisType(model.version);
|
|
@@ -244,19 +263,23 @@ function system(callback) {
|
|
|
244
263
|
result.uuid = util.getValue(lines, 'ioplatformuuid', '=', true).toLowerCase();
|
|
245
264
|
result.sku = util.getValue(lines, 'board-id', '=', true) || util.getValue(lines, 'target-sub-type', '=', true);
|
|
246
265
|
}
|
|
247
|
-
if (callback) {
|
|
266
|
+
if (callback) {
|
|
267
|
+
callback(result);
|
|
268
|
+
}
|
|
248
269
|
resolve(result);
|
|
249
270
|
});
|
|
250
271
|
}
|
|
251
272
|
if (_sunos) {
|
|
252
|
-
if (callback) {
|
|
273
|
+
if (callback) {
|
|
274
|
+
callback(result);
|
|
275
|
+
}
|
|
253
276
|
resolve(result);
|
|
254
277
|
}
|
|
255
278
|
if (_windows) {
|
|
256
279
|
try {
|
|
257
280
|
util.powerShell('Get-CimInstance Win32_ComputerSystemProduct | select Name,Vendor,Version,IdentifyingNumber,UUID | fl').then((stdout, error) => {
|
|
258
281
|
if (!error) {
|
|
259
|
-
|
|
282
|
+
const lines = stdout.split('\r\n');
|
|
260
283
|
result.manufacturer = util.getValue(lines, 'vendor', ':');
|
|
261
284
|
result.model = util.getValue(lines, 'name', ':');
|
|
262
285
|
result.version = util.getValue(lines, 'version', ':');
|
|
@@ -264,33 +287,68 @@ function system(callback) {
|
|
|
264
287
|
result.uuid = util.getValue(lines, 'uuid', ':').toLowerCase();
|
|
265
288
|
// detect virtual (1)
|
|
266
289
|
const model = result.model.toLowerCase();
|
|
267
|
-
if (
|
|
290
|
+
if (
|
|
291
|
+
model === 'virtualbox' ||
|
|
292
|
+
model === 'kvm' ||
|
|
293
|
+
model === 'virtual machine' ||
|
|
294
|
+
model === 'bochs' ||
|
|
295
|
+
model.startsWith('vmware') ||
|
|
296
|
+
model.startsWith('qemu') ||
|
|
297
|
+
model.startsWith('parallels')
|
|
298
|
+
) {
|
|
268
299
|
result.virtual = true;
|
|
269
|
-
if (model.startsWith('virtualbox')) {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
if (model.startsWith('
|
|
273
|
-
|
|
274
|
-
|
|
300
|
+
if (model.startsWith('virtualbox')) {
|
|
301
|
+
result.virtualHost = 'VirtualBox';
|
|
302
|
+
}
|
|
303
|
+
if (model.startsWith('vmware')) {
|
|
304
|
+
result.virtualHost = 'VMware';
|
|
305
|
+
}
|
|
306
|
+
if (model.startsWith('kvm')) {
|
|
307
|
+
result.virtualHost = 'KVM';
|
|
308
|
+
}
|
|
309
|
+
if (model.startsWith('bochs')) {
|
|
310
|
+
result.virtualHost = 'bochs';
|
|
311
|
+
}
|
|
312
|
+
if (model.startsWith('qemu')) {
|
|
313
|
+
result.virtualHost = 'KVM';
|
|
314
|
+
}
|
|
315
|
+
if (model.startsWith('parallels')) {
|
|
316
|
+
result.virtualHost = 'Parallels';
|
|
317
|
+
}
|
|
275
318
|
}
|
|
276
319
|
const manufacturer = result.manufacturer.toLowerCase();
|
|
277
320
|
if (manufacturer.startsWith('vmware') || manufacturer.startsWith('qemu') || manufacturer === 'xen' || manufacturer.startsWith('parallels')) {
|
|
278
321
|
result.virtual = true;
|
|
279
|
-
if (manufacturer.startsWith('vmware')) {
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
if (manufacturer.startsWith('
|
|
322
|
+
if (manufacturer.startsWith('vmware')) {
|
|
323
|
+
result.virtualHost = 'VMware';
|
|
324
|
+
}
|
|
325
|
+
if (manufacturer.startsWith('xen')) {
|
|
326
|
+
result.virtualHost = 'Xen';
|
|
327
|
+
}
|
|
328
|
+
if (manufacturer.startsWith('qemu')) {
|
|
329
|
+
result.virtualHost = 'KVM';
|
|
330
|
+
}
|
|
331
|
+
if (manufacturer.startsWith('parallels')) {
|
|
332
|
+
result.virtualHost = 'Parallels';
|
|
333
|
+
}
|
|
283
334
|
}
|
|
284
335
|
util.powerShell('Get-CimInstance MS_Systeminformation -Namespace "root/wmi" | select systemsku | fl ').then((stdout, error) => {
|
|
285
336
|
if (!error) {
|
|
286
|
-
|
|
337
|
+
const lines = stdout.split('\r\n');
|
|
287
338
|
result.sku = util.getValue(lines, 'systemsku', ':');
|
|
288
339
|
}
|
|
289
340
|
if (!result.virtual) {
|
|
290
341
|
util.powerShell('Get-CimInstance Win32_bios | select Version, SerialNumber, SMBIOSBIOSVersion').then((stdout, error) => {
|
|
291
342
|
if (!error) {
|
|
292
343
|
let lines = stdout.toString();
|
|
293
|
-
if (
|
|
344
|
+
if (
|
|
345
|
+
lines.indexOf('VRTUAL') >= 0 ||
|
|
346
|
+
lines.indexOf('A M I ') >= 0 ||
|
|
347
|
+
lines.indexOf('VirtualBox') >= 0 ||
|
|
348
|
+
lines.indexOf('VMWare') >= 0 ||
|
|
349
|
+
lines.indexOf('Xen') >= 0 ||
|
|
350
|
+
lines.indexOf('Parallels') >= 0
|
|
351
|
+
) {
|
|
294
352
|
result.virtual = true;
|
|
295
353
|
if (lines.indexOf('VirtualBox') >= 0 && !result.virtualHost) {
|
|
296
354
|
result.virtualHost = 'VirtualBox';
|
|
@@ -311,25 +369,35 @@ function system(callback) {
|
|
|
311
369
|
result.virtualHost = 'Parallels';
|
|
312
370
|
}
|
|
313
371
|
}
|
|
314
|
-
if (callback) {
|
|
372
|
+
if (callback) {
|
|
373
|
+
callback(result);
|
|
374
|
+
}
|
|
315
375
|
resolve(result);
|
|
316
376
|
} else {
|
|
317
|
-
if (callback) {
|
|
377
|
+
if (callback) {
|
|
378
|
+
callback(result);
|
|
379
|
+
}
|
|
318
380
|
resolve(result);
|
|
319
381
|
}
|
|
320
382
|
});
|
|
321
383
|
} else {
|
|
322
|
-
if (callback) {
|
|
384
|
+
if (callback) {
|
|
385
|
+
callback(result);
|
|
386
|
+
}
|
|
323
387
|
resolve(result);
|
|
324
388
|
}
|
|
325
389
|
});
|
|
326
390
|
} else {
|
|
327
|
-
if (callback) {
|
|
391
|
+
if (callback) {
|
|
392
|
+
callback(result);
|
|
393
|
+
}
|
|
328
394
|
resolve(result);
|
|
329
395
|
}
|
|
330
396
|
});
|
|
331
|
-
} catch
|
|
332
|
-
if (callback) {
|
|
397
|
+
} catch {
|
|
398
|
+
if (callback) {
|
|
399
|
+
callback(result);
|
|
400
|
+
}
|
|
333
401
|
resolve(result);
|
|
334
402
|
}
|
|
335
403
|
}
|
|
@@ -347,15 +415,13 @@ function cleanDefaults(s) {
|
|
|
347
415
|
return '';
|
|
348
416
|
}
|
|
349
417
|
function bios(callback) {
|
|
350
|
-
|
|
351
418
|
return new Promise((resolve) => {
|
|
352
419
|
process.nextTick(() => {
|
|
353
|
-
|
|
354
420
|
let result = {
|
|
355
421
|
vendor: '',
|
|
356
422
|
version: '',
|
|
357
423
|
releaseDate: '',
|
|
358
|
-
revision: ''
|
|
424
|
+
revision: ''
|
|
359
425
|
};
|
|
360
426
|
let cmd = '';
|
|
361
427
|
if (_linux || _freebsd || _openbsd || _netbsd) {
|
|
@@ -364,7 +430,7 @@ function bios(callback) {
|
|
|
364
430
|
} else {
|
|
365
431
|
cmd = 'export LC_ALL=C; dmidecode -t bios 2>/dev/null; unset LC_ALL';
|
|
366
432
|
}
|
|
367
|
-
exec(cmd,
|
|
433
|
+
exec(cmd, (error, stdout) => {
|
|
368
434
|
let lines = stdout.toString().split('\n');
|
|
369
435
|
result.vendor = util.getValue(lines, 'Vendor');
|
|
370
436
|
result.version = util.getValue(lines, 'Version');
|
|
@@ -378,7 +444,7 @@ function bios(callback) {
|
|
|
378
444
|
}
|
|
379
445
|
if (lines.length && stdout.toString().indexOf('Characteristics:') >= 0) {
|
|
380
446
|
const features = [];
|
|
381
|
-
lines.forEach(line => {
|
|
447
|
+
lines.forEach((line) => {
|
|
382
448
|
if (line.indexOf(' is supported') >= 0) {
|
|
383
449
|
const feature = line.split(' is supported')[0].trim();
|
|
384
450
|
features.push(feature);
|
|
@@ -399,62 +465,75 @@ function bios(callback) {
|
|
|
399
465
|
} catch (e) {
|
|
400
466
|
util.noop();
|
|
401
467
|
}
|
|
402
|
-
if (callback) {
|
|
468
|
+
if (callback) {
|
|
469
|
+
callback(result);
|
|
470
|
+
}
|
|
403
471
|
resolve(result);
|
|
404
472
|
});
|
|
405
473
|
}
|
|
406
474
|
if (_darwin) {
|
|
407
475
|
result.vendor = 'Apple Inc.';
|
|
408
|
-
exec(
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
result.version = bootRomVersion;
|
|
416
|
-
}
|
|
417
|
-
} catch (e) {
|
|
418
|
-
util.noop();
|
|
476
|
+
exec('system_profiler SPHardwareDataType -json', (error, stdout) => {
|
|
477
|
+
try {
|
|
478
|
+
const hardwareData = JSON.parse(stdout.toString());
|
|
479
|
+
if (hardwareData && hardwareData.SPHardwareDataType && hardwareData.SPHardwareDataType.length) {
|
|
480
|
+
let bootRomVersion = hardwareData.SPHardwareDataType[0].boot_rom_version;
|
|
481
|
+
bootRomVersion = bootRomVersion ? bootRomVersion.split('(')[0].trim() : null;
|
|
482
|
+
result.version = bootRomVersion;
|
|
419
483
|
}
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
}
|
|
484
|
+
} catch (e) {
|
|
485
|
+
util.noop();
|
|
486
|
+
}
|
|
487
|
+
if (callback) {
|
|
488
|
+
callback(result);
|
|
489
|
+
}
|
|
490
|
+
resolve(result);
|
|
491
|
+
});
|
|
423
492
|
}
|
|
424
493
|
if (_sunos) {
|
|
425
494
|
result.vendor = 'Sun Microsystems';
|
|
426
|
-
if (callback) {
|
|
495
|
+
if (callback) {
|
|
496
|
+
callback(result);
|
|
497
|
+
}
|
|
427
498
|
resolve(result);
|
|
428
499
|
}
|
|
429
500
|
if (_windows) {
|
|
430
501
|
try {
|
|
431
|
-
util
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
if (
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
502
|
+
util
|
|
503
|
+
.powerShell(
|
|
504
|
+
'Get-CimInstance Win32_bios | select Description,Version,Manufacturer,@{n="ReleaseDate";e={$_.ReleaseDate.ToString("yyyy-MM-dd")}},BuildNumber,SerialNumber,SMBIOSBIOSVersion | fl'
|
|
505
|
+
)
|
|
506
|
+
.then((stdout, error) => {
|
|
507
|
+
if (!error) {
|
|
508
|
+
let lines = stdout.toString().split('\r\n');
|
|
509
|
+
const description = util.getValue(lines, 'description', ':');
|
|
510
|
+
const version = util.getValue(lines, 'SMBIOSBIOSVersion', ':');
|
|
511
|
+
if (description.indexOf(' Version ') !== -1) {
|
|
512
|
+
// ... Phoenix ROM BIOS PLUS Version 1.10 A04
|
|
513
|
+
result.vendor = description.split(' Version ')[0].trim();
|
|
514
|
+
result.version = description.split(' Version ')[1].trim();
|
|
515
|
+
} else if (description.indexOf(' Ver: ') !== -1) {
|
|
516
|
+
// ... BIOS Date: 06/27/16 17:50:16 Ver: 1.4.5
|
|
517
|
+
result.vendor = util.getValue(lines, 'manufacturer', ':');
|
|
518
|
+
result.version = description.split(' Ver: ')[1].trim();
|
|
519
|
+
} else {
|
|
520
|
+
result.vendor = util.getValue(lines, 'manufacturer', ':');
|
|
521
|
+
result.version = version || util.getValue(lines, 'version', ':');
|
|
522
|
+
}
|
|
523
|
+
result.releaseDate = util.getValue(lines, 'releasedate', ':');
|
|
524
|
+
result.revision = util.getValue(lines, 'buildnumber', ':');
|
|
525
|
+
result.serial = cleanDefaults(util.getValue(lines, 'serialnumber', ':'));
|
|
447
526
|
}
|
|
448
|
-
result.releaseDate = util.getValue(lines, 'releasedate', ':');
|
|
449
|
-
result.revision = util.getValue(lines, 'buildnumber', ':');
|
|
450
|
-
result.serial = cleanDefaults(util.getValue(lines, 'serialnumber', ':'));
|
|
451
|
-
}
|
|
452
527
|
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
528
|
+
if (callback) {
|
|
529
|
+
callback(result);
|
|
530
|
+
}
|
|
531
|
+
resolve(result);
|
|
532
|
+
});
|
|
456
533
|
} catch (e) {
|
|
457
|
-
if (callback) {
|
|
534
|
+
if (callback) {
|
|
535
|
+
callback(result);
|
|
536
|
+
}
|
|
458
537
|
resolve(result);
|
|
459
538
|
}
|
|
460
539
|
}
|
|
@@ -465,11 +544,9 @@ function bios(callback) {
|
|
|
465
544
|
exports.bios = bios;
|
|
466
545
|
|
|
467
546
|
function baseboard(callback) {
|
|
468
|
-
|
|
469
547
|
return new Promise((resolve) => {
|
|
470
548
|
process.nextTick(() => {
|
|
471
|
-
|
|
472
|
-
let result = {
|
|
549
|
+
const result = {
|
|
473
550
|
manufacturer: '',
|
|
474
551
|
model: '',
|
|
475
552
|
version: '',
|
|
@@ -489,9 +566,7 @@ function baseboard(callback) {
|
|
|
489
566
|
const workload = [];
|
|
490
567
|
workload.push(execPromise(cmd));
|
|
491
568
|
workload.push(execPromise('export LC_ALL=C; dmidecode -t memory 2>/dev/null'));
|
|
492
|
-
util.promiseAll(
|
|
493
|
-
workload
|
|
494
|
-
).then((data) => {
|
|
569
|
+
util.promiseAll(workload).then((data) => {
|
|
495
570
|
let lines = data.results[0] ? data.results[0].toString().split('\n') : [''];
|
|
496
571
|
result.manufacturer = cleanDefaults(util.getValue(lines, 'Manufacturer'));
|
|
497
572
|
result.model = cleanDefaults(util.getValue(lines, 'Product Name'));
|
|
@@ -511,7 +586,7 @@ function baseboard(callback) {
|
|
|
511
586
|
result.version = cleanDefaults(!result.version ? util.getValue(lines, 'board_version') : result.version);
|
|
512
587
|
result.serial = cleanDefaults(!result.serial ? util.getValue(lines, 'board_serial') : result.serial);
|
|
513
588
|
result.assetTag = cleanDefaults(!result.assetTag ? util.getValue(lines, 'board_asset_tag') : result.assetTag);
|
|
514
|
-
} catch
|
|
589
|
+
} catch {
|
|
515
590
|
util.noop();
|
|
516
591
|
}
|
|
517
592
|
|
|
@@ -531,7 +606,9 @@ function baseboard(callback) {
|
|
|
531
606
|
result.memSlots = 0;
|
|
532
607
|
}
|
|
533
608
|
|
|
534
|
-
if (callback) {
|
|
609
|
+
if (callback) {
|
|
610
|
+
callback(result);
|
|
611
|
+
}
|
|
535
612
|
resolve(result);
|
|
536
613
|
});
|
|
537
614
|
}
|
|
@@ -539,10 +616,8 @@ function baseboard(callback) {
|
|
|
539
616
|
const workload = [];
|
|
540
617
|
workload.push(execPromise('ioreg -c IOPlatformExpertDevice -d 2'));
|
|
541
618
|
workload.push(execPromise('system_profiler SPMemoryDataType'));
|
|
542
|
-
util.promiseAll(
|
|
543
|
-
|
|
544
|
-
).then((data) => {
|
|
545
|
-
let lines = data.results[0] ? data.results[0].toString().replace(/[<>"]/g, '').split('\n') : [''];
|
|
619
|
+
util.promiseAll(workload).then((data) => {
|
|
620
|
+
const lines = data.results[0] ? data.results[0].toString().replace(/[<>"]/g, '').split('\n') : [''];
|
|
546
621
|
result.manufacturer = util.getValue(lines, 'manufacturer', '=', true);
|
|
547
622
|
result.model = util.getValue(lines, 'model', '=', true);
|
|
548
623
|
result.version = util.getValue(lines, 'version', '=', true);
|
|
@@ -562,12 +637,16 @@ function baseboard(callback) {
|
|
|
562
637
|
result.memMax = os.totalmem();
|
|
563
638
|
}
|
|
564
639
|
|
|
565
|
-
if (callback) {
|
|
640
|
+
if (callback) {
|
|
641
|
+
callback(result);
|
|
642
|
+
}
|
|
566
643
|
resolve(result);
|
|
567
644
|
});
|
|
568
645
|
}
|
|
569
646
|
if (_sunos) {
|
|
570
|
-
if (callback) {
|
|
647
|
+
if (callback) {
|
|
648
|
+
callback(result);
|
|
649
|
+
}
|
|
571
650
|
resolve(result);
|
|
572
651
|
}
|
|
573
652
|
if (_windows) {
|
|
@@ -577,9 +656,7 @@ function baseboard(callback) {
|
|
|
577
656
|
const maxCapacityAttribute = win10plus ? 'MaxCapacityEx' : 'MaxCapacity';
|
|
578
657
|
workload.push(util.powerShell('Get-CimInstance Win32_baseboard | select Model,Manufacturer,Product,Version,SerialNumber,PartNumber,SKU | fl'));
|
|
579
658
|
workload.push(util.powerShell(`Get-CimInstance Win32_physicalmemoryarray | select ${maxCapacityAttribute}, MemoryDevices | fl`));
|
|
580
|
-
util.promiseAll(
|
|
581
|
-
workload
|
|
582
|
-
).then((data) => {
|
|
659
|
+
util.promiseAll(workload).then((data) => {
|
|
583
660
|
let lines = data.results[0] ? data.results[0].toString().split('\r\n') : [''];
|
|
584
661
|
|
|
585
662
|
result.manufacturer = cleanDefaults(util.getValue(lines, 'manufacturer', ':'));
|
|
@@ -599,11 +676,15 @@ function baseboard(callback) {
|
|
|
599
676
|
result.memMax = util.toInt(util.getValue(lines, maxCapacityAttribute, ':')) * (win10plus ? 1024 : 1) || null;
|
|
600
677
|
result.memSlots = util.toInt(util.getValue(lines, 'MemoryDevices', ':')) || null;
|
|
601
678
|
|
|
602
|
-
if (callback) {
|
|
679
|
+
if (callback) {
|
|
680
|
+
callback(result);
|
|
681
|
+
}
|
|
603
682
|
resolve(result);
|
|
604
683
|
});
|
|
605
|
-
} catch
|
|
606
|
-
if (callback) {
|
|
684
|
+
} catch {
|
|
685
|
+
if (callback) {
|
|
686
|
+
callback(result);
|
|
687
|
+
}
|
|
607
688
|
resolve(result);
|
|
608
689
|
}
|
|
609
690
|
}
|
|
@@ -615,18 +696,33 @@ exports.baseboard = baseboard;
|
|
|
615
696
|
|
|
616
697
|
function macOsChassisType(model) {
|
|
617
698
|
model = model.toLowerCase();
|
|
618
|
-
if (model.indexOf('macbookair') >= 0 || model.indexOf('macbook air') >= 0) {
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
if (model.indexOf('
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
if (model.indexOf('
|
|
699
|
+
if (model.indexOf('macbookair') >= 0 || model.indexOf('macbook air') >= 0) {
|
|
700
|
+
return 'Notebook';
|
|
701
|
+
}
|
|
702
|
+
if (model.indexOf('macbookpro') >= 0 || model.indexOf('macbook pro') >= 0) {
|
|
703
|
+
return 'Notebook';
|
|
704
|
+
}
|
|
705
|
+
if (model.indexOf('macbook') >= 0) {
|
|
706
|
+
return 'Notebook';
|
|
707
|
+
}
|
|
708
|
+
if (model.indexOf('macmini') >= 0 || model.indexOf('mac mini') >= 0) {
|
|
709
|
+
return 'Desktop';
|
|
710
|
+
}
|
|
711
|
+
if (model.indexOf('imac') >= 0) {
|
|
712
|
+
return 'Desktop';
|
|
713
|
+
}
|
|
714
|
+
if (model.indexOf('macstudio') >= 0 || model.indexOf('mac studio') >= 0) {
|
|
715
|
+
return 'Desktop';
|
|
716
|
+
}
|
|
717
|
+
if (model.indexOf('macpro') >= 0 || model.indexOf('mac pro') >= 0) {
|
|
718
|
+
return 'Tower';
|
|
719
|
+
}
|
|
625
720
|
return 'Other';
|
|
626
721
|
}
|
|
627
722
|
|
|
628
723
|
function chassis(callback) {
|
|
629
|
-
const chassisTypes = [
|
|
724
|
+
const chassisTypes = [
|
|
725
|
+
'Other',
|
|
630
726
|
'Unknown',
|
|
631
727
|
'Desktop',
|
|
632
728
|
'Low Profile Desktop',
|
|
@@ -661,12 +757,11 @@ function chassis(callback) {
|
|
|
661
757
|
'IoT Gateway ',
|
|
662
758
|
'Embedded PC',
|
|
663
759
|
'Mini PC',
|
|
664
|
-
'Stick PC'
|
|
760
|
+
'Stick PC'
|
|
665
761
|
];
|
|
666
762
|
|
|
667
763
|
return new Promise((resolve) => {
|
|
668
764
|
process.nextTick(() => {
|
|
669
|
-
|
|
670
765
|
let result = {
|
|
671
766
|
manufacturer: '',
|
|
672
767
|
model: '',
|
|
@@ -674,7 +769,7 @@ function chassis(callback) {
|
|
|
674
769
|
version: '',
|
|
675
770
|
serial: '-',
|
|
676
771
|
assetTag: '-',
|
|
677
|
-
sku: ''
|
|
772
|
+
sku: ''
|
|
678
773
|
};
|
|
679
774
|
if (_linux || _freebsd || _openbsd || _netbsd) {
|
|
680
775
|
const cmd = `echo -n "chassis_asset_tag: "; cat /sys/devices/virtual/dmi/id/chassis_asset_tag 2>/dev/null; echo;
|
|
@@ -682,26 +777,26 @@ function chassis(callback) {
|
|
|
682
777
|
echo -n "chassis_type: "; cat /sys/devices/virtual/dmi/id/chassis_type 2>/dev/null; echo;
|
|
683
778
|
echo -n "chassis_vendor: "; cat /sys/devices/virtual/dmi/id/chassis_vendor 2>/dev/null; echo;
|
|
684
779
|
echo -n "chassis_version: "; cat /sys/devices/virtual/dmi/id/chassis_version 2>/dev/null; echo;`;
|
|
685
|
-
exec(cmd,
|
|
780
|
+
exec(cmd, (error, stdout) => {
|
|
686
781
|
let lines = stdout.toString().split('\n');
|
|
687
782
|
result.manufacturer = cleanDefaults(util.getValue(lines, 'chassis_vendor'));
|
|
688
783
|
const ctype = parseInt(util.getValue(lines, 'chassis_type').replace(/\D/g, ''));
|
|
689
|
-
result.type = cleanDefaults(
|
|
784
|
+
result.type = cleanDefaults(ctype && !isNaN(ctype) && ctype < chassisTypes.length ? chassisTypes[ctype - 1] : '');
|
|
690
785
|
result.version = cleanDefaults(util.getValue(lines, 'chassis_version'));
|
|
691
786
|
result.serial = cleanDefaults(util.getValue(lines, 'chassis_serial'));
|
|
692
787
|
result.assetTag = cleanDefaults(util.getValue(lines, 'chassis_asset_tag'));
|
|
693
788
|
|
|
694
|
-
if (callback) {
|
|
789
|
+
if (callback) {
|
|
790
|
+
callback(result);
|
|
791
|
+
}
|
|
695
792
|
resolve(result);
|
|
696
793
|
});
|
|
697
794
|
}
|
|
698
795
|
if (_darwin) {
|
|
699
|
-
exec('ioreg -c IOPlatformExpertDevice -d 2',
|
|
796
|
+
exec('ioreg -c IOPlatformExpertDevice -d 2', (error, stdout) => {
|
|
700
797
|
if (!error) {
|
|
701
|
-
|
|
798
|
+
const lines = stdout.toString().replace(/[<>"]/g, '').split('\n');
|
|
702
799
|
const model = util.getAppleModel(util.getValue(lines, 'model', '=', true));
|
|
703
|
-
// const modelParts = util.splitByNumber(model);
|
|
704
|
-
// const version = util.getValue(lines, 'version', '=', true);
|
|
705
800
|
result.manufacturer = util.getValue(lines, 'manufacturer', '=', true);
|
|
706
801
|
result.model = model.key;
|
|
707
802
|
result.type = macOsChassisType(model.model);
|
|
@@ -711,12 +806,16 @@ function chassis(callback) {
|
|
|
711
806
|
result.sku = util.getValue(lines, 'target-sub-type', '=', true);
|
|
712
807
|
}
|
|
713
808
|
|
|
714
|
-
if (callback) {
|
|
809
|
+
if (callback) {
|
|
810
|
+
callback(result);
|
|
811
|
+
}
|
|
715
812
|
resolve(result);
|
|
716
813
|
});
|
|
717
814
|
}
|
|
718
815
|
if (_sunos) {
|
|
719
|
-
if (callback) {
|
|
816
|
+
if (callback) {
|
|
817
|
+
callback(result);
|
|
818
|
+
}
|
|
720
819
|
resolve(result);
|
|
721
820
|
}
|
|
722
821
|
if (_windows) {
|
|
@@ -728,7 +827,7 @@ function chassis(callback) {
|
|
|
728
827
|
result.manufacturer = cleanDefaults(util.getValue(lines, 'manufacturer', ':'));
|
|
729
828
|
result.model = cleanDefaults(util.getValue(lines, 'model', ':'));
|
|
730
829
|
const ctype = parseInt(util.getValue(lines, 'ChassisTypes', ':').replace(/\D/g, ''));
|
|
731
|
-
result.type =
|
|
830
|
+
result.type = ctype && !isNaN(ctype) && ctype < chassisTypes.length ? chassisTypes[ctype - 1] : '';
|
|
732
831
|
result.version = cleanDefaults(util.getValue(lines, 'version', ':'));
|
|
733
832
|
result.serial = cleanDefaults(util.getValue(lines, 'serialnumber', ':'));
|
|
734
833
|
result.assetTag = cleanDefaults(util.getValue(lines, 'partnumber', ':'));
|
|
@@ -738,11 +837,15 @@ function chassis(callback) {
|
|
|
738
837
|
result.sku = cleanDefaults(util.getValue(lines, 'sku', ':'));
|
|
739
838
|
}
|
|
740
839
|
|
|
741
|
-
if (callback) {
|
|
840
|
+
if (callback) {
|
|
841
|
+
callback(result);
|
|
842
|
+
}
|
|
742
843
|
resolve(result);
|
|
743
844
|
});
|
|
744
|
-
} catch
|
|
745
|
-
if (callback) {
|
|
845
|
+
} catch {
|
|
846
|
+
if (callback) {
|
|
847
|
+
callback(result);
|
|
848
|
+
}
|
|
746
849
|
resolve(result);
|
|
747
850
|
}
|
|
748
851
|
}
|