currentLoad() workarround for empty os.cpus info

This commit is contained in:
Sebastian Hildebrandt 2020-04-29 11:32:28 +02:00
parent 3fe9e0a46f
commit fe9859ecc3
6 changed files with 14 additions and 6 deletions

View File

@ -30,6 +30,7 @@ For major (breaking) changes - version 3 and 2 see end of page.
| Version | Date | Comment |
| -------------- | -------------- | -------- |
| 4.23.9 | 2020-04-29 | `currentLoad()` workarround for no os.cpus info |
| 4.23.8 | 2020-04-26 | `getMacAddresses()` fix added try catch |
| 4.23.7 | 2020-04-26 | `getCpuCurrentSpeedSync()` workarround fix |
| 4.23.6 | 2020-04-25 | `networkGatewayDefault()` bug fix no interfaces |

View File

@ -56,13 +56,15 @@
<h2>Core Concept</h2>
<p><a href="https://nodejs.org/en/" rel="nofollow">Node.js</a> comes with some basic OS information, but I always wanted a little more. So I came up to write this
little library. This library is still work in progress. It is supposed to be used as a <a href="https://nodejs.org/en/" rel="nofollow">node.js</a> backend/server-side library (will definilely not work within a browser). It requires node.js version 4.0 and above.</p>
little library. This library is still work in progress. It requires node.js version 4.0 and above.</p>
<p>I was able to test it on several Debian, Raspbian, Ubuntu distributions as well as macOS (Mavericks, Yosemite, El Captain, Sierra, High Sierra, Mojave) and some Windows 7, Windows 10, FreeBSD, OpenBSD, NetBSD and SunOS machines.
Not all functions are supported on all operating systems. Have a look at the function reference in the docs to get further details.</p>
<p>If you have comments, suggestions &amp; reports, please feel free to contact me on <a href="https://github.com/sebhildebrandt/systeminformation/issues">github</a>!</p>
<p>I also created a nice little command line tool called <a href="https://github.com/sebhildebrandt/mmon" rel="nofollow">mmon</a> (micro-monitor) for Linux and macOS, also available via <a href="https://github.com/sebhildebrandt/mmon" rel="nofollow">github</a> and <a href="https://npmjs.org/package/mmon" rel="nofollow">npm</a></p>
<h3>Attention:</h3>
<p>This library is supposed to be used as a <a href="https://nodejs.org/en/" rel="nofollow">node.js</a> backend/server-side library and will definilely not work within a browser.</p>
<h2>Installation</h2>
<pre>$ npm install systeminformation --save</pre>

View File

@ -83,14 +83,19 @@
</tr>
</thead>
<tbody>
<tr>
<th scope="row">4.23.9</th>
<td>2020-04-29</td>
<td><span class="code">currentLoad()</span> workarround for no os.cpus info</td>
</tr>
<tr>
<th scope="row">4.23.8</th>
<td>2020-04-2&</td>
<td>2020-04-26</td>
<td><span class="code">getMacAddresses()</span> fix added try catch</td>
</tr>
<tr>
<th scope="row">4.23.7</th>
<td>2020-04-2&</td>
<td>2020-04-26</td>
<td><span class="code">getCpuCurrentSpeedSync()</span> workarround fix</td>
</tr>
<tr>

View File

@ -168,7 +168,7 @@
<img class="logo" src="assets/logo.png">
<div class="title">systeminformation</div>
<div class="subtitle"><span id="typed"></span></div>
<div class="version">Current Version: <span id="version">4.23.8</span></div>
<div class="version">Current Version: <span id="version">4.23.9</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">

View File

@ -1142,7 +1142,7 @@ function getLoad() {
let totalIrq = 0;
let totalIdle = 0;
let cores = [];
_corecount = (cpus && cpus.length) ? cpus.length : 1;
_corecount = (cpus && cpus.length) ? cpus.length : 0;
for (let i = 0; i < _corecount; i++) {
const cpu = cpus[i].times;

View File

@ -763,7 +763,7 @@ function networkInterfaces(callback) {
}
mac = details.mac;
// fallback due to https://github.com/nodejs/node/issues/13581 (node 8.1 - node 8.2)
if (mac.indexOf('00:00:0') > -1 && (_linux || _darwin)) {
if (mac.indexOf('00:00:0') > -1 && (_linux || _darwin) && parseInt(process.versions.node.split('.'), 10) === 8) {
if (Object.keys(_mac).length === 0) {
_mac = getMacAddresses();
}