systeminformation 5.18.14 → 5.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -31,11 +31,15 @@
31
31
  ## The Systeminformation Project
32
32
  This is amazing. Started as a small project just for myself, it now has > 15,000 lines of code, > 600 versions published, up to 6 mio downloads per month, > 150 mio downloads overall. #1 NPM ranking for backend packages. Thank you to all who contributed to this project!
33
33
 
34
- ## New Version 5.0
34
+ ## Please support this project ... ☕️
35
+
36
+ Over the past few years I spent **over 2.000 hours** working on this project and invested in hardware to be able to test on different platforms. Currently I am working very hard on the next **new version 6.0** completely rewritten in TypeScript and with a lot of new features. Any support is highly appreciated - [Buy me a coffee](https://www.buymeacoffee.com/systeminfo).
37
+
38
+ **Your contribution** make it possible for me to keep working on this project, add new features and support more platforms. Thank you in advance!
35
39
 
36
- The new Version 5 is here - I spent several weeks finalizing this new version. Any support is highly appreciated - [Buy me a coffee](https://www.buymeacoffee.com/systeminfo)
40
+ ## New Version 5.0
37
41
 
38
- This next major version release 5.0 comes with new functionality and several improvements and changes (some of them are breaking changes!):
42
+ The new Version 5 is here - this next major version release 5.0 comes with new functionality and several improvements and changes (some of them are breaking changes!):
39
43
 
40
44
  - added audio: get detailed audio device information
41
45
  - added bluetooth: get detailed bluetooth device information
@@ -75,9 +79,22 @@ npm install systeminformation --save
75
79
  or simpler
76
80
 
77
81
  ```bash
78
- npm install systeminformation
82
+ npm i systeminformation
79
83
  ```
80
84
 
85
+ ### Give it a try with `npx`?
86
+
87
+ You just want to give it a try - right from your command line without installing it? Here is how you can call it with `npx`:
88
+
89
+ ```
90
+ # get basic system info (System, OS, CPU)
91
+ npx systeminformation info
92
+
93
+ # obtain all static data - may take up to 30 seconds
94
+ npx systeminformation
95
+ ```
96
+
97
+
81
98
  #### Still need Version 4?
82
99
 
83
100
  If you need version 4 (for compatibility reasons), you can install version 4 (latest release) like this
@@ -111,6 +128,7 @@ si.cpu()
111
128
 
112
129
  (last 7 major and minor version releases)
113
130
 
131
+ - Version 5.19.0: `currentLoad()` added steal and guest time (linux)
114
132
  - Version 5.18.0: `fsSize()` added optional drive parameter
115
133
  - Version 5.17.0: `graphics()` added positionX, positionY (mac OS)
116
134
  - Version 5.16.0: `fsSize()` added rw property
package/lib/cli.js CHANGED
@@ -17,15 +17,75 @@
17
17
  // Dependencies
18
18
  // ----------------------------------------------------------------------------------
19
19
  const si = require('./index');
20
+ const lib_version = require('../package.json').version;
21
+
22
+ function capFirst(string) {
23
+ return string[0].toUpperCase() + string.slice(1);
24
+ }
25
+
26
+ function printLines(obj) {
27
+ for (const property in obj) {
28
+ console.log(capFirst(property) + ' '.substring(0, 17 - property.length) + ': ' + (obj[property] || ''));
29
+ }
30
+ console.log();
31
+ }
32
+
33
+ function info() {
34
+ console.log('┌─────────────────────────────────────────────────────────────────────────────────────────┐');
35
+ console.log('│ SYSTEMINFORMATION '.substring(0, 80 - lib_version.length) + 'Version: ' + lib_version + ' │');
36
+ console.log('└─────────────────────────────────────────────────────────────────────────────────────────┘');
37
+
38
+ si.osInfo().then(res => {
39
+ console.log();
40
+ console.log('Operating System:');
41
+ console.log('──────────────────────────────────────────────────────────────────────────────────────────');
42
+ delete res.serial;
43
+ delete res.servicepack;
44
+ delete res.logofile;
45
+ delete res.fqdn;
46
+ delete res.uefi;
47
+ printLines(res);
48
+ si.system().then(res => {
49
+ console.log('System:');
50
+ console.log('──────────────────────────────────────────────────────────────────────────────────────────');
51
+ delete res.serial;
52
+ delete res.uuid;
53
+ delete res.sku;
54
+ delete res.uuid;
55
+ printLines(res);
56
+ si.cpu().then(res => {
57
+ console.log('CPU:');
58
+ console.log('──────────────────────────────────────────────────────────────────────────────────────────');
59
+ delete res.cache;
60
+ delete res.governor;
61
+ delete res.flags;
62
+ delete res.virtualization;
63
+ delete res.revision;
64
+ delete res.voltage;
65
+ delete res.vendor;
66
+ delete res.speedMin;
67
+ delete res.speedMax;
68
+ printLines(res);
69
+ });
70
+ });
71
+ });
72
+ }
20
73
 
21
74
  // ----------------------------------------------------------------------------------
22
75
  // Main
23
76
  // ----------------------------------------------------------------------------------
24
77
  (function () {
25
- si.getStaticData().then(
26
- ((data) => {
27
- data.time = si.time();
28
- console.log(JSON.stringify(data, null, 2));
29
- }
30
- ));
78
+ const args = process.argv.slice(2);
79
+
80
+ if (args[0] === 'info') {
81
+ info();
82
+ } else {
83
+ si.getStaticData().then(
84
+ ((data) => {
85
+ data.time = si.time();
86
+ console.log(JSON.stringify(data, null, 2));
87
+ }
88
+ ));
89
+ }
90
+
31
91
  })();
package/lib/cpu.js CHANGED
@@ -36,6 +36,8 @@ let _current_cpu = {
36
36
  system: 0,
37
37
  idle: 0,
38
38
  irq: 0,
39
+ steal: 0,
40
+ guest: 0,
39
41
  load: 0,
40
42
  tick: 0,
41
43
  ms: 0,
@@ -45,12 +47,16 @@ let _current_cpu = {
45
47
  currentLoadNice: 0,
46
48
  currentLoadIdle: 0,
47
49
  currentLoadIrq: 0,
50
+ currentLoadSteal: 0,
51
+ currentLoadGuest: 0,
48
52
  rawCurrentLoad: 0,
49
53
  rawCurrentLoadUser: 0,
50
54
  rawCurrentLoadSystem: 0,
51
55
  rawCurrentLoadNice: 0,
52
56
  rawCurrentLoadIdle: 0,
53
- rawCurrentLoadIrq: 0
57
+ rawCurrentLoadIrq: 0,
58
+ rawCurrentLoadSteal: 0,
59
+ rawCurrentLoadGuest: 0
54
60
  };
55
61
  let _cpus = [];
56
62
  let _corecount = 0;
@@ -1559,15 +1565,44 @@ function getLoad() {
1559
1565
  let now = Date.now() - _current_cpu.ms;
1560
1566
  if (now >= 200) {
1561
1567
  _current_cpu.ms = Date.now();
1562
- const cpus = os.cpus();
1568
+ const cpus = os.cpus().map(function (cpu) {
1569
+ cpu.times.steal = 0;
1570
+ cpu.times.guest = 0;
1571
+ return cpu;
1572
+ });
1563
1573
  let totalUser = 0;
1564
1574
  let totalSystem = 0;
1565
1575
  let totalNice = 0;
1566
1576
  let totalIrq = 0;
1567
1577
  let totalIdle = 0;
1578
+ let totalSteal = 0;
1579
+ let totalGuest = 0;
1568
1580
  let cores = [];
1569
1581
  _corecount = (cpus && cpus.length) ? cpus.length : 0;
1570
1582
 
1583
+ // linux: try to get other cpu stats
1584
+ if (_linux) {
1585
+ try {
1586
+ const lines = execSync('cat /proc/stat 2>/dev/null | grep cpu').split('\n');
1587
+ if (lines.length > 1) {
1588
+ lines.shift();
1589
+ if (lines.length === cpus.length) {
1590
+ for (let i = 0; i < lines.length; i++) {
1591
+ let parts = lines[i].split(' ');
1592
+ if (parts.length >= 10) {
1593
+ const steal = parseFloat(parts[8]) || 0;
1594
+ const guest = parseFloat(parts[9]) || 0;
1595
+ cpus[i].times.steal = steal;
1596
+ cpus[i].times.guest = guest;
1597
+ }
1598
+ }
1599
+ }
1600
+ }
1601
+ } catch (e) {
1602
+ util.noop();
1603
+ }
1604
+ }
1605
+
1571
1606
  for (let i = 0; i < _corecount; i++) {
1572
1607
  const cpu = cpus[i].times;
1573
1608
  totalUser += cpu.user;
@@ -1575,6 +1610,8 @@ function getLoad() {
1575
1610
  totalNice += cpu.nice;
1576
1611
  totalIdle += cpu.idle;
1577
1612
  totalIrq += cpu.irq;
1613
+ totalSteal += cpu.steal || 0;
1614
+ totalGuest += cpu.guest || 0;
1578
1615
  let tmpTick = (_cpus && _cpus[i] && _cpus[i].totalTick ? _cpus[i].totalTick : 0);
1579
1616
  let tmpLoad = (_cpus && _cpus[i] && _cpus[i].totalLoad ? _cpus[i].totalLoad : 0);
1580
1617
  let tmpUser = (_cpus && _cpus[i] && _cpus[i].user ? _cpus[i].user : 0);
@@ -1582,9 +1619,11 @@ function getLoad() {
1582
1619
  let tmpNice = (_cpus && _cpus[i] && _cpus[i].nice ? _cpus[i].nice : 0);
1583
1620
  let tmpIdle = (_cpus && _cpus[i] && _cpus[i].idle ? _cpus[i].idle : 0);
1584
1621
  let tmpIrq = (_cpus && _cpus[i] && _cpus[i].irq ? _cpus[i].irq : 0);
1622
+ let tmpSteal = (_cpus && _cpus[i] && _cpus[i].steal ? _cpus[i].steal : 0);
1623
+ let tmpGuest = (_cpus && _cpus[i] && _cpus[i].guest ? _cpus[i].guest : 0);
1585
1624
  _cpus[i] = cpu;
1586
- _cpus[i].totalTick = _cpus[i].user + _cpus[i].sys + _cpus[i].nice + _cpus[i].irq + _cpus[i].idle;
1587
- _cpus[i].totalLoad = _cpus[i].user + _cpus[i].sys + _cpus[i].nice + _cpus[i].irq;
1625
+ _cpus[i].totalTick = _cpus[i].user + _cpus[i].sys + _cpus[i].nice + _cpus[i].irq + _cpus[i].steal + _cpus[i].guest + _cpus[i].idle;
1626
+ _cpus[i].totalLoad = _cpus[i].user + _cpus[i].sys + _cpus[i].nice + _cpus[i].irq + _cpus[i].steal + _cpus[i].guest;
1588
1627
  _cpus[i].currentTick = _cpus[i].totalTick - tmpTick;
1589
1628
  _cpus[i].load = (_cpus[i].totalLoad - tmpLoad);
1590
1629
  _cpus[i].loadUser = (_cpus[i].user - tmpUser);
@@ -1592,6 +1631,8 @@ function getLoad() {
1592
1631
  _cpus[i].loadNice = (_cpus[i].nice - tmpNice);
1593
1632
  _cpus[i].loadIdle = (_cpus[i].idle - tmpIdle);
1594
1633
  _cpus[i].loadIrq = (_cpus[i].irq - tmpIrq);
1634
+ _cpus[i].loadSteal = (_cpus[i].steal - tmpSteal);
1635
+ _cpus[i].loadGuest = (_cpus[i].guest - tmpGuest);
1595
1636
  cores[i] = {};
1596
1637
  cores[i].load = _cpus[i].load / _cpus[i].currentTick * 100;
1597
1638
  cores[i].loadUser = _cpus[i].loadUser / _cpus[i].currentTick * 100;
@@ -1599,15 +1640,19 @@ function getLoad() {
1599
1640
  cores[i].loadNice = _cpus[i].loadNice / _cpus[i].currentTick * 100;
1600
1641
  cores[i].loadIdle = _cpus[i].loadIdle / _cpus[i].currentTick * 100;
1601
1642
  cores[i].loadIrq = _cpus[i].loadIrq / _cpus[i].currentTick * 100;
1643
+ cores[i].loadSteal = _cpus[i].loadSteal / _cpus[i].currentTick * 100;
1644
+ cores[i].loadGuest = _cpus[i].loadGuest / _cpus[i].currentTick * 100;
1602
1645
  cores[i].rawLoad = _cpus[i].load;
1603
1646
  cores[i].rawLoadUser = _cpus[i].loadUser;
1604
1647
  cores[i].rawLoadSystem = _cpus[i].loadSystem;
1605
1648
  cores[i].rawLoadNice = _cpus[i].loadNice;
1606
1649
  cores[i].rawLoadIdle = _cpus[i].loadIdle;
1607
1650
  cores[i].rawLoadIrq = _cpus[i].loadIrq;
1651
+ cores[i].rawLoadSteal = _cpus[i].loadSteal;
1652
+ cores[i].rawLoadGuest = _cpus[i].loadGuest;
1608
1653
  }
1609
- let totalTick = totalUser + totalSystem + totalNice + totalIrq + totalIdle;
1610
- let totalLoad = totalUser + totalSystem + totalNice + totalIrq;
1654
+ let totalTick = totalUser + totalSystem + totalNice + totalIrq + totalSteal + totalGuest + totalIdle;
1655
+ let totalLoad = totalUser + totalSystem + totalNice + totalIrq + totalSteal + totalGuest;
1611
1656
  let currentTick = totalTick - _current_cpu.tick;
1612
1657
  result = {
1613
1658
  avgLoad: avgLoad,
@@ -1617,12 +1662,16 @@ function getLoad() {
1617
1662
  currentLoadNice: (totalNice - _current_cpu.nice) / currentTick * 100,
1618
1663
  currentLoadIdle: (totalIdle - _current_cpu.idle) / currentTick * 100,
1619
1664
  currentLoadIrq: (totalIrq - _current_cpu.irq) / currentTick * 100,
1665
+ currentLoadSteal: (totalSteal - _current_cpu.steal) / currentTick * 100,
1666
+ currentLoadGuest: (totalGuest - _current_cpu.guest) / currentTick * 100,
1620
1667
  rawCurrentLoad: (totalLoad - _current_cpu.load),
1621
1668
  rawCurrentLoadUser: (totalUser - _current_cpu.user),
1622
1669
  rawCurrentLoadSystem: (totalSystem - _current_cpu.system),
1623
1670
  rawCurrentLoadNice: (totalNice - _current_cpu.nice),
1624
1671
  rawCurrentLoadIdle: (totalIdle - _current_cpu.idle),
1625
1672
  rawCurrentLoadIrq: (totalIrq - _current_cpu.irq),
1673
+ rawCurrentLoadSteal: (totalSteal - _current_cpu.steal),
1674
+ rawCurrentLoadGuest: (totalGuest - _current_cpu.guest),
1626
1675
  cpus: cores
1627
1676
  };
1628
1677
  _current_cpu = {
@@ -1631,6 +1680,8 @@ function getLoad() {
1631
1680
  system: totalSystem,
1632
1681
  idle: totalIdle,
1633
1682
  irq: totalIrq,
1683
+ steal: totalSteal,
1684
+ guest: totalGuest,
1634
1685
  tick: totalTick,
1635
1686
  load: totalLoad,
1636
1687
  ms: _current_cpu.ms,
@@ -1640,12 +1691,16 @@ function getLoad() {
1640
1691
  currentLoadNice: result.currentLoadNice,
1641
1692
  currentLoadIdle: result.currentLoadIdle,
1642
1693
  currentLoadIrq: result.currentLoadIrq,
1694
+ currentLoadSteal: result.currentLoadSteal,
1695
+ currentLoadGuest: result.currentLoadGuest,
1643
1696
  rawCurrentLoad: result.rawCurrentLoad,
1644
1697
  rawCurrentLoadUser: result.rawCurrentLoadUser,
1645
1698
  rawCurrentLoadSystem: result.rawCurrentLoadSystem,
1646
1699
  rawCurrentLoadNice: result.rawCurrentLoadNice,
1647
1700
  rawCurrentLoadIdle: result.rawCurrentLoadIdle,
1648
1701
  rawCurrentLoadIrq: result.rawCurrentLoadIrq,
1702
+ rawCurrentLoadSteal: result.rawCurrentLoadSteal,
1703
+ rawCurrentLoadGuest: result.rawCurrentLoadGuest,
1649
1704
  };
1650
1705
  } else {
1651
1706
  let cores = [];
@@ -1663,6 +1718,8 @@ function getLoad() {
1663
1718
  cores[i].rawLoadNice = _cpus[i].loadNice;
1664
1719
  cores[i].rawLoadIdle = _cpus[i].loadIdle;
1665
1720
  cores[i].rawLoadIrq = _cpus[i].loadIrq;
1721
+ cores[i].rawLoadSteal = _cpus[i].loadSteal;
1722
+ cores[i].rawLoadGuest = _cpus[i].loadGuest;
1666
1723
  }
1667
1724
  result = {
1668
1725
  avgLoad: avgLoad,
@@ -1672,12 +1729,16 @@ function getLoad() {
1672
1729
  currentLoadNice: _current_cpu.currentLoadNice,
1673
1730
  currentLoadIdle: _current_cpu.currentLoadIdle,
1674
1731
  currentLoadIrq: _current_cpu.currentLoadIrq,
1732
+ currentLoadSteal: _current_cpu.currentLoadSteal,
1733
+ currentLoadGuest: _current_cpu.currentLoadGuest,
1675
1734
  rawCurrentLoad: _current_cpu.rawCurrentLoad,
1676
1735
  rawCurrentLoadUser: _current_cpu.rawCurrentLoadUser,
1677
1736
  rawCurrentLoadSystem: _current_cpu.rawCurrentLoadSystem,
1678
1737
  rawCurrentLoadNice: _current_cpu.rawCurrentLoadNice,
1679
1738
  rawCurrentLoadIdle: _current_cpu.rawCurrentLoadIdle,
1680
1739
  rawCurrentLoadIrq: _current_cpu.rawCurrentLoadIrq,
1740
+ rawCurrentLoadSteal: _current_cpu.rawCurrentLoadSteal,
1741
+ rawCurrentLoadGuest: _current_cpu.rawCurrentLoadGuest,
1681
1742
  cpus: cores
1682
1743
  };
1683
1744
  }
package/lib/index.d.ts CHANGED
@@ -591,12 +591,16 @@ export namespace Systeminformation {
591
591
  currentLoadNice: number;
592
592
  currentLoadIdle: number;
593
593
  currentLoadIrq: number;
594
+ currentLoadSteal: number;
595
+ currentLoadGuest: number;
594
596
  rawCurrentLoad: number;
595
597
  rawCurrentLoadUser: number;
596
598
  rawCurrentLoadSystem: number;
597
599
  rawCurrentLoadNice: number;
598
600
  rawCurrentLoadIdle: number;
599
601
  rawCurrentLoadIrq: number;
602
+ rawCurrentLoadSteal: number;
603
+ rawCurrentLoadGuest: number;
600
604
  cpus: CurrentLoadCpuData[];
601
605
  }
602
606
 
@@ -607,12 +611,16 @@ export namespace Systeminformation {
607
611
  loadNice: number;
608
612
  loadIdle: number;
609
613
  loadIrq: number;
614
+ loadSteal: number;
615
+ loadGuest: number;
610
616
  rawLoad: number;
611
617
  rawLoadUser: number;
612
618
  rawLoadSystem: number;
613
619
  rawLoadNice: number;
614
620
  rawLoadIdle: number;
615
621
  rawLoadIrq: number;
622
+ rawLoadSteal: number;
623
+ rawLoadGuest: number;
616
624
  }
617
625
 
618
626
  interface ProcessesData {
package/lib/wifi.js CHANGED
@@ -345,6 +345,7 @@ function parseWifiDarwin(wifiObj) {
345
345
  const signalLevel = wifiItem.RSSI;
346
346
  let security = [];
347
347
  let wpaFlags = [];
348
+ let ssid = wifiItem.SSID_STR || '';
348
349
  if (wifiItem.WPA_IE) {
349
350
  security.push('WPA');
350
351
  if (wifiItem.WPA_IE.IE_KEY_WPA_UCIPHERS) {
@@ -365,9 +366,12 @@ function parseWifiDarwin(wifiObj) {
365
366
  });
366
367
  }
367
368
  }
369
+ // if (wifiItem.SSID) {
370
+ // ssid = Buffer.from(wifiItem.SSID, 'base64').toString('utf8');
371
+ // }
368
372
  result.push({
369
- ssid: wifiItem.SSID_STR,
370
- bssid: wifiItem.BSSID,
373
+ ssid,
374
+ bssid: wifiItem.BSSID || '',
371
375
  mode: '',
372
376
  channel: wifiItem.CHANNEL,
373
377
  frequency: wifiFrequencyFromChannel(wifiItem.CHANNEL),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "systeminformation",
3
- "version": "5.18.14",
3
+ "version": "5.19.0",
4
4
  "description": "Advanced, lightweight system and OS information library",
5
5
  "license": "MIT",
6
6
  "author": "Sebastian Hildebrandt <hildebrandt@plus-innovations.com> (https://plus-innovations.com)",