diff --git a/CHANGELOG.md b/CHANGELOG.md index 30dac75..e671d69 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -100,6 +100,7 @@ Other changes | Version | Date | Comment | | -------------- | -------------- | -------- | +| 3.43.0 | 2018-08-25 | `cpuCurrentspeed()` added cpu speed for all cores | | 3.42.10 | 2018-08-25 | `processes()` optimized start time parsing | | 3.42.9 | 2018-08-08 | `cpuTemperature()` optimized parsing | | 3.42.8 | 2018-08-03 | updated docs | diff --git a/README.md b/README.md index 74c9e9d..f789012 100644 --- a/README.md +++ b/README.md @@ -54,13 +54,13 @@ async function cpu() { (last 7 major and minor version releases) +- Version 3.43.0: added speed per CPU core `cpuCurrentspeed()` - Version 3.42.0: added parent process PID `processes()` - Version 3.41.0: first partial `SunOS` support - Version 3.40.0: extended `versions()` (php, redis, mongodb) - Version 3.39.0: added `versions().mysql` and `versions().nginx`, start implementing `SunOS` support - Version 3.38.0: added `battery.acconnected` - Version 3.37.0: extended FreeBSD support `networkStats()` -- Version 3.36.0: extended FreeBSD support `networkConnections()` - ... You can find all changes here: [detailed changelog][changelog-url] @@ -149,6 +149,7 @@ I also created a nice little command line tool called [mmon][mmon-github-url] ( | | avg | X | X | X | X | X | avg CPU speed (all cores) | | | min | X | X | X | X | X | min CPU speed (all cores) | | | max | X | X | X | X | X | max CPU speed (all cores) | +| | cores | X | X | X | X | X | CPU speed per core (array) | | si.cpuTemperature(cb) | {...} | X | X | X* | X | | CPU temperature (if supported) | | | main | X | X | X | X | | main temperature (avg) | | | cores | X | X | X | X | | array of temperatures | diff --git a/lib/cpu.js b/lib/cpu.js index 7a4b20d..6a2946a 100644 --- a/lib/cpu.js +++ b/lib/cpu.js @@ -405,6 +405,7 @@ function getCpuCurrentSpeedSync() { let minFreq = 999999999; let maxFreq = 0; let avgFreq = 0; + let cores = []; if (cpus.length) { for (let i in cpus) { @@ -413,18 +414,21 @@ function getCpuCurrentSpeedSync() { if (cpus[i].speed > maxFreq) maxFreq = cpus[i].speed; if (cpus[i].speed < minFreq) minFreq = cpus[i].speed; } + cores.push(parseFloat(((cpus[i].speed + 1) / 1000).toFixed(2))); } avgFreq = avgFreq / cpus.length; return { min: parseFloat(((minFreq + 1) / 1000).toFixed(2)), max: parseFloat(((maxFreq + 1) / 1000).toFixed(2)), - avg: parseFloat(((avgFreq + 1) / 1000).toFixed(2)) + avg: parseFloat(((avgFreq + 1) / 1000).toFixed(2)), + cores: cores }; } else { return { min: 0, max: 0, - avg: 0 + avg: 0, + cores: cores }; } }