extended FreeBSD support networkConnections()

This commit is contained in:
Sebastian Hildebrandt 2018-02-11 22:08:37 +01:00
parent 999680dab8
commit 78624c670f
4 changed files with 17 additions and 17 deletions

View File

@ -100,6 +100,7 @@ Other changes
| Version | Date | Comment |
| -------------- | -------------- | -------- |
| 3.36.0 | 2018-02-11 | extended FreeBSD support `networkConnections()` |
| 3.35.0 | 2018-02-11 | extended FreeBSD support `processLoad()` |
| 3.34.1 | 2018-02-11 | updated docs |
| 3.34.0 | 2018-02-10 | first partial FreeBSD support |

View File

@ -53,13 +53,13 @@ async function cpu() {
### Latest Activity
(last 7 major and minor version releases)
- Version 3.36.0: extended FreeBSD support `networkConnections()`
- Version 3.35.0: extended FreeBSD support `processLoad()`
- Version 3.34.0: first partial FreeBSD support
- Version 3.33.0: added bios `bios()` and main board `baseboard()` information
- Version 3.32.0: extended `memLayout()` - added manufacturer
- Version 3.31.0: extended windows support `cpuFlags()` (partially)
- Version 3.30.0: extended `versions()` (added `yarn`, `gulp`, `grunt`, `tsc`, `git`)
- Version 3.29.0: extended windows support `services()`
- Version 3.28.0: extended windows support `processes()`
- ...
You can find all changes here: [detailed changelog][changelog-url]
@ -297,13 +297,13 @@ I also created a nice little command line tool called [mmon][mmon-github-url] (
| | rx_sec | X | | X | X | received bytes / second (* see notes) |
| | tx_sec | X | | X | X | transferred bytes per second (* see notes) |
| | ms | X | | X | X | interval length (for per second values) |
| si.networkConnections(cb) | [{...}] | X | | X | X | current network network connections<br>returns an array of all connections|
| | [0].protocol | X | | X | X | tcp or udp |
| | [0].localaddress | X | | X | X | local address |
| | [0].localport | X | | X | X | local port |
| | [0].peeraddress | X | | X | X | peer address |
| | [0].peerport | X | | X | X | peer port |
| | [0].state | X | | X | X | like ESTABLISHED, TIME_WAIT, ... |
| 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 |
| | [0].localport | X | X | X | X | local port |
| | [0].peeraddress | X | X | X | X | peer address |
| | [0].peerport | X | X | X | X | peer port |
| | [0].state | X | X | X | X | like ESTABLISHED, TIME_WAIT, ... |
| si.inetChecksite(url, cb) | {...} | X | X | X | X | response-time (ms) to fetch given URL |
| | url | X | X | X | X | given url |
| | ok | X | X | X | X | status code OK (2xx, 3xx) |

View File

@ -187,7 +187,7 @@ function getDynamicData(srv, iface, callback) {
let functionProcessed = (function () {
let totalFunctions = 14;
if (_windows) totalFunctions = 10;
if (_freebsd || _openbsd) totalFunctions = 10;
if (_freebsd || _openbsd) totalFunctions = 11;
return function () {
if (--totalFunctions === 0) {
@ -255,12 +255,10 @@ function getDynamicData(srv, iface, callback) {
});
}
if (!_openbsd && !_freebsd) {
network.networkConnections().then(res => {
data.networkConnections = res;
functionProcessed();
});
}
network.networkConnections().then(res => {
data.networkConnections = res;
functionProcessed();
});
memory.mem().then(res => {
data.mem = res;

View File

@ -403,8 +403,9 @@ function networkConnections(callback) {
return new Promise((resolve) => {
process.nextTick(() => {
let result = [];
if (_linux) {
if (_linux || _freebsd || _openbsd) {
let cmd = 'netstat -tuna | grep "ESTABLISHED\\|SYN_SENT\\|SYN_RECV\\|FIN_WAIT1\\|FIN_WAIT2\\|TIME_WAIT\\|CLOSE\\|CLOSE_WAIT\\|LAST_ACK\\|LISTEN\\|CLOSING\\|UNKNOWN\\|VERBUNDEN"';
if (_freebsd || _openbsd) cmd = 'netstat -na | grep "ESTABLISHED\\|SYN_SENT\\|SYN_RECV\\|FIN_WAIT1\\|FIN_WAIT2\\|TIME_WAIT\\|CLOSE\\|CLOSE_WAIT\\|LAST_ACK\\|LISTEN\\|CLOSING\\|UNKNOWN\\|VERBUNDEN"'
exec(cmd, function (error, stdout) {
if (!error) {
let lines = stdout.toString().split('\n');