From 95b93af55130664373877c14f3d67f99e2bf8703 Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Tue, 19 Jan 2021 15:13:31 +0100 Subject: [PATCH] processLoad now returns array --- README.md | 9 +- docs/main.js | 1 - docs/processes.html | 61 +++++---- lib/index.d.ts | 12 +- lib/processes.js | 322 +++++++++++++++++++++++++++++--------------- test/si.js | 2 +- test/test.js | 24 ++-- 7 files changed, 276 insertions(+), 155 deletions(-) diff --git a/README.md b/README.md index 2185c77..8c62640 100644 --- a/README.md +++ b/README.md @@ -387,8 +387,13 @@ I also created a nice little command line tool called [mmon][mmon-github-url] (m | | [0].running | X | X | X | X | | true / false | | | [0].startmode | | | | X | | manual, automatic, ... | | | [0].pids | X | X | X | X | | pids | -| | [0].pcpu | X | X | X | | | process % CPU | -| | [0].pmem | X | X | X | | | process % MEM | +| | [0].cpu | X | X | X | | | process % CPU | +| | [0].mem | X | X | X | | | process % MEM | +| si.processLoad('mysql, apache2', cb) | [{...}] | X | X | X | X | | pass comma separated string of processes
pass "*" for ALL processes (linux/win only) | +| | [0].proc | X | X | X | X | | name of process | +| | [0].pids | X | X | X | X | | pids | +| | [0].cpu | X | X | X | | | process % CPU | +| | [0].mem | X | X | X | | | process % MEM | #### 9. File System diff --git a/docs/main.js b/docs/main.js index 6c90ca3..fbe657d 100644 --- a/docs/main.js +++ b/docs/main.js @@ -37,7 +37,6 @@ function createMenu() { var titleElement; var titleLink; var ulElement; - var hrElement; var liElement; var aElement; for (let item of menu) { diff --git a/docs/processes.html b/docs/processes.html index 7732207..de87831 100644 --- a/docs/processes.html +++ b/docs/processes.html @@ -318,7 +318,7 @@ si.currentLoad().then(data => console.log(data)); - ...[0].pcpu + ...[0].cpu X X X @@ -328,7 +328,7 @@ si.currentLoad().then(data => console.log(data)); - ...[0].pcpuu + ...[0].cpuu X X @@ -338,7 +338,7 @@ si.currentLoad().then(data => console.log(data)); - ...[0].pcpus + ...[0].cpus X X @@ -348,7 +348,7 @@ si.currentLoad().then(data => console.log(data)); - ...[0].pmem + ...[0].mem X X X @@ -484,10 +484,10 @@ si.processes().then(data => console.log(data)); pid: 1, parentPid: 0, name: 'init', - pcpu: 0.04504576931569955, - pcpuu: 0.04084113255431208, - pcpus: 0.00420463676138747, - pmem: 0, + cpu: 0.04504576931569955, + cpuu: 0.04084113255431208, + cpus: 0.00420463676138747, + mem: 0, priority: 19, memVsz: 166144, memRss: 10684, @@ -505,18 +505,18 @@ si.processes().then(data => console.log(data)); } - si.processLoad('nginx',cb) - {...} + si.processLoad('nginx, ssl',cb) + [{...}] X X X X - detailed information about given process + detailed information about given processes
pass comma separated list or
'*' for all processes - proc + [0].proc X X X @@ -526,7 +526,7 @@ si.processes().then(data => console.log(data)); - pid + [0].pid X X X @@ -536,7 +536,7 @@ si.processes().then(data => console.log(data)); - pids + [0].pids X X X @@ -546,7 +546,7 @@ si.processes().then(data => console.log(data)); - cpu + [0].cpu X X X @@ -556,7 +556,7 @@ si.processes().then(data => console.log(data)); - mem + [0].mem X X X @@ -569,8 +569,9 @@ si.processes().then(data => console.log(data));
Example
const si = require('systeminformation');
-si.processLoad('nginx').then(data => console.log(data));
+si.processLoad('nginx, postgres').then(data => console.log(data));
+[
 {
   proc: 'nginx',
   pid: 11267,
@@ -584,7 +585,19 @@ si.processLoad('nginx').then(data => console.log(data));
- [0].pcpu + [0].cpu X X X @@ -648,7 +661,7 @@ si.processLoad('nginx').then(data => console.log(data)); { if (data !== null) { resolve({ data, title: 'Memory Layout' }); } else { resolve('not_supported') } }) } else if (f === 'o') { si.osInfo().then(data => { if (data !== null) { resolve({ data, title: 'OS Info' }); } else { resolve('not_supported') } }) } else if (f === 'p') { si.processes().then(data => { if (data !== null) { resolve({ data, title: 'Processes' }); } else { resolve('not_supported') } }) } - else if (f === 'P') { si.processLoad('postgres').then(data => { if (data !== null) { resolve({ data, title: 'Process Load' }); } else { resolve('not_supported') } }) } + else if (f === 'P') { si.processLoad('postgres, login, apache, mysql, nginx, git').then(data => { if (data !== null) { resolve({ data, title: 'Process Load' }); } else { resolve('not_supported') } }) } else if (f === 'r') { si.printer().then(data => { if (data !== null) { resolve({ data, title: 'Printer' }); } else { resolve('not_supported') } }) } else if (f === 's') { si.services('apache2, postgres').then(data => { if (data !== null) { resolve({ data, title: 'Services' }); } else { resolve('not_supported') } }) } else if (f === 'S') { si.shell().then(data => { if (data !== null) { resolve({ data, title: 'Shell' }); } else { resolve('not_supported') } }) } diff --git a/test/test.js b/test/test.js index bafe965..3ddc245 100644 --- a/test/test.js +++ b/test/test.js @@ -16,18 +16,18 @@ function printHeader() { function printMenu() { console.log(''); console.log('┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐'); - console.log('│ a ... Audio h ... Bluetooth s ... Services 1 ... NET Iface Default ? ... Get Object │'); - console.log('│ b ... BIOS i ... INET Latency S ... Shell 2 ... NET Gateway Default , ... All Static │'); - console.log('│ B ... Baseboard I ... INET Check Site t ... time 3 ... NET Interfaces . ... All Dynamic │'); - console.log('│ C ... Chassis j ... CPU Current Speed T ... CPU Temperature 4 ... NET Stats / ... All │'); - console.log('│ c ... CPU l ... CPU Current Load u ... USB 5 ... NET Connections │'); - console.log('│ d ... DiskLayout L ... Full Load U ... UUID │'); - console.log('│ D ... DiskIO m ... Memory v ... Versions 6 ... Docker Info │'); - console.log('│ e ... Block Devices M ... MEM Layout V ... Virtual Box 7 ... Docker Container │'); - console.log('│ E ... Open Files o ... OS Info w ... WIFI networks 8 ... Docker Cont Stats │'); - console.log('│ f ... FS Size p ... Processes y ... System 9 ... Docker Cont Proc │'); - console.log('│ F ... FS Stats P ... Process Load Y ... Battery 0 ... Docker All │'); - console.log('│ g ... Graphics r ... Printer z ... Users q >>> QUIT │'); + console.log('│ a ... Audio h ... Bluetooth s ... Services ? ... Get Object │'); + console.log('│ b ... BIOS i ... INET Latency S ... Shell , ... All Static │'); + console.log('│ B ... Baseboard I ... INET Check Site t ... time 1 ... NET Iface Default . ... All Dynamic │'); + console.log('│ C ... Chassis j ... CPU Current Speed T ... CPU Temperature 2 ... NET Gateway Default / ... All │'); + console.log('│ c ... CPU l ... CPU Current Load u ... USB 3 ... NET Interfaces │'); + console.log('│ d ... DiskLayout L ... Full Load U ... UUID 4 ... NET Stats │'); + console.log('│ D ... DiskIO m ... Memory v ... Versions 5 ... NET Connections │'); + console.log('│ e ... Block Devices M ... MEM Layout V ... Virtual Box 6 ... Docker Info │'); + console.log('│ E ... Open Files o ... OS Info w ... WIFI networks 7 ... Docker Container │'); + console.log('│ f ... FS Size p ... Processes y ... System 8 ... Docker Cont Stats │'); + console.log('│ F ... FS Stats P ... Process Load Y ... Battery 9 ... Docker Cont Proc │'); + console.log('│ g ... Graphics r ... Printer z ... Users 0 ... Docker All q >>> QUIT │'); console.log('└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘'); }