bugfix cpu_currentspeed, cpu_temperature; updated docs
This commit is contained in:
parent
c62ef0d69b
commit
83decf3962
13
README.md
13
README.md
@ -51,7 +51,7 @@ This library is splitted in several sections:
|
|||||||
|
|
||||||
| command | Linux | OSX | Comments |
|
| command | Linux | OSX | Comments |
|
||||||
| -------------- | ------ | ------ | ------- |
|
| -------------- | ------ | ------ | ------- |
|
||||||
| si.osinfo() | X | X | |
|
| si.osinfo() | X | X | OS information|
|
||||||
| - platform | X | X | 'Linux' or 'Darwin' |
|
| - platform | X | X | 'Linux' or 'Darwin' |
|
||||||
| - distro | X | X | |
|
| - distro | X | X | |
|
||||||
| - release | X | X | |
|
| - release | X | X | |
|
||||||
@ -60,16 +60,15 @@ This library is splitted in several sections:
|
|||||||
| - arch | X | X | same as os.arch() |
|
| - arch | X | X | same as os.arch() |
|
||||||
| - hostname | X | X | same as os.hostname() |
|
| - hostname | X | X | same as os.hostname() |
|
||||||
| - logofile | X | X | e.g. 'apple', 'debian', 'fedora', ... |
|
| - logofile | X | X | e.g. 'apple', 'debian', 'fedora', ... |
|
||||||
| si.cpu() | X | X | |
|
| si.cpu() | X | X | CPU information|
|
||||||
| - brand | X | X | e.g. 'Intel' |
|
| - brand | X | X | e.g. 'Intel(R)' |
|
||||||
| - speed | X | X | e.g. '3.40GHz' |
|
| - speed | X | X | e.g. '3.40GHz' |
|
||||||
| si.cpu_speed() | X | X | |
|
| si.cpu_currentspeed() | X | X | current speed (GHz)|
|
||||||
| - current | X | X | current speed |
|
|
||||||
| si.cores() | X | X | # cores |
|
| si.cores() | X | X | # cores |
|
||||||
| si.sensors() | X | | |
|
| si.cpu_temperature() | X | | CPU temperature (if sensors is installed) |
|
||||||
| - main | X | X | main temperature |
|
| - main | X | X | main temperature |
|
||||||
| - cores | X | X | array of temperatures |
|
| - cores | X | X | array of temperatures |
|
||||||
| si.mem() | X | X | |
|
| si.mem() | X | X | Memory information|
|
||||||
| - total | X | X | |
|
| - total | X | X | |
|
||||||
| - free | X | X | |
|
| - free | X | X | |
|
||||||
| - used | X | X | |
|
| - used | X | X | |
|
||||||
|
|||||||
46
lib/index.js
46
lib/index.js
@ -207,13 +207,13 @@ exports.cpu = function(callback) {
|
|||||||
// --------------------------
|
// --------------------------
|
||||||
// CPU - current speed
|
// CPU - current speed
|
||||||
|
|
||||||
exports.cpu_speed = function(callback) {
|
exports.cpu_currentspeed = function(callback) {
|
||||||
var result = {current : tmp_cpu_speed};
|
var result = {current : tmp_cpu_speed};
|
||||||
if (tmp_platform == 'Darwin') {
|
if (tmp_platform == 'Darwin') {
|
||||||
exec("sysctl -n hw.cpufrequency", function(error, stdout, stderr) {
|
exec("sysctl -n hw.cpufrequency", function(error, stdout, stderr) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
var lines = stdout.toString().split('\n');
|
var lines = stdout.toString().split('\n');
|
||||||
result.current = parseInt(lines[0]);
|
result = parseInt(lines[0]);
|
||||||
}
|
}
|
||||||
callback(result);
|
callback(result);
|
||||||
});
|
});
|
||||||
@ -226,7 +226,7 @@ exports.cpu_speed = function(callback) {
|
|||||||
}
|
}
|
||||||
if (output.trim()) {
|
if (output.trim()) {
|
||||||
var lines = output.toString().split('\n');
|
var lines = output.toString().split('\n');
|
||||||
result.current = parseInt(lines[0]) * 1000;
|
result = parseInt(lines[0]) * 1000;
|
||||||
}
|
}
|
||||||
callback(result);
|
callback(result);
|
||||||
}
|
}
|
||||||
@ -252,27 +252,31 @@ exports.cores = cores;
|
|||||||
// CPU - temperature
|
// CPU - temperature
|
||||||
// if sensors are installed
|
// if sensors are installed
|
||||||
|
|
||||||
exports.sensors = function(callback) {
|
exports.cpu_temperature = function(callback) {
|
||||||
var result = {
|
var result = {
|
||||||
main : 0.0,
|
main : 0.0,
|
||||||
cores : []
|
cores : []
|
||||||
}
|
}
|
||||||
var regex = /\+([^°]*)/g;
|
if (tmp_platform == 'Linux') {
|
||||||
exec("sensors", function(error, stdout, stderr) {
|
var regex = /\+([^°]*)/g;
|
||||||
if (!error) {
|
exec("sensors", function(error, stdout, stderr) {
|
||||||
var lines = stdout.toString().split('\n');
|
if (!error) {
|
||||||
lines.forEach(function(line) {
|
var lines = stdout.toString().split('\n');
|
||||||
var temps = line.match(regex);
|
lines.forEach(function(line) {
|
||||||
if (line.split(':')[0].toUpperCase().indexOf('PHYSICAL') != -1) {
|
var temps = line.match(regex);
|
||||||
result.main = parseFloat(temps);
|
if (line.split(':')[0].toUpperCase().indexOf('PHYSICAL') != -1) {
|
||||||
}
|
result.main = parseFloat(temps);
|
||||||
if (line.split(':')[0].toUpperCase().indexOf('CORE ') != -1) {
|
}
|
||||||
result.cores.push(parseFloat(temps));
|
if (line.split(':')[0].toUpperCase().indexOf('CORE ') != -1) {
|
||||||
}
|
result.cores.push(parseFloat(temps));
|
||||||
})
|
}
|
||||||
}
|
})
|
||||||
callback(result)
|
}
|
||||||
});
|
callback(result)
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
callback(result)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -538,7 +542,7 @@ function getfullload(callback) {
|
|||||||
output = output.replace(/ +/g, " ").split(' ');
|
output = output.replace(/ +/g, " ").split(' ');
|
||||||
var uptime = parseFloat(output[0])
|
var uptime = parseFloat(output[0])
|
||||||
var idletime = parseFloat(output[1]) / tmp_cores;
|
var idletime = parseFloat(output[1]) / tmp_cores;
|
||||||
result.fullload = (uptime - idletime) / uptime
|
result.fullload = (uptime - idletime) / uptime * 100.0
|
||||||
callback(result);
|
callback(result);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user