versions() fixed mysql version (macOS), services() pid as integer

This commit is contained in:
Sebastian Hildebrandt 2020-02-16 17:58:27 +01:00
parent 1d1bf0a7c9
commit 3c0052becc
7 changed files with 151 additions and 8 deletions

View File

@ -30,6 +30,7 @@ For major (breaking) changes - version 3 and 2 see end of page.
| Version | Date | Comment | | Version | Date | Comment |
| -------------- | -------------- | -------- | | -------------- | -------------- | -------- |
| 4.21.3 | 2020-02-16 | `versions()` fixed mysql version (macOS) |
| 4.21.2 | 2020-02-11 | `networkConnections()` fixed linux (debian) issue | | 4.21.2 | 2020-02-11 | `networkConnections()` fixed linux (debian) issue |
| 4.21.1 | 2020-01-31 | `networkGatewayDefault()` fixed windows 7 issue | | 4.21.1 | 2020-01-31 | `networkGatewayDefault()` fixed windows 7 issue |
| 4.21.0 | 2020-01-27 | `npx` compatibility | | 4.21.0 | 2020-01-27 | `npx` compatibility |

View File

@ -30,7 +30,7 @@
[![Sponsoring][sponsor-badge]][sponsor-url] [![Sponsoring][sponsor-badge]][sponsor-url]
[![MIT license][license-img]][license-url] [![MIT license][license-img]][license-url]
This is amazing. Started as a small project just for myself, it now has > 9,000 lines of code, > 250 versions published, up to 1 mio downloads per month, > 4 mio downloads overall. Thank you to all who contributed to this project! This is amazing. Started as a small project just for myself, it now has > 9,000 lines of code, > 250 versions published, up to 1 mio downloads per month, > 5 mio downloads overall. Thank you to all who contributed to this project!
## New Version 4.0 ## New Version 4.0

View File

@ -83,9 +83,14 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr>
<th scope="row">4.21.3</th>
<td>2020-02-16</td>
<td><span class="code">versions()</span> fixed versions mysql (macOS)</td>
</tr>
<tr> <tr>
<th scope="row">4.21.2</th> <th scope="row">4.21.2</th>
<td>2020-01-31</td> <td>2020-02-11</td>
<td><span class="code">networkConnections()</span> fixed linux (debian) issue</td> <td><span class="code">networkConnections()</span> fixed linux (debian) issue</td>
</tr> </tr>
<tr> <tr>

View File

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

View File

