New major release 3.0

This commit is contained in:
Sebastian Hildebrandt 2016-08-03 09:07:54 +02:00
parent 8ebf6c7548
commit b1d4b4ff65
4 changed files with 1810 additions and 957 deletions

23
.editorconfig Normal file
View File

@ -0,0 +1,23 @@
# For more information about the properties used in
# this file, please see the EditorConfig documentation:
# http://editorconfig.org/
# top-most EditorConfig file
root = true
[*]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = true
[{.travis.yml,package.json}]
# The indent size used in the `package.json` file cannot be changed
# https://github.com/npm/npm/pull/3180#issuecomment-16336516
indent_style = space
indent_size = 2

137
README.md
View File

@ -4,6 +4,8 @@ Simple system and OS information library for [node.js][nodejs-url]
[![NPM Version][npm-image]][npm-url] [![NPM Version][npm-image]][npm-url]
[![NPM Downloads][downloads-image]][downloads-url] [![NPM Downloads][downloads-image]][downloads-url]
[![Git Issues][issues-img]][issues-url]
[![deps status][daviddm-img]][daviddm-url]
[![MIT license][license-img]][license-url] [![MIT license][license-img]][license-url]
## Quick Start ## Quick Start
@ -21,19 +23,52 @@ All functions (except `version` and `time`) are implemented as asynchronous func
``` ```
var si = require('systeminformation'); var si = require('systeminformation');
// callback style
si.cpu(function(data) { si.cpu(function(data) {
console.log('CPU-Information:'); console.log('CPU-Information:');
console.log(data); console.log(data);
}) })
// promises style
si.cpu()
.then(data => console.log(data))
.catch(error => console.error(error));
``` ```
### Major Changes - Version 2 ### Major (breaking) Changes - Version 3
There are a lot of changes in version 2 of systeminformation! Here is a quick overview: - 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 above, you can now also use it in a promise oriented way. But callbacks are still supported.
- `cpuCurrentspeed`: now returns an object with current minimal, maximal and average CPU frequencies of all cores.
- `networkInterfaces`: now providing one more detail: internal - true if this is an internal interface like "lo"
- `mem`: now supports also `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)
- `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 New Functions
- `version`: returns systeminformation version (semver) - `disksIO`: returns overall diskIO and IOPS values for all mounted volumes
Bug Fixes
- several bug fixes (like assess errors)
- 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) - `system`: hardware info (manufacturer, product/model name, version, serial, uuid)
- `networkConnections`: number of active connections - `networkConnections`: number of active connections
- `inetLatency`: latency in ms to external resource (internet) - `inetLatency`: latency in ms to external resource (internet)
@ -75,15 +110,14 @@ Other changes
- no more external dependencies: `request` is not longer needed - 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 ;-) - where possible results are now integer or float values (instead of strings) because it is easier to calculate with numbers ;-)
**Be aware**, that the new version 2.x is **NOT backward compatible** to version 1.x ....
## Core concept ## Core concept
[Node.js][nodejs-url] comes with some basic OS information, but I always wanted a little more. So I came up to write this [Node.js][nodejs-url] comes with some basic OS information, but I always wanted a little more. So I came up to write this
little library. This library is still work in progress. In version 2 I cleaned up a lot of inconsistencies and bugs, but little library. This library is still work in progress. Version 3 comes with further improvements. First it
there is for sure room for improvement. I was only able to test it on several Debian, Raspbian, Ubuntu distributions as well requires now node.js version 4.0 and above. Another big change is, that all functions now return promises. You can use them
as OS X (Mavericks, Yosemite, El Captain). Version 2 now also supports nearly all functionality on OS X/Darwin platforms. like before with callbacks OR with promises (see example in this documentation). I am sure, there is for sure room for improvement.
But be careful, this library will definitely NOT work on Windows platforms! I was only able to test it on several Debian, Raspbian, Ubuntu distributions as well as OS X (Mavericks, Yosemite, El Captain).
Since version 2 nearly all functionality is available on OS X/Darwin platforms. But be careful, this library will definitely NOT work on Windows platforms!
If you have comments, suggestions & reports, please feel free to contact me! If you have comments, suggestions & reports, please feel free to contact me!
@ -133,17 +167,21 @@ This library is splitted in several sections:
| - brand | X | X | e.g. 'Core(TM)2 Duo' | | - brand | X | X | e.g. 'Core(TM)2 Duo' |
| - speed | X | X | in GHz e.g. '3.40' | | - speed | X | X | in GHz e.g. '3.40' |
| - cores | X | X | # cores | | - cores | X | X | # cores |
| si.cpuCurrentspeed(cb) | X | X | current speed (in GHz)| | si.cpuCurrentspeed(cb) | X | X | current CPU speed (in GHz)|
| - avg | X | | avg CPU speed (all cores) |
| - min | X | | min CPU speed (all cores) |
| - max | X | | max CPU speed (all cores) |
| si.cpuTemperature(cb) | X | | CPU temperature (if sensors is installed) | | si.cpuTemperature(cb) | X | | CPU temperature (if sensors is installed) |
| - main | X | | main temperature | | - main | X | | main temperature |
| - cores | X | | array of temperatures | | - cores | X | | array of temperatures |
| - max | X | | max temperature | | - max | X | | max temperature |
| si.mem(cb) | X | X | Memory information| | si.mem(cb) | X | X | Memory information|
| - total | X | X | | | - total | X | X | total memory |
| - free | X | X | | | - free | X | X | not used |
| - used | X | X | | | - used | X | X | used (incl. buffers/cache) |
| - active | X | X | | | - active | X | X | used actively (excl. buffers/cache) |
| - buffcache | X | X | | | - buffcache | X | X | used by buffers+cache |
| - available | X | X | potentially available (total - active) |
| - swaptotal | X | X | | | - swaptotal | X | X | |
| - swapused | X | X | | | - swapused | X | X | |
| - swapfree | X | X | | | - swapfree | X | X | |
@ -156,19 +194,39 @@ This library is splitted in several sections:
| si.fsStats(cb) | X | X | current transfer stats | | si.fsStats(cb) | X | X | current transfer stats |
| - rx | X | X | bytes read since startup | | - rx | X | X | bytes read since startup |
| - wx | X | X | bytes written since startup | | - wx | X | X | bytes written since startup |
| - tx | X | X | total bytes read + written since startup |
| - rx_sec | X | X | bytes read / second (* see notes) | | - rx_sec | X | X | bytes read / second (* see notes) |
| - wx_sec | X | X | bytes written / second (* see notes) | | - wx_sec | X | X | bytes written / second (* see notes) |
| - tx_sec | X | X | total bytes reads + written / second |
| - ms | X | X | interval length (for per second values) |
| si.disksIO(cb) | X | X | current transfer stats |
| - rIO | X | X | read IOs on all mounted drives |
| - wIO | X | X | write IOs on all mounted drives |
| - tIO | X | X | write IOs on all mounted drives |
| - rIO_sec | X | X | read IO per sec (* see notes) |
| - wIO_sec | X | X | write IO per sec (* see notes) |
| - tIO_sec | X | X | total IO per sec (* see notes) |
| - ms | X | | interval length (for per second values) |
| si.networkInterfaces(cb) | X | X | array of network interfaces | | si.networkInterfaces(cb) | X | X | array of network interfaces |
| - [0].iface | X | X | interface name | | - [0].iface | X | X | interface name |
| - [0].ip4 | X | X | ip4 address | | - [0].ip4 | X | X | ip4 address |
| - [0].ip6 | X | X | ip6 address | | - [0].ip6 | X | X | ip6 address |
| si.networkStats('eth1',cb) | X | X | current network stats of given interface | | - [0].internal | X | X | true if internal interface |
| si.networkStats(iface,cb) | X | X | current network stats of given interface<br>iface parameter is optional<br>defaults to first external network interface|
| - iface | X | X | interface | | - iface | X | X | interface |
| - operstate | X | X | up / down | | - operstate | X | X | up / down |
| - rx | X | X | received bytes overall | | - rx | X | X | received bytes overall |
| - tx | X | X | transferred bytes overall| | - tx | X | X | transferred bytes overall|
| - rx_sec | X | X | received bytes / second (* see notes) | | - rx_sec | X | X | received bytes / second (* see notes) |
| - tx_sec | X | X | transferred bytes per second (* see notes) | | - tx_sec | X | X | transferred bytes per second (* see notes) |
| - ms | X | X | interval length (for per second values) |
| si.networkConnections(cb) | X | X | current network network connections<br>returns an array of all connections|
| - [0].protocol | X | X | tcp or udp |
| - [0].localaddress | X | X | local address |
| - [0].localport | X | X | local port |
| - [0].peeraddress | X | X | peer address |
| - [0].peerport | X | X | peer port |
| - [0].state | X | X | like ESTABLISHED, TIME_WAIT, ... |
| si.currentLoad(cb) | X | X | CPU-Load in % | | si.currentLoad(cb) | X | X | CPU-Load in % |
| si.fullLoad(cb) | X | X | CPU-full load since bootup in % | | si.fullLoad(cb) | X | X | CPU-full load since bootup in % |
| si.services('mysql, apache2', cb) | X | X | pass comma separated string of services | | si.services('mysql, apache2', cb) | X | X | pass comma separated string of services |
@ -183,20 +241,27 @@ This library is splitted in several sections:
| - cpu | X | X | process % CPU | | - cpu | X | X | process % CPU |
| - mem | X | X | process % MEM | | - mem | X | X | process % MEM |
| si.users(cb) | X | X | array of users online | | si.users(cb) | X | X | array of users online |
| - [0].user | X | X | user name |
| - [0].tty | X | X | terminal |
| - [0].date | X | X | login date |
| - [0].time | X | X | login time |
| - [0].ip | X | X | ip address (remote login) |
| - [0].command | X | X | last command or shell |
| si.inetChecksite(url, cb) | X | X | response-time (ms) to fetch given URL | | si.inetChecksite(url, cb) | X | X | response-time (ms) to fetch given URL |
| - url | X | X | given url | | - url | X | X | given url |
| - ok | X | X | status code OK (2xx, 3xx) | | - ok | X | X | status code OK (2xx, 3xx) |
| - status | X | X | status code | | - status | X | X | status code |
| - ms | X | X | response time in ms | | - ms | X | X | response time in ms |
| si.inetLatency(cb) | X | X | response-time (ms) to external ressource | | si.inetLatency(host, cb) | X | X | response-time (ms) to external resource<br>host parameter is optional (default 8.8.8.8)|
| si.getStaticData(cb) | X | X | all static data at once | | si.getStaticData(cb) | X | X | all static data at once |
| si.getDynamicData(cb,srv,iface) | X | X | all dynamic data at once | | si.getDynamicData(srv,iface,cb) | X | X | all dynamic data at once |
| si.getAllData(cb,srv,iface) | X | X | all data at once | | si.getAllData(srv,iface,cb) | X | X | all data at once |
### cb: Asynchronous Function Calls (callback) ### cb: Asynchronous Function Calls (callback)
Remember: all functions (except `version` and `time`) are implemented as asynchronous (callback) functions! Remember: all functions (except `version` and `time`) are implemented as asynchronous functions! There are now two ways to consume them:
So another example, how to use a specific function might be:
**Callback Style**
``` ```
var si = require('systeminformation'); var si = require('systeminformation');
@ -211,10 +276,28 @@ si.networkStats('eth1', function(data) {
}) })
``` ```
**Promises Style** (new in version 3.0)
When omitting callback parameter (cb), then you can use all function in a promise oriented way:
```
si.networkStats('eth1')
.then(data => {
console.log('Network Interface Stats (eth1):');
console.log('- is up: ' + data.operstate);
console.log('- RX bytes overall: ' + data.rx);
console.log('- TX bytes overall: ' + data.tx);
console.log('- RX bytes/sec: ' + data.rx_sec);
console.log('- TX bytes/sec: ' + data.tx_sec);
})
.catch(error => console.error(error));
```
### *: Additional Notes ### *: Additional Notes
In `fsStats` and `networkStats` the results per second values (rx_sec, ...) are calculated beginning In `fsStats`, `disksIO` and `networkStats` the results per second values (rx_sec, IOPS, ...) are calculated beginning
with the second call of the function. It is determined by calculating the difference of transferred bytes with the second call of the function. It is determined by calculating the difference of transferred bytes / IOs
divided by the time between two calls of the function. divided by the time between two calls of the function.
## Known Issues ## Known Issues
@ -229,6 +312,7 @@ I am happy to discuss any comments and suggestions. Please feel free to contact
| Version | Date | Comment | | Version | Date | Comment |
| -------------- | -------------- | -------- | | -------------- | -------------- | -------- |
| 3.0.0 | 2016-08-02 | new major version 3.0 |
| 2.0.5 | 2016-03-02 | changed .gitignore | | 2.0.5 | 2016-03-02 | changed .gitignore |
| 2.0.4 | 2016-02-22 | tiny correction - removed double quotes CPU brand, ... | | 2.0.4 | 2016-02-22 | tiny correction - removed double quotes CPU brand, ... |
| 2.0.3 | 2016-02-22 | optimized cpuCurrentspeed | | 2.0.3 | 2016-02-22 | optimized cpuCurrentspeed |
@ -266,6 +350,7 @@ Written by Sebastian Hildebrandt [sebhildebrandt](https://github.com/sebhildebra
- Guillaume Legrain [glegrain](https://github.com/glegrain) - Guillaume Legrain [glegrain](https://github.com/glegrain)
- Riccardo Novaglia [richy24](https://github.com/richy24) - Riccardo Novaglia [richy24](https://github.com/richy24)
- Quentin Busuttil [Buzut](https://github.com/Buzut)
## Copyright Information ## Copyright Information
@ -312,3 +397,9 @@ All other trademarks are the property of their respective owners.
[npmjs-license]: https://img.shields.io/npm/l/systeminformation.svg?style=flat-square [npmjs-license]: https://img.shields.io/npm/l/systeminformation.svg?style=flat-square
[nodejs-url]: https://nodejs.org/en/ [nodejs-url]: https://nodejs.org/en/
[daviddm-img]: https://img.shields.io/david/sebhildebrandt/systeminformation.svg?style=flat-square
[daviddm-url]: https://david-dm.org/sebhildebrandt/systeminformation
[issues-img]: https://img.shields.io/github/issues/sebhildebrandt/systeminformation.svg?style=flat-square
[issues-url]: https://github.com/sebhildebrandt/systeminformation/issues

File diff suppressed because it is too large Load Diff

View File

@ -34,6 +34,6 @@
"linux" "linux"
], ],
"engines": { "engines": {
"node": ">=0.10" "node": ">=4.0.0"
} }
} }