code cleanup

This commit is contained in:
Sebastian Hildebrandt 2018-11-19 22:46:05 +01:00
commit 717b238f4a
5 changed files with 17 additions and 12 deletions

View File

@ -100,7 +100,8 @@ Other changes
| Version | Date | Comment |
| -------------- | -------------- | -------- |
| 3.49.1 | 2018-11-19 | code cleanup |
| 3.49.2 | 2018-11-19 | code cleanup |
| 3.49.1 | 2018-11-19 | `cpu().brand` removed extra spaces, tabs |
| 3.49.0 | 2018-11-19 | added system `uuid()` (os specific), `versions()` added postgresql |
| 3.48.4 | 2018-11-18 | windows: garbled output because of codepage |
| 3.48.3 | 2018-11-18 | `dockerContainerStats()` fixed issue `cpu_percent` win |

View File

@ -244,7 +244,8 @@ I also created a nice little command line tool called [mmon][mmon-github-url] (
| | serial | | X | X | X | | OS/Host serial number |
| | build | | | X | X | | OS build version |
| | codepage | X | X | X | X | | OS build version |
| si.uuid(cb) | : string | X | X | X | X| | device ID (based on OS install) |
| si.uuid(cb) | {...} | X | X | X | X | X | object of several UUIDs |
| | os | X | X | X | X | | os specific UUID |
| si.versions(cb) | {...} | X | X | X | X | X | version information (kernel, ssl, node, ...) |
| si.shell(cb) | : string | X | X | X | | | standard shell |
| si.users(cb) | [{...}] | X | X | X | X | X | array of users online |

View File

@ -115,10 +115,10 @@ const AMDBaseFrequencies = {
};
function cpuBrandManufacturer(res) {
res.brand = res.brand.replace(/\(R\)+/g, '®');
res.brand = res.brand.replace(/\(TM\)+/g, '™');
res.brand = res.brand.replace(/\(C\)+/g, '©');
res.brand = res.brand.replace(/CPU+/g, '').trim();
res.brand = res.brand.replace(/\(R\)+/g, '®').replace(/\s+/g, ' ').trim();
res.brand = res.brand.replace(/\(TM\)+/g, '™').replace(/\s+/g, ' ').trim();
res.brand = res.brand.replace(/\(C\)+/g, '©').replace(/\s+/g, ' ').trim();
res.brand = res.brand.replace(/CPU+/g, '').replace(/\s+/g, ' ').trim();
res.manufacturer = res.brand.split(' ')[0];
let parts = res.brand.split(' ');

View File

@ -505,14 +505,16 @@ function uuid(callback) {
return new Promise((resolve) => {
process.nextTick(() => {
let result = '';
let result = {
os: ''
};
let parts;
if (_darwin) {
exec('ioreg -rd1 -c IOPlatformExpertDevice | grep IOPlatformUUID', function (error, stdout) {
if (!error) {
parts = stdout.toString().split('\n')[0].replace(/"/g, '').split('=');
result = parts.length > 1 ? parts[1].trim().toLowerCase() : '';
result.os = parts.length > 1 ? parts[1].trim().toLowerCase() : '';
}
if (callback) {
callback(result);
@ -523,7 +525,7 @@ function uuid(callback) {
if (_linux) {
exec('( cat /var/lib/dbus/machine-id /etc/machine-id 2> /dev/null || hostname ) | head -n 1 || :', function (error, stdout) {
if (!error) {
result = stdout.toString().split('\n')[0].trim().toLowerCase();
result.os = stdout.toString().split('\n')[0].trim().toLowerCase();
}
if (callback) {
callback(result);
@ -534,7 +536,7 @@ function uuid(callback) {
if (_freebsd || _openbsd) {
exec('kenv -q smbios.system.uuid', function (error, stdout) {
if (!error) {
result = stdout.toString().split('\n')[0].trim().toLowerCase();
result.os = stdout.toString().split('\n')[0].trim().toLowerCase();
}
if (callback) {
callback(result);
@ -545,7 +547,8 @@ function uuid(callback) {
if (_windows) {
exec('%windir%\\System32\\reg query "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography" /v MachineGuid', util.execOptsWin, function (error, stdout) {
if (!error) {
result = stdout.toString().split('\n')[0].split('REG_SZ')[1].replace(/\r+|\n+|\s+/ig, '').toLowerCase();
parts = stdout.toString().split('\n\r')[0].split('REG_SZ');
result.os = parts.length > 1 ? parts[1].replace(/\r+|\n+|\s+/ig, '').toLowerCase() : '';
}
if (callback) {
callback(result);

View File

@ -1,6 +1,6 @@
{
"name": "systeminformation",
"version": "3.48.4",
"version": "3.49.1",
"description": "Simple system and OS information library",
"license": "MIT",
"author": "Sebastian Hildebrandt <hildebrandt@plus-innovations.com> (https://plus-innovations.com)",