added CoreOS identification, optimized cpuCurrentspeed

This commit is contained in:
Sebastian Hildebrandt 2016-02-22 09:19:36 +01:00
parent 5db77203c7
commit 639da0ce16
2 changed files with 15 additions and 6 deletions

View File

@ -229,6 +229,7 @@ I am happy to discuss any comments and suggestions. Please feel free to contact
| Version | Date | Comment |
| -------------- | -------------- | -------- |
| 2.0.2 | 2016-02-22 | added CoreOS identification, optimized cpuCurrentspeed |
| 2.0.1 | 2016-01-07 | minor patch |
| 2.0.0 | 2016-01-07 | new major version 2.0 |
| 1.0.7 | 2015-11-27 | fixed: si.network_speed() |

View File

@ -67,6 +67,7 @@
// --------------------------------
//
// version date comment
// 2.0.2 2016-02-22 added CoreOS identification, optimized cpuCurrentspeed
// 2.0.1 2016-01-07 minor patch
// 2.0.0 2016-01-07 new major version 2.0
// 1.0.7 2015-11-27 fixed: si.network_speed()
@ -254,6 +255,7 @@ function getLogoFile(distro) {
if (distro.toLowerCase().indexOf('mac os') != -1) { result = 'apple' } else
if (distro.toLowerCase().indexOf('arch') != -1) { result = 'arch' } else
if (distro.toLowerCase().indexOf('centos') != -1) { result = 'centos' } else
if (distro.toLowerCase().indexOf('coreos') != -1) { result = 'coreos' } else
if (distro.toLowerCase().indexOf('debian') != -1) { result = 'debian' } else
if (distro.toLowerCase().indexOf('elementary') != -1) { result = 'elementary' } else
if (distro.toLowerCase().indexOf('fedora') != -1) { result = 'fedora' } else
@ -309,7 +311,7 @@ function osInfo(callback) {
var lines = stdout.toString().split('\n');
lines.forEach(function(line) {
if (line.indexOf('=') != -1) {
release[line.split('=')[0].trim().toUpperCase()] = line.split('=')[1].trim();
release[line.split('=')[0].trim().toUpperCase()] = line.split('=')[1].trim();
}
});
result.distro = release.DISTRIB_ID || release.NAME || 'unknown';
@ -361,7 +363,7 @@ function getCpu(callback) {
var result = {
manufacturer : 'unknown',
brand : 'unknown',
speed : 'unknown',
speed : '0.00',
cores : _cores
};
if (_darwin) {
@ -383,8 +385,12 @@ function getCpu(callback) {
var lines = stdout.toString().split('\n');
var line = lines[0].split(':')[1];
result.brand = line.split('@')[0].trim();
result.speed = line.split('@')[1] ? parseFloat(line.split('@')[1].trim()) : getCpuCurrentSpeedSync();
_cpu_speed = result.speed;
result.speed = line.split('@')[1] ? parseFloat(line.split('@')[1].trim()).toFixed(2) : '0.00';
if (result.speed == '0.00') {
var current = getCpuCurrentSpeedSync();
if (current != '0.00') result.speed = current;
}
_cpu_speed = result.speed;
}
result = cpuBrandManufacturer(result);
callback(result);
@ -590,7 +596,7 @@ function mem(callback) {
if(line[i].toLowerCase().indexOf('total') != -1) result.swaptotal = parseFloat(line[i].split('=')[1].trim()) * 1024 * 1024;
if(line[i].toLowerCase().indexOf('used') != -1) result.swapused = parseFloat(line[i].split('=')[1].trim()) * 1024 * 1024;
if(line[i].toLowerCase().indexOf('free') != -1) result.swapfree = parseFloat(line[i].split('=')[1].trim()) * 1024 * 1024;
}
}
}
@ -1032,7 +1038,7 @@ function services(srv, callback) {
})
});
callback(data)
}
}
});
} else callback(data)
}
@ -1277,6 +1283,8 @@ function getDynamicData(callback, srv, network) {
// get time
data.time = time();
data.node = process.versions.node;
data.v8 = process.versions.v8;
cpuCurrentspeed(function(res) {
data.cpuCurrentspeed = res;