added chassis()
This commit is contained in:
parent
d761c29e1f
commit
ad2870c0a8
12
README.md
12
README.md
@ -130,17 +130,25 @@ I also created a nice little command line tool called [mmon][mmon-github-url] (
|
||||
| | serial | X | X | X | X | | serial number |
|
||||
| | uuid | X | X | X | X | | UUID |
|
||||
| | sku | X | X | | X | | SKU number |
|
||||
| si.bios(cb) | {...} | X | X | X | X | | hardware information |
|
||||
| si.bios(cb) | {...} | X | X | X | X | | bios information |
|
||||
| | vendor | X | X | X | X | | e.g. 'AMI' |
|
||||
| | version | X | X | | X | | version |
|
||||
| | releaseDate | X | X | | X | | release date |
|
||||
| | revision | X | X | | X | | revision |
|
||||
| si.baseboard(cb) | {...} | X | X | X | X | | hardware information |
|
||||
| si.baseboard(cb) | {...} | X | X | X | X | | baseboard information |
|
||||
| | manufacturer | X | X | X | X | | e.g. 'ASUS' |
|
||||
| | model | X | X | X | X | | model / product name |
|
||||
| | version | X | X | X | X | | version |
|
||||
| | serial | X | X | X | X | | serial number |
|
||||
| | assetTag | X | X | X | X | | asset tag |
|
||||
| si.chassis(cb) | {...} | X | X | X | X | | chassis information |
|
||||
| | manufacturer | X | X | X | X | | e.g. 'MSI' |
|
||||
| | model | X | X | X | X | | model / product name |
|
||||
| | type | X | X | X | X | | model / product name |
|
||||
| | version | X | X | X | X | | version |
|
||||
| | serial | X | X | X | X | | serial number |
|
||||
| | assetTag | X | X | X | X | | asset tag |
|
||||
| | sku | | | | X | | SKU number |
|
||||
|
||||
#### 3. CPU, Memory, Disks, Battery, Graphics
|
||||
|
||||
|
||||
@ -136,7 +136,7 @@
|
||||
<td>X</td>
|
||||
<td>X</td>
|
||||
<td></td>
|
||||
<td>hardware information</td>
|
||||
<td>bios information</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
@ -186,7 +186,7 @@
|
||||
<td>X</td>
|
||||
<td>X</td>
|
||||
<td></td>
|
||||
<td>hardware information</td>
|
||||
<td>baseboard information</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
@ -238,6 +238,86 @@
|
||||
<td></td>
|
||||
<td>asset tag</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>si.chassis(cb)</td>
|
||||
<td>{...}</td>
|
||||
<td>X</td>
|
||||
<td>X</td>
|
||||
<td>X</td>
|
||||
<td>X</td>
|
||||
<td></td>
|
||||
<td>chassis information</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>manufacturer</td>
|
||||
<td>X</td>
|
||||
<td>X</td>
|
||||
<td>X</td>
|
||||
<td>X</td>
|
||||
<td></td>
|
||||
<td>e.g. 'ASUS'</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>model</td>
|
||||
<td>X</td>
|
||||
<td>X</td>
|
||||
<td>X</td>
|
||||
<td>X</td>
|
||||
<td></td>
|
||||
<td>model / product name</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>type</td>
|
||||
<td>X</td>
|
||||
<td>X</td>
|
||||
<td>X</td>
|
||||
<td>X</td>
|
||||
<td></td>
|
||||
<td>chassis type e.g. 'desktop'</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>version</td>
|
||||
<td>X</td>
|
||||
<td>X</td>
|
||||
<td>X</td>
|
||||
<td>X</td>
|
||||
<td></td>
|
||||
<td>version</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>serial</td>
|
||||
<td>X</td>
|
||||
<td>X</td>
|
||||
<td>X</td>
|
||||
<td>X</td>
|
||||
<td></td>
|
||||
<td>serial number</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>assetTag</td>
|
||||
<td>X</td>
|
||||
<td>X</td>
|
||||
<td>X</td>
|
||||
<td>X</td>
|
||||
<td></td>
|
||||
<td>asset tag</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>sku</td>
|
||||
<td>X</td>
|
||||
<td>X</td>
|
||||
<td>X</td>
|
||||
<td>X</td>
|
||||
<td></td>
|
||||
<td>SKU number</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@ -77,6 +77,7 @@ function getStaticData(callback) {
|
||||
system.system(),
|
||||
system.bios(),
|
||||
system.baseboard(),
|
||||
system.chassis(),
|
||||
osInfo.osInfo(),
|
||||
osInfo.uuid(),
|
||||
osInfo.versions(),
|
||||
@ -309,6 +310,7 @@ exports.version = version;
|
||||
exports.system = system.system;
|
||||
exports.bios = system.bios;
|
||||
exports.baseboard = system.baseboard;
|
||||
exports.chassis = system.chassis;
|
||||
|
||||
exports.time = osInfo.time;
|
||||
exports.osInfo = osInfo.osInfo;
|
||||
|
||||
107
lib/system.js
107
lib/system.js
@ -429,4 +429,111 @@ function baseboard(callback) {
|
||||
|
||||
exports.baseboard = baseboard;
|
||||
|
||||
function chassis(callback) {
|
||||
const chassisTypes = ['Other',
|
||||
'Unknown',
|
||||
'Desktop',
|
||||
'Low Profile Desktop',
|
||||
'Pizza Box',
|
||||
'Mini Tower',
|
||||
'Tower',
|
||||
'Portable',
|
||||
'Laptop',
|
||||
'Notebook',
|
||||
'Hand Held',
|
||||
'Docking Station',
|
||||
'All in One',
|
||||
'Sub Notebook',
|
||||
'Space-Saving',
|
||||
'Lunch Box',
|
||||
'Main System Chassis',
|
||||
'Expansion Chassis',
|
||||
'SubChassis',
|
||||
'Bus Expansion Chassis',
|
||||
'Peripheral Chassis',
|
||||
'Storage Chassis',
|
||||
'Rack Mount Chassis',
|
||||
'Sealed-Case PC']
|
||||
|
||||
return new Promise((resolve) => {
|
||||
process.nextTick(() => {
|
||||
|
||||
let result = {
|
||||
manufacturer: '',
|
||||
model: '',
|
||||
type: '',
|
||||
version: '',
|
||||
serial: '-',
|
||||
assetTag: '-',
|
||||
sku: '',
|
||||
};
|
||||
let cmd = '';
|
||||
if (_linux || _freebsd || _openbsd) {
|
||||
const cmd = `echo -n "chassis_asset_tag: "; cat /sys/devices/virtual/dmi/id/chassis_asset_tag 2>&1;
|
||||
echo -n "chassis_serial: "; cat /sys/devices/virtual/dmi/id/chassis_serial 2>&1;
|
||||
echo -n "chassis_type: "; cat /sys/devices/virtual/dmi/id/chassis_type 2>&1;
|
||||
echo -n "chassis_vendor: "; cat /sys/devices/virtual/dmi/id/chassis_vendor 2>&1;
|
||||
echo -n "chassis_version: "; cat /sys/devices/virtual/dmi/id/chassis_version 2>&1;`;
|
||||
exec(cmd, function (error, stdout) {
|
||||
let lines = stdout.toString().split('\n');
|
||||
result.manufacturer = util.getValue(lines, 'chassis_vendor');
|
||||
result.type = util.getValue(lines, 'chassis_type');
|
||||
result.version = util.getValue(lines, 'chassis_version');
|
||||
result.serial = util.getValue(lines, 'chassis_serial');
|
||||
result.assetTag = util.getValue(lines, 'chassis_asset_tag');
|
||||
if (result.serial.toLowerCase().indexOf('o.e.m.') !== -1) result.serial = '-';
|
||||
if (result.assetTag.toLowerCase().indexOf('o.e.m.') !== -1) result.assetTag = '-';
|
||||
|
||||
if (callback) { callback(result); }
|
||||
resolve(result);
|
||||
});
|
||||
}
|
||||
if (_darwin) {
|
||||
exec('ioreg -c IOPlatformExpertDevice -d 2', function (error, stdout) {
|
||||
if (!error) {
|
||||
let lines = stdout.toString().replace(/[<>"]/g, '').split('\n');
|
||||
result.manufacturer = util.getValue(lines, 'manufacturer', '=', true);
|
||||
result.model = util.getValue(lines, 'model', '=', true);
|
||||
result.version = util.getValue(lines, 'version', '=', true);
|
||||
result.serial = util.getValue(lines, 'ioplatformserialnumber', '=', true);
|
||||
result.assetTag = util.getValue(lines, 'board-id', '=', true);
|
||||
}
|
||||
|
||||
if (callback) { callback(result); }
|
||||
resolve(result);
|
||||
});
|
||||
}
|
||||
if (_sunos) {
|
||||
if (callback) { callback(result); }
|
||||
resolve(result);
|
||||
}
|
||||
if (_windows) {
|
||||
try {
|
||||
exec(util.getWmic() + ' path Win32_SystemEnclosure get /value', util.execOptsWin, function (error, stdout) {
|
||||
if (!error) {
|
||||
let lines = stdout.toString().split('\r\n');
|
||||
|
||||
result.manufacturer = util.getValue(lines, 'manufacturer', '=');
|
||||
result.model = util.getValue(lines, 'model', '=');
|
||||
const ctype = parseInt(util.getValue(lines, 'ChassisTypes', '='));
|
||||
result.type = (ctype && !isNaN(ctype) && ctype < chassisTypes.length) ? chassisTypes[ctype] : '';
|
||||
result.version = util.getValue(lines, 'version', '=');
|
||||
result.serial = util.getValue(lines, 'serialnumber', '=');
|
||||
result.assetTag = util.getValue(lines, 'partnumber', '=');
|
||||
result.sku = util.getValue(lines, 'sku', '=');
|
||||
}
|
||||
|
||||
if (callback) { callback(result); }
|
||||
resolve(result);
|
||||
});
|
||||
} catch (e) {
|
||||
if (callback) { callback(result); }
|
||||
resolve(result);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
exports.chassis = chassis;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user