@ -165,6 +165,46 @@
<td>X</td> <td>X</td>
<td>current loads per CPU in % + raw ticks</td> <td>current loads per CPU in % + raw ticks</td>
</tr> </tr>
<tr class="example">
<td></td>
<td colspan="7">
<h5>Example</h5>
<pre><code class="js">const si = require('systeminformation');
si.currentLoad().then(data => console.log(data));</code></pre class="example">
<pre class="example">
{
avgload: 0.23,
currentload: 4.326328800988875,
currentload_user: 2.595797280593325,
currentload_system: 1.73053152039555,
currentload_nice: 0,
currentload_idle: 95.67367119901112,
currentload_irq: 0,
raw_currentload: 350,
raw_currentload_user: 210,
raw_currentload_system: 140,
raw_currentload_nice: 0,
raw_currentload_idle: 7740,
raw_currentload_irq: 0,
cpus: [
{
load: 13.725490196078432,
load_user: 7.8431372549019605,
load_system: 5.88235294117647,
load_nice: 0,
load_idle: 86.27450980392157,
load_irq: 0,
raw_load: 140,
raw_load_user: 80,
raw_load_system: 60,
raw_load_nice: 0,
raw_load_idle: 880,
raw_load_irq: 0
},
...
]
}</pre>
</tr>
<tr> <tr>
<td>si.fullLoad(cb)</td> <td>si.fullLoad(cb)</td>
<td>: integer</td> <td>: integer</td>
@ -425,8 +465,46 @@
<td>X</td> <td>X</td>
<td>process path</td> <td>process path</td>
</tr> </tr>
<tr class="example">
<td></td>
<td colspan="7">
<h5>Example</h5>
<pre><code class="js">const si = require('systeminformation');
si.processes().then(data => console.log(data));</code></pre class="example">
<pre class="example">
{
all: 258,
running: 1,
blocked: 0,
sleeping: 157,
unknown: 0,
list: [
{
pid: 1,
parentPid: 0,
name: 'init',
pcpu: 0.04504576931569955,
pcpuu: 0.04084113255431208,
pcpus: 0.00420463676138747,
pmem: 0,
priority: 19,
mem_vsz: 166144,
mem_rss: 10684,
nice: 0,
started: '2020-02-08 10:18:15',
state: 'sleeping',
tty: '',
user: 'root',
command: 'init',
params: '',
path: '/sbin'
},
...
]
}</pre>
</tr>
<tr> <tr>
<td>si.processLoad('apache2',cb)</td> <td>si.processLoad('nginx',cb)</td>
<td>{...}</td> <td>{...}</td>
<td>X</td> <td>X</td>
<td>X</td> <td>X</td>
@ -485,6 +563,28 @@
<td></td> <td></td>
<td>process % MEM</td> <td>process % MEM</td>
</tr> </tr>
<tr class="example">
<td></td>
<td colspan="7">
<h5>Example</h5>
<pre><code class="js">const si = require('systeminformation');
si.processLoad('nginx').then(data => console.log(data));</code></pre class="example">
<pre class="example">
{
proc: 'nginx',
pid: 11267,
pids: [
11251, 11252, 11253,
11254, 11255, 11256,
11257, 11258, 11259,
11260, 11261, 11262,
11263, 11264, 11265,
11266, 11267
],
cpu: 0.01,
mem: 0
}</pre>
</tr>
<tr> <tr>
<td>si.services('mysql, apache2', cb)</td> <td>si.services('mysql, apache2', cb)</td>
<td>[{...}]</td> <td>[{...}]</td>
@ -555,6 +655,32 @@
<td></td> <td></td>
<td>process % MEM</td> <td>process % MEM</td>
</tr> </tr>
<tr class="example">
<td></td>
<td colspan="7">
<h5>Example</h5>
<pre><code class="js">const si = require('systeminformation');
si.services('mysql, postgres').then(data => console.log(data));</code></pre class="example">
<pre class="example">
[
{
name: 'mysql',
running: true,
startmode: '',
pids: [ 152 ],
pcpu: 0.3,
pmem: 0
},
{
name: 'postgres',
running: true,
startmode: '',
pids: [ 1087, 1873 ],
pcpu: 0,
pmem: 0
},
]</pre>
</tr>
</tbody> </tbody>
</table> </table>
<h4>Getting correct stats values</h4> <h4>Getting correct stats values</h4>

View File

@ -492,9 +492,17 @@ function versions(callback) {
exec('mysql -V', function (error, stdout) { exec('mysql -V', function (error, stdout) {
if (!error) { if (!error) {
let mysql = stdout.toString().split('\n')[0] || ''; let mysql = stdout.toString().split('\n')[0] || '';
mysql = (mysql.toLowerCase().split(',')[0] || '').trim(); mysql = mysql.toLowerCase();
const parts = mysql.split(' '); if (mysql.indexOf(',') > -1) {
result.mysql = (parts[parts.length - 1] || '').trim(); mysql = (mysql.split(',')[0] || '').trim();
const parts = mysql.split(' ');
result.mysql = (parts[parts.length - 1] || '').trim();
} else {
if (mysql.indexOf(' ver ') > -1) {
mysql = mysql.split(' ver ')[1];
result.mysql = mysql.split(' ')[0];
}
}
} }
functionProcessed(); functionProcessed();
}); });

View File

@ -135,7 +135,10 @@ function services(srv, callback) {
let singleSrv = allSrv.filter(item => { return item.name === srv; }); let singleSrv = allSrv.filter(item => { return item.name === srv; });
const pids = []; const pids = [];
for (const p of ps) { for (const p of ps) {
pids.push(p.trim().split(' ')[2]); const pid = p.trim().split(' ')[2];
if (pid) {
pids.push(parseInt(pid, 10));
}
} }
result.push({ result.push({
name: srv, name: srv,