fixed cpu cores, updated docs
This commit is contained in:
parent
a61654f347
commit
1cdd178c6a
@ -63,8 +63,8 @@ This library is splitted in several sections:
|
|||||||
| si.cpu() | X | X | CPU information|
|
| si.cpu() | X | X | CPU information|
|
||||||
| - brand | X | X | e.g. 'Intel(R)' |
|
| - brand | X | X | e.g. 'Intel(R)' |
|
||||||
| - speed | X | X | e.g. '3.40GHz' |
|
| - speed | X | X | e.g. '3.40GHz' |
|
||||||
|
| - cores | X | X | # cores |
|
||||||
| si.cpu_currentspeed() | X | X | current speed (GHz)|
|
| si.cpu_currentspeed() | X | X | current speed (GHz)|
|
||||||
| si.cores() | X | X | # cores |
|
|
||||||
| si.cpu_temperature() | X | | CPU temperature (if sensors is installed) |
|
| 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 |
|
||||||
@ -127,6 +127,9 @@ si.network_speed('eth1', function(data) {
|
|||||||
|
|
||||||
| Version | Date | Comment |
|
| Version | Date | Comment |
|
||||||
| -------------- | -------------- | -------- |
|
| -------------- | -------------- | -------- |
|
||||||
|
| 1.0.3 | 2015-07-18 | bugfix cpu cores |
|
||||||
|
| 1.0.2 | 2015-07-18 | bugfix cpu_currentspeed, cpu_temperature |
|
||||||
|
| 1.0.1 | 2015-07-18 | documentation update |
|
||||||
| 1.0.0 | 2015-07-18 | bug-fixes, version bumb, published as npm component |
|
| 1.0.0 | 2015-07-18 | bug-fixes, version bumb, published as npm component |
|
||||||
| 0.0.3 | 2014-04-14 | bug-fix (cpu_speed) |
|
| 0.0.3 | 2014-04-14 | bug-fix (cpu_speed) |
|
||||||
| 0.0.2 | 2014-03-14 | Optimization FS-Speed & CPU current speed |
|
| 0.0.2 | 2014-03-14 | Optimization FS-Speed & CPU current speed |
|
||||||
@ -172,7 +175,8 @@ Written by Sebastian Hildebrandt [sebhildebrandt](https://github.com/sebhildebra
|
|||||||
>OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
>OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
>THE SOFTWARE.
|
>THE SOFTWARE.
|
||||||
>
|
>
|
||||||
>Further details see LICENSE(LICENSE) file.
|
>Further details see LICENSE file.
|
||||||
|
MIT(LICENSE)
|
||||||
|
|
||||||
|
|
||||||
[npm-image]: https://img.shields.io/npm/v/systeminformation.svg
|
[npm-image]: https://img.shields.io/npm/v/systeminformation.svg
|
||||||
|
|||||||
50
lib/index.js
50
lib/index.js
@ -171,12 +171,13 @@ exports.osinfo =function(callback) {
|
|||||||
// ----------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------
|
||||||
|
|
||||||
// --------------------------
|
// --------------------------
|
||||||
// CPU - data
|
// CPU - brand, speed
|
||||||
|
|
||||||
exports.cpu = function(callback) {
|
function getcpu(callback) {
|
||||||
var result = {
|
var result = {
|
||||||
brand : 'unknown',
|
brand : 'unknown',
|
||||||
speed : 'unknown'
|
speed : 'unknown',
|
||||||
|
cores : tmp_cores
|
||||||
};
|
};
|
||||||
// grep "^model name" /proc/cpuinfo 2>/dev/null || sysctl -n machdep.cpu.brand_string
|
// grep "^model name" /proc/cpuinfo 2>/dev/null || sysctl -n machdep.cpu.brand_string
|
||||||
if (tmp_platform == 'Darwin') {
|
if (tmp_platform == 'Darwin') {
|
||||||
@ -204,6 +205,33 @@ exports.cpu = function(callback) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --------------------------
|
||||||
|
// CPU - Processor cores
|
||||||
|
|
||||||
|
function cores(callback) {
|
||||||
|
exec("grep -c ^processor /proc/cpuinfo 2>/dev/null || sysctl -n hw.ncpu", function(error, stdout, stderr) {
|
||||||
|
var result = {cores: 1};
|
||||||
|
if (!error) {
|
||||||
|
result.cores = parseInt(stdout.toString());
|
||||||
|
tmp_cores = result.cores;
|
||||||
|
}
|
||||||
|
if (callback) callback(result);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------
|
||||||
|
// CPU - Processor Data
|
||||||
|
|
||||||
|
exports.cpu = function(callback) {
|
||||||
|
if (tmp_cores == 0) {
|
||||||
|
cores(function(data) {
|
||||||
|
getcpu(callback)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
getcpu(callback)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// --------------------------
|
// --------------------------
|
||||||
// CPU - current speed
|
// CPU - current speed
|
||||||
|
|
||||||
@ -232,22 +260,6 @@ exports.cpu_currentspeed = function(callback) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------
|
|
||||||
// CPU - Processor cores
|
|
||||||
|
|
||||||
function cores(callback) {
|
|
||||||
exec("grep -c ^processor /proc/cpuinfo 2>/dev/null || sysctl -n hw.ncpu", function(error, stdout, stderr) {
|
|
||||||
var result = {cores: 1};
|
|
||||||
if (!error) {
|
|
||||||
result.cores = parseInt(stdout.toString());
|
|
||||||
tmp_cores = result.cores;
|
|
||||||
}
|
|
||||||
if (callback) callback(result);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.cores = cores;
|
|
||||||
|
|
||||||
// --------------------------
|
// --------------------------
|
||||||
// CPU - temperature
|
// CPU - temperature
|
||||||
// if sensors are installed
|
// if sensors are installed
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user