cpu added flags, virtualization; uuid added hardware
This commit is contained in:
parent
d895c23881
commit
8d01889ac2
@ -200,6 +200,8 @@ I also created a nice little command line tool called [mmon][mmon-github-url] (m
|
|||||||
| | stepping | X | X | X | X | | processor stepping |
|
| | stepping | X | X | X | X | | processor stepping |
|
||||||
| | revision | X | | X | X | | revision |
|
| | revision | X | | X | X | | revision |
|
||||||
| | voltage | | X | | | | voltage |
|
| | voltage | | X | | | | voltage |
|
||||||
|
| | flags | X | X | X | X | | CPU flags |
|
||||||
|
| | virtualization | X | X | X | X | | virtualization supported |
|
||||||
| | cache | X | X | X | X | | cache in bytes (object) |
|
| | cache | X | X | X | X | | cache in bytes (object) |
|
||||||
| | cache.l1d | X | X | X | X | | L1D (data) size |
|
| | cache.l1d | X | X | X | X | | L1D (data) size |
|
||||||
| | cache.l1i | X | X | X | X | | L1I (instruction) size |
|
| | cache.l1i | X | X | X | X | | L1I (instruction) size |
|
||||||
@ -324,6 +326,7 @@ I also created a nice little command line tool called [mmon][mmon-github-url] (m
|
|||||||
| | uefi | X | X | X | X | | OS started via UEFI |
|
| | uefi | X | X | X | X | | OS started via UEFI |
|
||||||
| si.uuid(cb) | {...} | X | X | X | X | X | object of several UUIDs |
|
| si.uuid(cb) | {...} | X | X | X | X | X | object of several UUIDs |
|
||||||
| | os | X | X | X | X | | os specific UUID |
|
| | os | X | X | X | X | | os specific UUID |
|
||||||
|
| | hardware | X | X | X | X | | hardware specific UUID |
|
||||||
| si.versions(apps, cb) | {...} | X | X | X | X | X | version information (kernel, ssl, node, ...)<br />apps param is optional for detecting<br />only specific apps/libs<br />(string, comma separated) |
|
| si.versions(apps, cb) | {...} | X | X | X | X | X | version information (kernel, ssl, node, ...)<br />apps param is optional for detecting<br />only specific apps/libs<br />(string, comma separated) |
|
||||||
| si.shell(cb) | : string | X | X | X | | | standard shell |
|
| si.shell(cb) | : string | X | X | X | | | standard shell |
|
||||||
| si.users(cb) | [{...}] | X | X | X | X | X | array of users online |
|
| si.users(cb) | [{...}] | X | X | X | X | X | array of users online |
|
||||||
|
|||||||
@ -255,6 +255,26 @@
|
|||||||
<td></td>
|
<td></td>
|
||||||
<td>voltage</td>
|
<td>voltage</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td></td>
|
||||||
|
<td>flags</td>
|
||||||
|
<td>X</td>
|
||||||
|
<td>X</td>
|
||||||
|
<td>X</td>
|
||||||
|
<td>X</td>
|
||||||
|
<td></td>
|
||||||
|
<td>CPU flags</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td></td>
|
||||||
|
<td>virtualization</td>
|
||||||
|
<td>X</td>
|
||||||
|
<td>X</td>
|
||||||
|
<td>X</td>
|
||||||
|
<td>X</td>
|
||||||
|
<td></td>
|
||||||
|
<td>supports virtualization</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td>cache</td>
|
<td>cache</td>
|
||||||
@ -329,8 +349,9 @@ si.cpu().then(data => console.log(data));</code></pre class="example">
|
|||||||
physicalCores: 8,
|
physicalCores: 8,
|
||||||
processors: 1,
|
processors: 1,
|
||||||
socket: 'LGA1151',
|
socket: 'LGA1151',
|
||||||
cache: { l1d: 262144, l1i: 262144, l2: 2, l3: 16 },
|
flags: 'fpu vme de pse ...',
|
||||||
flags: 'fpu vme de pse ...'
|
virtualization: true,
|
||||||
|
cache: { l1d: 262144, l1i: 262144, l2: 2, l3: 16 }
|
||||||
}</pre>
|
}</pre>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
10
docs/os.html
10
docs/os.html
@ -259,6 +259,16 @@ si.osInfo().then(data => console.log(data));</code></pre class="example">
|
|||||||
<td></td>
|
<td></td>
|
||||||
<td>os specific UUID</td>
|
<td>os specific UUID</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td></td>
|
||||||
|
<td>hardware</td>
|
||||||
|
<td>X</td>
|
||||||
|
<td>X</td>
|
||||||
|
<td>X</td>
|
||||||
|
<td>X</td>
|
||||||
|
<td></td>
|
||||||
|
<td>hardware specific UUID</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>si.shell(cb)</td>
|
<td>si.shell(cb)</td>
|
||||||
<td>: string</td>
|
<td>: string</td>
|
||||||
|
|||||||
1
lib/index.d.ts
vendored
1
lib/index.d.ts
vendored
@ -315,6 +315,7 @@ export namespace Systeminformation {
|
|||||||
|
|
||||||
interface UuidData {
|
interface UuidData {
|
||||||
os: string;
|
os: string;
|
||||||
|
hardware: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface VersionData {
|
interface VersionData {
|
||||||
|
|||||||
@ -14,6 +14,7 @@
|
|||||||
// ----------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------
|
||||||
|
|
||||||
const exec = require('child_process').exec;
|
const exec = require('child_process').exec;
|
||||||
|
const execFile = require('child_process').execFile;
|
||||||
const util = require('./util');
|
const util = require('./util');
|
||||||
|
|
||||||
let _platform = process.platform;
|
let _platform = process.platform;
|
||||||
@ -125,23 +126,23 @@ function inetLatency(host, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
host = host || '8.8.8.8';
|
host = host || '8.8.8.8';
|
||||||
const hostSanitized = util.isPrototypePolluted() ? '8.8.8.8' : util.sanitizeShellString(host);
|
const hostSanitized = (util.isPrototypePolluted() ? '8.8.8.8' : util.sanitizeShellString(host)).trim();
|
||||||
|
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
process.nextTick(() => {
|
process.nextTick(() => {
|
||||||
let cmd;
|
let params;
|
||||||
if (_linux || _freebsd || _openbsd || _netbsd || _darwin) {
|
if (_linux || _freebsd || _openbsd || _netbsd || _darwin) {
|
||||||
if (_linux) {
|
if (_linux) {
|
||||||
cmd = 'ping -c 2 -w 3 ' + hostSanitized + ' | grep rtt';
|
params = '-c 2 -w 3 ' + hostSanitized + ' | grep rtt';
|
||||||
}
|
}
|
||||||
if (_freebsd || _openbsd || _netbsd) {
|
if (_freebsd || _openbsd || _netbsd) {
|
||||||
cmd = 'ping -c 2 -t 3 ' + hostSanitized + ' | grep round-trip';
|
params = '-c 2 -t 3 ' + hostSanitized + ' | grep round-trip';
|
||||||
}
|
}
|
||||||
if (_darwin) {
|
if (_darwin) {
|
||||||
cmd = 'ping -c 2 -t 3 ' + hostSanitized + ' | grep avg';
|
params = '-c 2 -t 3 ' + hostSanitized + ' | grep avg';
|
||||||
}
|
}
|
||||||
|
|
||||||
exec(cmd, function (error, stdout) {
|
execFile('ping', params.split(' '), function (error, stdout) {
|
||||||
let result = null;
|
let result = null;
|
||||||
if (!error) {
|
if (!error) {
|
||||||
const line = stdout.toString().split('=');
|
const line = stdout.toString().split('=');
|
||||||
@ -157,7 +158,8 @@ function inetLatency(host, callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (_sunos) {
|
if (_sunos) {
|
||||||
exec('ping -s -a ' + hostSanitized + ' 56 2 | grep avg', { timeout: 3000 }, function (error, stdout) {
|
const params = '-s -a ' + hostSanitized + ' 56 2 | grep avg';
|
||||||
|
execFile('ping', params.split(' '), { timeout: 3000 }, function (error, stdout) {
|
||||||
let result = null;
|
let result = null;
|
||||||
if (!error) {
|
if (!error) {
|
||||||
const line = stdout.toString().split('=');
|
const line = stdout.toString().split('=');
|
||||||
@ -175,7 +177,8 @@ function inetLatency(host, callback) {
|
|||||||
if (_windows) {
|
if (_windows) {
|
||||||
let result = null;
|
let result = null;
|
||||||
try {
|
try {
|
||||||
exec('ping ' + hostSanitized + ' -n 1', util.execOptsWin, function (error, stdout) {
|
const params = hostSanitized + ' -n 1';
|
||||||
|
execFile('ping', params.split(' '), util.execOptsWin, function (error, stdout) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
let lines = stdout.toString().split('\r\n');
|
let lines = stdout.toString().split('\r\n');
|
||||||
lines.shift();
|
lines.shift();
|
||||||
|
|||||||
@ -957,7 +957,8 @@ function uuid(callback) {
|
|||||||
process.nextTick(() => {
|
process.nextTick(() => {
|
||||||
|
|
||||||
let result = {
|
let result = {
|
||||||
os: ''
|
os: '',
|
||||||
|
hardware: ''
|
||||||
};
|
};
|
||||||
let parts;
|
let parts;
|
||||||
|
|
||||||
@ -984,10 +985,13 @@ function uuid(callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (_linux) {
|
if (_linux) {
|
||||||
exec('( cat /var/lib/dbus/machine-id /etc/machine-id 2> /dev/null || hostname ) | head -n 1 || :', function (error, stdout) {
|
const cmd = `echo -n "os: "; cat /var/lib/dbus/machine-id 2> /dev/null; echo;
|
||||||
if (!error) {
|
echo -n "os: "; cat /etc/machine-id 2> /dev/null; echo;
|
||||||
result.os = stdout.toString().split('\n')[0].trim().toLowerCase();
|
echo -n "machine: "; cat /sys/class/dmi/id/product_uuid 2> /dev/null; echo;`;
|
||||||
}
|
exec(cmd, function (error, stdout) {
|
||||||
|
const lines = stdout.toString.split('\n');
|
||||||
|
result.os = util.getValue(lines, 'os').toLowerCase();
|
||||||
|
result.hardware = util.getValue(lines, 'hardware').toLowerCase();
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback(result);
|
callback(result);
|
||||||
}
|
}
|
||||||
@ -995,10 +999,14 @@ function uuid(callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (_freebsd || _openbsd || _netbsd) {
|
if (_freebsd || _openbsd || _netbsd) {
|
||||||
exec('kenv -q smbios.system.uuid', function (error, stdout) {
|
const cmd = `echo -n "os: "; sysctl -n kern.hostid; echo;
|
||||||
if (!error) {
|
echo -n "hardware: "; sysctl -n kern.hostuuid; echo;`;
|
||||||
result.os = stdout.toString().split('\n')[0].trim().toLowerCase();
|
exec(cmd, function (error, stdout) {
|
||||||
}
|
const lines = stdout.toString.split('\n');
|
||||||
|
result.os = util.getValue(lines, 'os').toLowerCase();
|
||||||
|
result.hardware = util.getValue(lines, 'hardware').toLowerCase();
|
||||||
|
if (result.os.indexOf('unknown') >= 0) { result.os = ''; }
|
||||||
|
if (result.hardware.indexOf('unknown') >= 0) { result.hardware = ''; }
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback(result);
|
callback(result);
|
||||||
}
|
}
|
||||||
@ -1007,15 +1015,18 @@ function uuid(callback) {
|
|||||||
}
|
}
|
||||||
if (_windows) {
|
if (_windows) {
|
||||||
exec('%windir%\\System32\\reg query "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography" /v MachineGuid', util.execOptsWin, function (error, stdout) {
|
exec('%windir%\\System32\\reg query "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography" /v MachineGuid', util.execOptsWin, function (error, stdout) {
|
||||||
if (!error) {
|
|
||||||
parts = stdout.toString().split('\n\r')[0].split('REG_SZ');
|
parts = stdout.toString().split('\n\r')[0].split('REG_SZ');
|
||||||
result.os = parts.length > 1 ? parts[1].replace(/\r+|\n+|\s+/ig, '').toLowerCase() : '';
|
result.os = parts.length > 1 ? parts[1].replace(/\r+|\n+|\s+/ig, '').toLowerCase() : '';
|
||||||
}
|
util.wmic('csproduct get /value').then((stdout) => {
|
||||||
|
// let lines = stdout.split('\r\n').filter(line => line.trim() !== '').filter((line, idx) => idx > 0)[0].trim().split(/\s\s+/);
|
||||||
|
let lines = stdout.split('\r\n');
|
||||||
|
result.hardware = util.getValue(lines, 'uuid', '=').toLowerCase();
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback(result);
|
callback(result);
|
||||||
}
|
}
|
||||||
resolve(result);
|
resolve(result);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -18,6 +18,8 @@ const fs = require('fs');
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
const exec = require('child_process').exec;
|
const exec = require('child_process').exec;
|
||||||
const execSync = require('child_process').execSync;
|
const execSync = require('child_process').execSync;
|
||||||
|
const execFile = require('child_process').execFile;
|
||||||
|
|
||||||
|
|
||||||
const util = require('./util');
|
const util = require('./util');
|
||||||
|
|
||||||
@ -971,7 +973,8 @@ function processLoad(proc, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (_darwin || _linux) {
|
if (_darwin || _linux) {
|
||||||
exec('ps -axo pid,pcpu,pmem,comm | grep -i ' + procSanitized + ' | grep -v grep', { maxBuffer: 1024 * 20000 }, function (error, stdout) {
|
const params = '-axo pid,pcpu,pmem,comm | grep -i ' + procSanitized + ' | grep -v grep';
|
||||||
|
execFile('ps', params.split(' '), { maxBuffer: 1024 * 20000 }, function (error, stdout) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
let lines = stdout.toString().split('\n');
|
let lines = stdout.toString().split('\n');
|
||||||
|
|
||||||
|
|||||||
@ -77,7 +77,7 @@ function system(callback) {
|
|||||||
if (!result.sku || result.sku.toLowerCase().indexOf('o.e.m.') !== -1) result.sku = '-';
|
if (!result.sku || result.sku.toLowerCase().indexOf('o.e.m.') !== -1) result.sku = '-';
|
||||||
|
|
||||||
// detect virtual (1)
|
// detect virtual (1)
|
||||||
if (result.model.toLowerCase() === 'virtualbox' || result.model.toLowerCase() === 'kvm' || result.model.toLowerCase() === 'virtual machine' || result.model.toLowerCase() === 'bochs' || result.model.toLowerCase().startsWith('vmware')) {
|
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')) {
|
||||||
result.virtual = true;
|
result.virtual = true;
|
||||||
switch (result.model.toLowerCase()) {
|
switch (result.model.toLowerCase()) {
|
||||||
case 'virtualbox':
|
case 'virtualbox':
|
||||||
@ -124,13 +124,12 @@ function system(callback) {
|
|||||||
if (fs.existsSync('/.dockerenv') || fs.existsSync('/.dockerinit')) {
|
if (fs.existsSync('/.dockerenv') || fs.existsSync('/.dockerinit')) {
|
||||||
result.model = 'Docker Container';
|
result.model = 'Docker Container';
|
||||||
}
|
}
|
||||||
if (result.manufacturer === '' && result.model === 'Computer' && result.version === '') { // still default values
|
try {
|
||||||
exec('dmesg | grep -iE "virtual|hypervisor" | grep -iE "vmware|qemu|kvm|xen"', function (error, stdout) {
|
const stdout = execSync('dmesg | grep -iE "virtual|hypervisor" | grep -iE "vmware|qemu|kvm|xen"')
|
||||||
// detect virtual machines
|
// detect virtual machines
|
||||||
if (!error) {
|
|
||||||
let lines = stdout.toString().split('\n');
|
let lines = stdout.toString().split('\n');
|
||||||
if (lines.length > 0) {
|
if (lines.length > 0) {
|
||||||
result.model = 'Virtual machine';
|
if (result.model === 'Computer') { result.model = 'Virtual machine'; }
|
||||||
result.virtual = true;
|
result.virtual = true;
|
||||||
if (stdout.toString().toLowerCase().indexOf('vmware') && !result.virtualHost) {
|
if (stdout.toString().toLowerCase().indexOf('vmware') && !result.virtualHost) {
|
||||||
result.virtualHost = 'VMware';
|
result.virtualHost = 'VMware';
|
||||||
@ -145,7 +144,10 @@ function system(callback) {
|
|||||||
result.virtualHost = 'KVM';
|
result.virtualHost = 'KVM';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
util.noop();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.manufacturer === '' && result.model === 'Computer' && result.version === '') {
|
if (result.manufacturer === '' && result.model === 'Computer' && result.version === '') {
|
||||||
// Check Raspberry Pi
|
// Check Raspberry Pi
|
||||||
fs.readFile('/proc/cpuinfo', function (error, stdout) {
|
fs.readFile('/proc/cpuinfo', function (error, stdout) {
|
||||||
@ -287,11 +289,6 @@ function system(callback) {
|
|||||||
resolve(result);
|
resolve(result);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
if (callback) { callback(result); }
|
|
||||||
resolve(result);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
if (_darwin) {
|
if (_darwin) {
|
||||||
exec('ioreg -c IOPlatformExpertDevice -d 2', function (error, stdout) {
|
exec('ioreg -c IOPlatformExpertDevice -d 2', function (error, stdout) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user