systeminformation 5.18.15 → 5.19.1

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
@@ -128,12 +128,13 @@ si.cpu()
128
128
 
129
129
  (last 7 major and minor version releases)
130
130
 
131
+ - Version 5.19.0: `currentLoad()` added steal and guest time (linux)
131
132
  - Version 5.18.0: `fsSize()` added optional drive parameter
132
- - Version 5.17.0: `graphics()` added positionX, positionY (mac OS)
133
+ - Version 5.17.0: `graphics()` added positionX, positionY (macOS)
133
134
  - Version 5.16.0: `fsSize()` added rw property
134
135
  - Version 5.15.0: `blockDevices()` added device
135
136
  - Version 5.14.0: `blockDevices()` added raid group member (linux)
136
- - Version 5.13.0: `networkConnections()` added process name (mac OS)
137
+ - Version 5.13.0: `networkConnections()` added process name (macOS)
137
138
  - Version 5.12.0: `cpu()` added performance and efficiency cores
138
139
  - Version 5.11.0: `networkInterfaces()` added default property and default parameter
139
140
  - Version 5.10.0: basic `android` support
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.15",
3
+ "version": "5.19.1",
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)",