new major version 4.0

This commit is contained in:
Sebastian Hildebrandt 2019-02-02 23:49:45 +01:00
parent 54c99da05d
commit b5f2c3f2c5
9 changed files with 284 additions and 160 deletions

View File

@ -1,105 +1,36 @@
# Changelog
### Major (breaking) Changes - Version 3
- works only with [node.js][nodejs-url] **v4.0.0** and above (using now internal ES6 promise function, arrow functions, ...)
- **Promises**. As you can see in the documentation, you can now also use it in a promise oriented way. But callbacks are still supported.
- **Async/Await**. Due to the promises support, systeminformation also works perfectly with the `async/await` pattern (available in [node.js][nodejs-url] **v7.6.0** and above). See example in the docs.
- `cpuCurrentspeed`: now returns an object with current minimal, maximal and average CPU frequencies of all cores.
- `mem`: now supports also newer versions of `free` (Version 3.3.10 and above); extended information `avaliable` (potentially available memory)
- `fsStats`: added information sum bytes read + write (tx) and sum transfer rate/sec (tx_sec)
- `networkInterfaces`: now providing one more detail: internal - true if this is an internal interface like "lo"
- `networkConnections`: instead of only counting sockets, you now get an array of objects with connection details for each socket (protocol, local and peer address, state)
- `users`: now provides an array of objects with users online including detailed session information (login date/time, ip address, terminal, command)
- `inetLatency`: now you can provide a host against which you want to test latency (default is 8.8.8.8)
- `getDynamicData`: changed order of parameters (callback - if provided - is now the last one): `getDynamicData(srv, network, callback)`
- `getAllData`: changed order of parameters (callback - if provided - is now the last one): `getAllData(srv, network, callback)`
### Major Changes - Version 4
New Functions
- FreeBSD support: for some basic functions (new in version 3.34 ff)
- `diskLayout`: returns hard disk layout (new in version 3.23)
- `memLayout`: returns memory chip layout (new in version 3.23)
- Windows support: for some basic functions (new in version 3.17 ff)
- `cpuCache`: returns CPU cache (L1, L2, L3) sizes (new in version 3.14)
- `cpuFlags`: returns CPU flags (new in version 3.14)
- `currentLoad.cpus`: returns current load per cpu/core in an array (new in version 3.14)
- `shell`: returns standard shell e.g. /bin/bash (new in version 3.13)
- `blockDevices`: returns array of block devices like disks, partitions, raids, roms (new in version 3.10)
- `dockerContainerProcesses`: returns processes for a specific docker container (new in version 3.8)
- `versions`: returns object of versions - kernel, ssl, node, npm, ...(new in version 3.6)
- `graphics`: returns arrays of graphics controllers and displays (new in version 3.5)
- `networkInterfaceDefault`: returns default network interface (new in version 3.4)
- `processes`: now returns also a process list with all process details (new in version 3.3)
- `battery`: retrieves battery status and charging level (new in version 3.2)
- `dockerContainers`: returns a list of all docker containers (new in version 3.1)
- `dockerContainerStats`: returns statistics for a specific docker container (new in version 3.1)
- `dockerAll`: returns a list of all docker containers including their stats (new in version 3.1)
- `disksIO`: returns overall diskIO and IOPS values for all mounted volumes (new in version 3.0)
- `chassis()`: chassis information
Bug Fixes / improvements
Breaking Changes
- improvement `cpuTemperature` - works now also on Raspberry Pi
- bugfix `disksIO` - on OSX read and write got mixed up
- several bug fixes (like assess errors in `cpuCurrentspeed`, potentially incorrect results in `users`, ...)
- testet on even more platforms and linux distributions
- `networkStats()`: will provide an **array** of stats for all given interfaces. In previous versions only one interface was provided as a parameter. Pass '*' for all interfaces
- `networkStats()`: `rx` and `tx` changed to `rx_bytes` and `tx_bytes`
- `dockerContainerStats()`: will provide an **array** of stats for all given docker containers. In previous versions only one interface was provided as a parameter. Pass '*' for all docker containers
**Be aware**, that the new version 3.x is **NOT fully backward compatible** to version 2.x ...
Other Changes
- `system()` optimized system detection (e.g. new Raspberry Pi models, ...)
- `system()`, `bios()`, `baseboard()` information also as non-root (linux)
- `graphics()` bettercontroller and display detection, fixes
- `versions()` optimization, fixes
- `networkInterfaces()` added `operstate`, `type`, `duplex`, `mtu`, `speed`, `carrierChanges`
- `networkStats()` added stats for `errors`, `dropped`
- added TypeScript definitions
### Major (breaking) Changes - Version 2
**Be aware**, that the new version 4.x is **NOT fully backward compatible** to version 3.x ...
There had been a lot of changes in version 2 of systeminformation! Here is a quick overview (for those who come from version 1):
New Functions
- `version`: returns systeminformation version (semver) of this library
- `system`: hardware info (manufacturer, product/model name, version, serial, uuid)
- `networkConnections`: number of active connections
- `inetLatency`: latency in ms to external resource (internet)
- `getStaticData`: returns on json object with static data at once (OS, CPU, Network Interfaces - they should not change until restarted)
- `getDynamicData`: returns on json object with all dynamic data at once (e.g. for monitoring agents)
- `getAllData`: returns on json object with all data (static and dynamic) at once
Renamed Functions (now all camelCase)
- `osinfo`: renamed to `osInfo`
- `cpu_currentspeed`: renamed to `cpuCurrentspeed`
- `cpu_temperature`: renamed to `cpuTemperature`
- `fs_size`: renamed to `fsSize`
- `fs_speed`: renamed to `fsStats`
- `network_interfaces`: renamed to `networkInterfaces`
- `network_speed`: renamed to `networkStats`
- `network_connections`: renamed to `networkConnections`
- `currentload`: renamed to `currentLoad`
- `fullload`: renamed to `fullLoad`
- `processload`: renamed to `processLoad`
- `checksite`: renamed to `inetChecksite`
Function Changes
- `cpu_temperature`/`cpuTemperature`: -1 is new default (and indicates that non sensors are installed)
- `cpu_temperature`/`cpuTemperature`: new result `max` which returns max temperature of all cores
- `cpu_currentspeed`/`cpuCurrentspeed`: now in GHz
- `cpu`: splitted `manufacturer` (e.g. Intel) and `brand` (e.g. Core 2 Duo)
- `network_speed`/`networkStats`: now better support for OS X (also support for `operstate`)
- `network_speed`/`networkStats`: overall received and transferred bytes (rx, tx)
- `mem`: now better support for OS X (also support for `swaptotal`, `swapused`, `swapfree`)
- `fs_size`/`fsSize`: use-values now in % (0 - 100% instead of 0 - 1)
- `fs_speed`/`fsStats`: now also full support for OS X
- `checksite`/`inetChecksite`: new result structure - see command reference
- `checksite`/`inetChecksite`: ms (former `response_ms`): -1 if not ok
Other changes
- osx-temperature-sensor: now added as an optional dependency
- no more external dependencies: `request` is not longer needed
- where possible results are now integer or float values (instead of strings) because it is easier to calculate with numbers ;-)
For major (breaking) changes - version 3 and 2 see end of page.
## Version history
| Version | Date | Comment |
| -------------- | -------------- | -------- |
| 4.0.0 | 2019-02-02 | new major version |
| 3.54.0 | 2018-12-30 | added TypeScript type definitions |
| 3.53.1 | 2018-12-29 | `versions()` bug fix nginx version |
| 3.53.0 | 2018-12-29 | `versions()` added perl, python, gcc |
@ -295,4 +226,99 @@ Other changes
| 0.0.2 | 2014-03-14 | Optimization FS-Speed & CPU current speed |
| 0.0.1 | 2014-03-13 | initial release |
### Major (breaking) Changes - Version 3
- works only with [node.js][nodejs-url] **v4.0.0** and above (using now internal ES6 promise function, arrow functions, ...)
- **Promises**. As you can see in the documentation, you can now also use it in a promise oriented way. But callbacks are still supported.
- **Async/Await**. Due to the promises support, systeminformation also works perfectly with the `async/await` pattern (available in [node.js][nodejs-url] **v7.6.0** and above). See example in the docs.
- `cpuCurrentspeed`: now returns an object with current minimal, maximal and average CPU frequencies of all cores.
- `mem`: now supports also newer versions of `free` (Version 3.3.10 and above); extended information `avaliable` (potentially available memory)
- `fsStats`: added information sum bytes read + write (tx) and sum transfer rate/sec (tx_sec)
- `networkInterfaces`: now providing one more detail: internal - true if this is an internal interface like "lo"
- `networkConnections`: instead of only counting sockets, you now get an array of objects with connection details for each socket (protocol, local and peer address, state)
- `users`: now provides an array of objects with users online including detailed session information (login date/time, ip address, terminal, command)
- `inetLatency`: now you can provide a host against which you want to test latency (default is 8.8.8.8)
- `getDynamicData`: changed order of parameters (callback - if provided - is now the last one): `getDynamicData(srv, network, callback)`
- `getAllData`: changed order of parameters (callback - if provided - is now the last one): `getAllData(srv, network, callback)`
New Functions
- FreeBSD support: for some basic functions (new in version 3.34 ff)
- `diskLayout`: returns hard disk layout (new in version 3.23)
- `memLayout`: returns memory chip layout (new in version 3.23)
- Windows support: for some basic functions (new in version 3.17 ff)
- `cpuCache`: returns CPU cache (L1, L2, L3) sizes (new in version 3.14)
- `cpuFlags`: returns CPU flags (new in version 3.14)
- `currentLoad.cpus`: returns current load per cpu/core in an array (new in version 3.14)
- `shell`: returns standard shell e.g. /bin/bash (new in version 3.13)
- `blockDevices`: returns array of block devices like disks, partitions, raids, roms (new in version 3.10)
- `dockerContainerProcesses`: returns processes for a specific docker container (new in version 3.8)
- `versions`: returns object of versions - kernel, ssl, node, npm, ...(new in version 3.6)
- `graphics`: returns arrays of graphics controllers and displays (new in version 3.5)
- `networkInterfaceDefault`: returns default network interface (new in version 3.4)
- `processes`: now returns also a process list with all process details (new in version 3.3)
- `battery`: retrieves battery status and charging level (new in version 3.2)
- `dockerContainers`: returns a list of all docker containers (new in version 3.1)
- `dockerContainerStats`: returns statistics for a specific docker container (new in version 3.1)
- `dockerAll`: returns a list of all docker containers including their stats (new in version 3.1)
- `disksIO`: returns overall diskIO and IOPS values for all mounted volumes (new in version 3.0)
Bug Fixes / improvements
- improvement `cpuTemperature` - works now also on Raspberry Pi
- bugfix `disksIO` - on OSX read and write got mixed up
- several bug fixes (like assess errors in `cpuCurrentspeed`, potentially incorrect results in `users`, ...)
- testet on even more platforms and linux distributions
**Be aware**, that the new version 3.x is **NOT fully backward compatible** to version 2.x ...
### Major (breaking) Changes - Version 2
There had been a lot of changes in version 2 of systeminformation! Here is a quick overview (for those who come from version 1):
New Functions
- `version`: returns systeminformation version (semver) of this library
- `system`: hardware info (manufacturer, product/model name, version, serial, uuid)
- `networkConnections`: number of active connections
- `inetLatency`: latency in ms to external resource (internet)
- `getStaticData`: returns on json object with static data at once (OS, CPU, Network Interfaces - they should not change until restarted)
- `getDynamicData`: returns on json object with all dynamic data at once (e.g. for monitoring agents)
- `getAllData`: returns on json object with all data (static and dynamic) at once
Renamed Functions (now all camelCase)
- `osinfo`: renamed to `osInfo`
- `cpu_currentspeed`: renamed to `cpuCurrentspeed`
- `cpu_temperature`: renamed to `cpuTemperature`
- `fs_size`: renamed to `fsSize`
- `fs_speed`: renamed to `fsStats`
- `network_interfaces`: renamed to `networkInterfaces`
- `network_speed`: renamed to `networkStats`
- `network_connections`: renamed to `networkConnections`
- `currentload`: renamed to `currentLoad`
- `fullload`: renamed to `fullLoad`
- `processload`: renamed to `processLoad`
- `checksite`: renamed to `inetChecksite`
Function Changes
- `cpu_temperature`/`cpuTemperature`: -1 is new default (and indicates that non sensors are installed)
- `cpu_temperature`/`cpuTemperature`: new result `max` which returns max temperature of all cores
- `cpu_currentspeed`/`cpuCurrentspeed`: now in GHz
- `cpu`: splitted `manufacturer` (e.g. Intel) and `brand` (e.g. Core 2 Duo)
- `network_speed`/`networkStats`: now better support for OS X (also support for `operstate`)
- `network_speed`/`networkStats`: overall received and transferred bytes (rx, tx)
- `mem`: now better support for OS X (also support for `swaptotal`, `swapused`, `swapfree`)
- `fs_size`/`fsSize`: use-values now in % (0 - 100% instead of 0 - 1)
- `fs_speed`/`fsStats`: now also full support for OS X
- `checksite`/`inetChecksite`: new result structure - see command reference
- `checksite`/`inetChecksite`: ms (former `response_ms`): -1 if not ok
Other changes
- osx-temperature-sensor: now added as an optional dependency
- no more external dependencies: `request` is not longer needed
- where possible results are now integer or float values (instead of strings) because it is easier to calculate with numbers ;-)
[nodejs-url]: https://nodejs.org/en/

