diff --git a/CHANGELOG.md b/CHANGELOG.md index c347228..d492634 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ For major (breaking) changes - version 3 and 2 see end of page. | 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.1 | 2020-01-31 | `networkGatewayDefault()` fixed windows 7 issue | | 4.21.0 | 2020-01-27 | `npx` compatibility | diff --git a/README.md b/README.md index d286a6f..f1c5649 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ [![Sponsoring][sponsor-badge]][sponsor-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 diff --git a/docs/history.html b/docs/history.html index 974c0f3..d2af45c 100644 --- a/docs/history.html +++ b/docs/history.html @@ -83,9 +83,14 @@ + + 4.21.3 + 2020-02-16 + versions() fixed versions mysql (macOS) + 4.21.2 - 2020-01-31 + 2020-02-11 networkConnections() fixed linux (debian) issue diff --git a/docs/index.html b/docs/index.html index 0bafd8a..f29e218 100644 --- a/docs/index.html +++ b/docs/index.html @@ -168,7 +168,7 @@
systeminformation
-
Current Version: 4.21.2
+
Current Version: 4.21.3
diff --git a/docs/processes.html b/docs/processes.html index d5c734c..41a5748 100644 --- a/docs/processes.html +++ b/docs/processes.html @@ -165,6 +165,46 @@ X current loads per CPU in % + raw ticks + + + +
Example
+
const si = require('systeminformation');
+si.currentLoad().then(data => console.log(data));
+
+{
+  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
+    },
+    ...
+  ]
+}
+ si.fullLoad(cb) : integer @@ -425,8 +465,46 @@ X process path + + + +
Example
+
const si = require('systeminformation');
+si.processes().then(data => console.log(data));
+
+{
+  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'
+    },
+    ...
+  ]
+}
+ - si.processLoad('apache2',cb) + si.processLoad('nginx',cb) {...} X X @@ -485,6 +563,28 @@ process % MEM + + + +
Example
+
const si = require('systeminformation');
+si.processLoad('nginx').then(data => console.log(data));
+
+{
+  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
+}
+ si.services('mysql, apache2', cb) [{...}] @@ -555,6 +655,32 @@ process % MEM + + + +
Example
+
const si = require('systeminformation');
+si.services('mysql, postgres').then(data => console.log(data));
+
+[
+  {
+    name: 'mysql',
+    running: true,
+    startmode: '',
+    pids: [ 152 ],
+    pcpu: 0.3,
+    pmem: 0
+  },
+  {
+    name: 'postgres',
+    running: true,
+    startmode: '',
+    pids: [ 1087, 1873 ],
+    pcpu: 0,
+    pmem: 0
+  },
+]
+

Getting correct stats values

diff --git a/lib/osinfo.js b/lib/osinfo.js index bc3814a..45b6625 100644 --- a/lib/osinfo.js +++ b/lib/osinfo.js @@ -492,9 +492,17 @@ function versions(callback) { exec('mysql -V', function (error, stdout) { if (!error) { let mysql = stdout.toString().split('\n')[0] || ''; - mysql = (mysql.toLowerCase().split(',')[0] || '').trim(); - const parts = mysql.split(' '); - result.mysql = (parts[parts.length - 1] || '').trim(); + mysql = mysql.toLowerCase(); + if (mysql.indexOf(',') > -1) { + 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(); }); diff --git a/lib/processes.js b/lib/processes.js index 0249b14..2938e5a 100644 --- a/lib/processes.js +++ b/lib/processes.js @@ -135,7 +135,10 @@ function services(srv, callback) { let singleSrv = allSrv.filter(item => { return item.name === srv; }); const pids = []; 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({ name: srv,