dockerContainerStats() improved calculation cpuPercent

This commit is contained in:
Sebastian Hildebrandt 2022-12-08 13:14:01 +01:00
parent 5d17a86a2c
commit 94e5187d88
5 changed files with 18 additions and 6 deletions

View File

@ -82,6 +82,7 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page.
| Version | Date | Comment |
| ------- | ---------- | --------------------------------------------------------------------------------------------------- |
| 5.16.2 | 2022-12-08 | `dockerContainerStats()` improved calculation cpuPercent |
| 5.16.1 | 2022-12-04 | code cleanup, moved from lgtm to GitHub Code Scan |
| 5.16.0 | 2022-12-01 | `fsSize()` added rw (win, linux, mac OS, BSD) |
| 5.15.1 | 2022-11-29 | fix typescript typings |

View File

@ -24,8 +24,8 @@
[![Git Issues][issues-img]][issues-url]
[![Closed Issues][closed-issues-img]][closed-issues-url]
<img src="docs/assets/no-dependencies.svg" alt="no dependencies">
[![Caretaker][caretaker-image]][caretaker-url]
[![Sponsoring][sponsor-badge]][sponsor-url]
[![Caretaker][caretaker-image]][caretaker-url]
[![MIT license][license-img]][license-url]
This is amazing. Started as a small project just for myself, it now has > 15,000 lines of code, > 500 versions published, up to 5 mio downloads per month, > 100 mio downloads overall. #1 NPM ranking for backend packages. Thank you to all who contributed to this project!
@ -1057,7 +1057,7 @@ All other trademarks are the property of their respective owners.
[downloads-image]: https://img.shields.io/npm/dm/systeminformation.svg?style=flat-square
[downloads-url]: https://npmjs.org/package/systeminformation
[sponsor-badge]: https://img.shields.io/badge/-Buy%20me%20a%20coffee-blue?style=flat-square
[sponsor-badge]: https://img.shields.io/badge/Support-Buy%20me%20a%20coffee-brightgreen?style=flat-square
[sponsor-url]: https://www.buymeacoffee.com/systeminfo
[license-url]: https://github.com/sebhildebrandt/systeminformation/blob/master/LICENSE

View File

@ -57,6 +57,11 @@
</tr>
</thead>
<tbody>
<tr>
<th scope="row">5.16.2</th>
<td>2022-12-04</td>
<td>code cleanup, moved from lgtm to GitHub Code Scan</td>
</tr>
<tr>
<th scope="row">5.16.1</th>
<td>2022-12-04</td>
@ -2879,4 +2884,4 @@
</body>
</html>
</html>

View File

@ -170,7 +170,7 @@
<img class="logo" src="assets/logo.png" alt="logo">
<div class="title">systeminformation</div>
<div class="subtitle"><span id="typed"></span>&nbsp;</div>
<div class="version">New Version: <span id="version">5.16.1</span></div>
<div class="version">New Version: <span id="version">5.16.2</span></div>
<button class="btn btn-light" onclick="location.href='https://github.com/sebhildebrandt/systeminformation'">View on Github <i class=" fab fa-github"></i></button>
</div>
<div class="down">
@ -401,4 +401,4 @@
</script>
</body>
</html>
</html>

View File

@ -361,7 +361,12 @@ function docker_calcCPUPercent(cpu_stats, precpu_stats) {
if (systemDelta > 0.0 && cpuDelta > 0.0) {
// calculate the change for the cpu usage of the container in between readings
cpuPercent = (cpuDelta / systemDelta) * cpu_stats.cpu_usage.percpu_usage.length * 100.0;
if (precpu_stats.online_cpus) {
cpuPercent = (cpuDelta / systemDelta) * precpu_stats.online_cpus * 100.0;
}
else {
cpuPercent = (cpuDelta / systemDelta) * cpu_stats.cpu_usage.percpu_usage.length * 100.0;
}
}
return cpuPercent;
@ -706,6 +711,7 @@ function dockerVolumes(callback) {
}
exports.dockerVolumes = dockerVolumes;
function dockerAll(callback) {
return new Promise((resolve) => {
process.nextTick(() => {