View File

@ -14,17 +14,16 @@ Simple system and OS information library for [node.js][nodejs-url]
[![Caretaker][caretaker-image]][caretaker-url]
[![MIT license][license-img]][license-url]
## Version 4.0 - just arround the corner
## New Version 4.0
I am currently working on the next major release, version 4.0. What you will see is
This next major version release 4.0 comes with several optimizations and changes:
- new systeminformation website with better documentation and examples
- new systeminformation website with better documentation and examples [systeminformation.io][systeminformation-url]
- added typescript definitions
- added JsDoc
- automated tests - travis-ci integration
- reworked network section: this will now return more information and allows to get networkStats for more than one interface at once.
- dockerContainerStats for all containers at once
- fsstats per disk (and all at once)
- dockerContainerStats for multiple containers or all containers at once
- optimized graphics controller and display detection
- added chassis information
- better Raspberry-PI detection
- lot of minor improvements
@ -32,7 +31,7 @@ But be aware: you will see some minor breaking changes. I expect to finalize the
## Quick Start
Lightweight collection of 35+ functions to retrieve detailed hardware, system and OS information.
Lightweight collection of 40+ functions to retrieve detailed hardware, system and OS information.
- simple to use
- get detailed information about system, cpu, baseboard, battery, memory, disks/filesystem, network, docker, software, services and processes
@ -401,18 +400,18 @@ I also created a nice little command line tool called [mmon][mmon-github-url] (
| | [0].speed | X | | | X | | speed in MBit / s |
| | [0].carrierChanges | X | | | | | # changes up/down |
| si.networkInterfaceDefault(cb) | : string | X | X | X | X | X | get name of default network interface |
| si.networkStats(iface,cb) | {...} | X | X | X | X | | current network stats of given interface<br>iface parameter is optional<br>defaults to first external network interface|
| | iface | X | X | X | X | | interface |
| | operstate | X | X | X | X | | up / down |
| | rx_bytes | X | X | X | X | | received bytes overall |
| | rx_dropped | X | X | X | X | | received dropped overall |
| | rx_errors | X | X | X | X | | received errors overall |
| | tx_bytes | X | X | X | X | | transferred bytes overall |
| | tx_dropped | X | X | X | X | | transferred dropped overall |
| | tx_errors | X | X | X | X | | transferred errors overall |
| | rx_sec | X | X | X | X | | received bytes / second (* see notes) |
| | tx_sec | X | X | X | X | | transferred bytes per second (* see notes) |
| | ms | X | X | X | X | | interval length (for per second values) |
| si.networkStats(ifaces,cb) | [{...}] | X | X | X | X | | current network stats of given interfaces<br>iface list: space or comma separated<br>iface parameter is optional<br>defaults to first external network interface,<br />pass '*' for all interfaces |
| | [0].iface | X | X | X | X | | interface |
| | [0].operstate | X | X | X | X | | up / down |
| | [0].rx_bytes | X | X | X | X | | received bytes overall |
| | [0].rx_dropped | X | X | X | X | | received dropped overall |
| | [0].rx_errors | X | X | X | X | | received errors overall |
| | [0].tx_bytes | X | X | X | X | | transferred bytes overall |
| | [0].tx_dropped | X | X | X | X | | transferred dropped overall |
| | [0].tx_errors | X | X | X | X | | transferred errors overall |
| | [0].rx_sec | X | X | X | X | | received bytes / second (* see notes) |
| | [0].tx_sec | X | X | X | X | | transferred bytes per second (* see notes) |
| | [0].ms | X | X | X | X | | interval length (for per second values) |
| si.networkConnections(cb) | [{...}] | X | X | X | X | | current network network connections<br>returns an array of all connections|
| | [0].protocol | X | X | X | X | | tcp or udp |
| | [0].localaddress | X | X | X | X | | local address |
@ -441,21 +440,21 @@ I also created a nice little command line tool called [mmon][mmon-github-url] (
| | [0].state | X | X | X | X | X | created, running, exited |
| | [0].ports | X | X | X | X | X | array of ports |
| | [0].mounts | X | X | X | X | X | array of mounts |
| si.dockerContainerStats(id, cb) | {...} | X | X | X | X | X | statistics for a specific container |
| | id | X | X | X | X | X | Container ID |
| | mem_usage | X | X | X | X | X | memory usage in bytes |
| | mem_limit | X | X | X | X | X | memory limit (max mem) in bytes |
| | mem_percent | X | X | X | X | X | memory usage in percent |
| | cpu_percent | X | X | X | X | X | cpu usage in percent |
| | pids | X | X | X | X | X | number of processes |
| | netIO.rx | X | X | X | X | X | received bytes via network |
| | netIO.wx | X | X | X | X | X | sent bytes via network |
| | blockIO.r | X | X | X | X | X | bytes read from BlockIO |
| | blockIO.w | X | X | X | X | X | bytes written to BlockIO |
| | cpu_stats | X | X | X | X | X | detailed cpu stats |
| | percpu_stats | X | X | X | X | X | detailed per cpu stats |
| | memory_stats | X | X | X | X | X | detailed memory stats |
| | networks | X | X | X | X | X | detailed network stats per interface |
| si.dockerContainerStats(ids, cb) | [{...}] | X | X | X | X | X | statistics for specific containers<br>container IDs: space or comma separated,<br>pass '*' for all containers|
| | [0].id | X | X | X | X | X | Container ID |
| | [0].mem_usage | X | X | X | X | X | memory usage in bytes |
| | [0].mem_limit | X | X | X | X | X | memory limit (max mem) in bytes |
| | [0].mem_percent | X | X | X | X | X | memory usage in percent |
| | [0].cpu_percent | X | X | X | X | X | cpu usage in percent |
| | [0].pids | X | X | X | X | X | number of processes |
| | [0].netIO.rx | X | X | X | X | X | received bytes via network |
| | [0].netIO.wx | X | X | X | X | X | sent bytes via network |
| | [0].blockIO.r | X | X | X | X | X | bytes read from BlockIO |
| | [0].blockIO.w | X | X | X | X | X | bytes written to BlockIO |
| | [0].cpu_stats | X | X | X | X | X | detailed cpu stats |
| | [0].percpu_stats | X | X | X | X | X | detailed per cpu stats |
| | [0].memory_stats | X | X | X | X | X | detailed memory stats |
| | [0].networks | X | X | X | X | X | detailed network stats per interface |
| si.dockerContainerProcesses(id, cb) | [{...}] | X | X | X | X | X | array of processes inside a container |
| | [0].pid_host | X | X | X | X | X | process ID (host) |
| | [0].ppid | X | X | X | X | X | parent process ID |
@ -700,6 +699,7 @@ All other trademarks are the property of their respective owners.
[nodejs-url]: https://nodejs.org/en/
[docker-url]: https://www.docker.com/
[systeminformation-url]: https://systeminformation.io
[daviddm-img]: https://img.shields.io/david/sebhildebrandt/systeminformation.svg?style=flat-square
[daviddm-url]: https://david-dm.org/sebhildebrandt/systeminformation

View File

@ -160,14 +160,14 @@
<td>array of mounts</td>
</tr>
<tr>
<td>si.dockerContainerStats(id, cb)</td>
<td>{...}</td>
<td>si.dockerContainerStats(ids, cb)</td>
<td>[{...}]</td>
<td>X</td>
<td>X</td>
<td>X</td>
<td>X</td>
<td>X</td>
<td>statistics for a specific container</td>
<td>statistics for specific containers<br>container IDs: space or comma separated,<br>pass '*' for all containers</td>
</tr>
<tr>
<td></td>

View File

@ -165,7 +165,7 @@
<div class="title">systeminformation</div>
<div class="subtitle"><span id="typed"></span></div>
<div class="version">Current Version: <span id="version">4.0.0</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 class="down">
Read Documentation<br>
@ -177,7 +177,7 @@
<div class="row">
<div class="col-12 sectionheader index">
<div class="title">Overview</div>
<div class="subtitle">Lightweight collection of 35+ functions to retrieve detailed hardware, system and OS information. For Linux, macOS, partial Windows, FreeBSD and SunOS support</div>
<div class="subtitle">Lightweight collection of 40+ functions to retrieve detailed hardware, system and OS information. For Linux, macOS, partial Windows, FreeBSD and SunOS support</div>
</div>
</div>
<div class="row justify-content-center sectionheader index">

View File

@ -201,17 +201,17 @@
</tr>
<tr>
<td>si.networkStats(iface,cb)</td>
<td>{...}</td>
<td>[{...}]</td>
<td>X</td>
<td>X</td>
<td>X</td>
<td>X</td>
<td></td>
<td>current network stats of given interface<br />iface parameter is optional<br />defaults to first external network interface</td>
<td>current network stats of given interfaces,<br />iface list: comma separated,<br />iface parameter is optional,<br />defaults to first external network interface,<br />pass '*' for all interfaces</td>
</tr>
<tr>
<td></td>
<td>iface</td>
<td>[0].iface</td>
<td>X</td>
<td>X</td>
<td>X</td>
@ -221,7 +221,7 @@
</tr>
<tr>
<td></td>
<td>operstate</td>
<td>[0].operstate</td>
<td>X</td>
<td>X</td>
<td>X</td>
@ -231,7 +231,7 @@
</tr>
<tr>
<td></td>
<td>rx_bytes</td>
<td>[0].rx_bytes</td>
<td>X</td>
<td>X</td>
<td>X</td>
@ -241,7 +241,7 @@
</tr>
<tr>
<td></td>
<td>rx_dropped</td>
<td>[0].rx_dropped</td>
<td>X</td>
<td>X</td>
<td>X</td>
@ -251,7 +251,7 @@
</tr>
<tr>
<td></td>
<td>rx_errors</td>
<td>[0].rx_errors</td>
<td>X</td>
<td>X</td>
<td>X</td>
@ -261,7 +261,7 @@
</tr>
<tr>
<td></td>
<td>tx_bytes</td>
<td>[0].tx_bytes</td>
<td>X</td>
<td>X</td>
<td>X</td>
@ -271,7 +271,7 @@
</tr>
<tr>
<td></td>
<td>tx_dropped</td>
<td>[0].tx_dropped</td>
<td>X</td>
<td>X</td>
<td>X</td>
@ -281,7 +281,7 @@
</tr>
<tr>
<td></td>
<td>tx_errors</td>
<td>[0].tx_errors</td>
<td>X</td>
<td>X</td>
<td>X</td>
@ -291,7 +291,7 @@
</tr>
<tr>
<td></td>
<td>rx_sec</td>
<td>[0].rx_sec</td>
<td>X</td>
<td>X</td>
<td>X</td>
@ -301,7 +301,7 @@
</tr>
<tr>
<td></td>
<td>tx_sec</td>
<td>[0].tx_sec</td>
<td>X</td>
<td>X</td>
<td>X</td>
@ -311,7 +311,7 @@
</tr>
<tr>
<td></td>
<td>ms</td>
<td>[0].ms</td>
<td>X</td>
<td>X</td>
<td>X</td>

View File

@ -312,9 +312,9 @@
<tr>
<td></td>
<td>sku</td>
<td>X</td>
<td>X</td>
<td>X</td>
<td></td>
<td></td>
<td></td>
<td>X</td>
<td></td>
<td>SKU number</td>

View File

@ -203,10 +203,60 @@ function docker_calcBlockIO(blkio_stats) {
return result;
}
function dockerContainerStats(containerIDs, callback) {
let containerArray = [];
// fallback - if only callback is given
if (util.isFunction(containerIDs) && !callback) {
callback = containerIDs;
containerIDs = '*';
} else {
containerIDs = containerIDs || '*';
containerIDs = containerIDs.trim().toLowerCase().replace(/,+/g, '|');
containerArray = containerIDs.split('|');
}
return new Promise((resolve) => {
process.nextTick(() => {
const result = [];
const workload = [];
if (containerArray.length && containerArray[0].trim() === '*') {
containerArray = [];
dockerContainers().then(allContainers => {
for (let container of allContainers) {
containerArray.push(container.id);
}
dockerContainerStats(containerArray.join(',')).then(result => {
if (callback) { callback(result); }
resolve(result);
});
});
} else {
for (let containerID of containerArray) {
workload.push(dockerContainerStatsSingle(containerID.trim()));
}
if (workload.length) {
Promise.all(
workload
).then(data => {
if (callback) { callback(data); }
resolve(data);
});
} else {
if (callback) { callback(result); }
resolve(result);
}
}
});
});
}
// --------------------------
// container stats (for one container)
function dockerContainerStats(containerID, callback) {
function dockerContainerStatsSingle(containerID, callback) {
containerID = containerID || '';
let result = {
id: containerID,

14
lib/index.d.ts vendored
View File

@ -39,6 +39,16 @@ export namespace Systeminformation {
assetTag: string;
}
interface ChassisData {
manufacturer: string;
model: string;
type: string;
version: string;
serial: string;
assetTag: string;
sku: string;
}
// 3. CPU, Memory, Disks, Battery, Graphics
interface CpuData {
@ -446,6 +456,7 @@ export namespace Systeminformation {
system: SystemData;
bios: BiosData;
baseboard: BaseboardData;
chassis: ChassisData;
os: OsData;
uuid: UuidData;
versions: VersionData;
@ -462,6 +473,7 @@ export function version(): string;
export function system(cb?: (data: Systeminformation.SystemData) => any): Promise<Systeminformation.SystemData>;
export function bios(cb?: (data: Systeminformation.BiosData) => any): Promise<Systeminformation.BiosData>;
export function baseboard(cb?: (data: Systeminformation.BaseboardData) => any): Promise<Systeminformation.BaseboardData>;
export function chassis(cb?: (data: Systeminformation.ChassisData) => any): Promise<Systeminformation.ChassisData>;
export function time(): Systeminformation.TimeData;
export function osInfo(cb?: (data: Systeminformation.OsData) => any): Promise<Systeminformation.OsData>;
@ -492,7 +504,7 @@ export function diskLayout(cb?: (data: Systeminformation.DiskLayoutData) => any)
export function networkInterfaceDefault(cb?: (data: string) => any): Promise<string>;
export function networkInterfaces(cb?: (data: Systeminformation.NetworkInterfacesData[]) => any): Promise<Systeminformation.NetworkInterfacesData[]>;
export function networkStats(iface?: string, cb?: (data: Systeminformation.NetworkStatsData) => any): Promise<Systeminformation.NetworkStatsData>;
export function networkStats(ifaces?: string, cb?: (data: Systeminformation.NetworkStatsData[]) => any): Promise<Systeminformation.NetworkStatsData[]>;
export function networkConnections(cb?: (data: Systeminformation.NetworkConnectionsData[]) => any): Promise<Systeminformation.NetworkConnectionsData[]>;
export function inetChecksite(url: string, cb?: (data: Systeminformation.InetChecksiteData) => any): Promise<Systeminformation.InetChecksiteData>;
export function inetLatency(host?: string, cb?: (data: number) => any): Promise<number>;

View File

@ -341,7 +341,7 @@ function networkInterfaces(callback) {
try {
lines = execSync(cmd).toString().split('\n');
} catch (e) {
util.noop();
}
duplex = util.getValue(lines, 'duplex');
duplex = duplex.startsWith('cat') ? '' : duplex;
@ -456,7 +456,57 @@ function calcNetworkSpeed(iface, rx_bytes, tx_bytes, operstate, rx_dropped, rx_e
return result;
}
function networkStats(iface, callback) {
function networkStats(ifaces, callback) {
let ifacesArray = [];
// fallback - if only callback is given
if (util.isFunction(ifaces) && !callback) {
callback = ifaces;
ifaces = [getDefaultNetworkInterface()];
} else {
ifaces = ifaces || getDefaultNetworkInterface();
ifaces = ifaces.trim().toLowerCase().replace(/,+/g, '|');
ifacesArray = ifaces.split('|');
}
return new Promise((resolve) => {
process.nextTick(() => {
const result = [];
const workload = [];
if (ifacesArray.length && ifacesArray[0].trim() === '*') {
ifacesArray = [];
networkInterfaces().then(allIFaces => {
for (let iface of allIFaces) {
ifacesArray.push(iface.iface);
}
networkStats(ifacesArray.join(',')).then(result => {
if (callback) { callback(result); }
resolve(result);
});
});
} else {
for (let iface of ifacesArray) {
workload.push(networkStatsSingle(iface.trim()));
}
if (workload.length) {
Promise.all(
workload
).then(data => {
if (callback) { callback(data); }
resolve(data);
});
} else {
if (callback) { callback(result); }
resolve(result);
}
}
});
});
}
function networkStatsSingle(iface) {
function parseLinesWindowsPerfData(sections) {
let perfData = [];
@ -480,17 +530,9 @@ function networkStats(iface, callback) {
return perfData;
}
// fallback - if only callback is given
if (util.isFunction(iface) && !callback) {
callback = iface;
iface = '';
}
return new Promise((resolve) => {
process.nextTick(() => {
iface = iface || getDefaultNetworkInterface();
let result = {
iface: iface,
operstate: 'unknown',
@ -539,11 +581,9 @@ function networkStats(iface, callback) {
result = calcNetworkSpeed(iface, rx_bytes, tx_bytes, operstate, rx_dropped, rx_errors, tx_dropped, tx_errors);
}
if (callback) { callback(result); }
resolve(result);
});
} else {
if (callback) { callback(result); }
resolve(result);
}
}
@ -566,7 +606,6 @@ function networkStats(iface, callback) {
}
result = calcNetworkSpeed(iface, rx_bytes, tx_bytes, operstate, rx_dropped, rx_errors, tx_dropped, tx_errors);
}
if (callback) { callback(result); }
resolve(result);
});
}
@ -595,7 +634,6 @@ function networkStats(iface, callback) {
result = calcNetworkSpeed(iface, rx_bytes, tx_bytes, result.operstate, rx_dropped, rx_errors, tx_dropped, tx_errors);
}
}
if (callback) { callback(result); }
resolve(result);
});
});
@ -635,7 +673,6 @@ function networkStats(iface, callback) {
if (rx_bytes && tx_bytes) {
result = calcNetworkSpeed(ifaceName, parseInt(rx_bytes), parseInt(tx_bytes), operstate, rx_dropped, rx_errors, tx_dropped, tx_errors);
}
if (callback) { callback(result); }
resolve(result);
});
});
@ -647,7 +684,6 @@ function networkStats(iface, callback) {
result.tx_sec = _network[iface].tx_sec;
result.ms = _network[iface].last_ms;
result.operstate = _network[iface].operstate;
if (callback) { callback(result); }
resolve(result);
}
});