networkInterfaceDefault() optimization (macOS)

This commit is contained in:
Sebastian Hildebrandt 2020-09-16 22:31:43 +02:00
parent 57cd89ac74
commit e03431d6ae
6 changed files with 23 additions and 17 deletions

View File

@ -30,6 +30,7 @@ For major (breaking) changes - version 3 and 2 see end of page.
| Version | Date | Comment |
| -------------- | -------------- | -------- |
| 4.27.4 | 2020-09-16 | `networkInterfaceDefault()` optimization (macOS) |
| 4.27.3 | 2020-08-26 | updated typescript typings |
| 4.27.2 | 2020-08-26 | fixed issue breaking node v4 compatibility |
| 4.27.1 | 2020-08-25 | `networkStats()` fixed packages dropped (linux) |

View File

@ -38,10 +38,10 @@ This next major version release 4.0 comes with several optimizations and changes
- new systeminformation website with better documentation and examples [systeminformation.io][systeminformation-url]
- added typescript definitions
- reworked network section: this will now return more information and allows to get networkStats for more than one interface at once.
- reworked network section: this will now return more information and allows getting networkStats for more than one interface at once.
- dockerContainerStats for multiple containers or all containers at once
- optimized graphics controller and display detection
- added wifiNetworks to get available wifi networks
- added wifiNetworks to get available Wi-Fi networks
- added vboxInfo to get detailed vm information
- added chassis information
- better Raspberry-PI detection
@ -58,7 +58,7 @@ Lightweight collection of 40+ functions to retrieve detailed hardware, system an
- supports Linux, macOS, partial Windows, FreeBSD, OpenBSD, NetBSD and SunOS support
- no npm dependencies (for production)
**Attention**: this is a `node.js` library. It is supposed to be used as a backend/server-side library and will definilely not work within a browser.
**Attention**: this is a `node.js` library. It is supposed to be used as a backend/server-side library and will definitely not work within a browser.
### Installation
@ -79,7 +79,7 @@ si.cpu()
.catch(error => console.error(error));
```
**Callback, Promises, Awync / Await**
**Callback, Promises, Async / Await**
## News and Changes
@ -88,7 +88,7 @@ si.cpu()
(last 7 major and minor version releases)
- Version 4.27.0: `observe()` added observe / watch function
- Version 4.26.0: `diskLayout()` added full S.M.A.R.T data (linux)
- Version 4.26.0: `diskLayout()` added full S.M.A.R.T data (Linux)
- Version 4.25.0: `get()` added function to get partial system info
- Version 4.24.0: `networkInterfaces()` added subnet mask ip4 and ip6
- Version 4.23.0: `versions()` added param to specify which program/lib versions to detect
@ -100,7 +100,7 @@ You can find all changes here: [detailed changelog][changelog-url]
## 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 little library. This library is still work in progress. It is supposed to be used as a backend/server-side library (will definilely not work within a browser). It requires node.js version 4.0 and above.
[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. It is supposed to be used as a backend/server-side library (will definitely not work within a browser). It requires node.js version 4.0 and above.
I was able to test it on several Debian, Raspbian, Ubuntu distributions as well as macOS (Mavericks, Yosemite, El Captain, Sierra, High Sierra, Mojave) and some Windows 7, Windows 10, FreeBSD, OpenBSD, NetBSD and SunOS machines. Not all functions are supported on all operating systems. Have a look at the function reference in the docs to get further details.
@ -667,7 +667,7 @@ si.cpu(function(data) {
**Promises Style** is new in version 3.0.
When omitting callback parameter (cb), then you can use all function in a promise oriented way. All functions (exept of `version` and `time`) are returning a promise, that you can consume:
When omitting callback parameter (cb), then you can use all function in a promise oriented way. All functions (except of `version` and `time`) are returning a promise, that you can consume:
```js
const si = require('systeminformation');
@ -736,12 +736,12 @@ In some cases we also discovered that `wmic` returned incorrect temperature valu
#### Linux Temperature
In some cases you need to install the linux `sensors` package to be able to measure temperature
In some cases you need to install the Linux `sensors` package to be able to measure temperature
e.g. on DEBIAN based systems by running `sudo apt-get install lm-sensors`
#### Linux S.M.A.R.T. Status
To be able to detect S.M.A.R.T. status on Linux you need to install `smartmontools`. On DEBIAN based linux distributions you can install it by running `sudo apt-get install smartmontools`
To be able to detect S.M.A.R.T. status on Linux you need to install `smartmontools`. On DEBIAN based Linux distributions you can install it by running `sudo apt-get install smartmontools`
## *: Additional Notes
@ -749,9 +749,9 @@ In `fsStats()`, `disksIO()` and `networkStats()` the results / sec. values (rx_s
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.
The first time you are calling one of this functions, you will get `-1` for transfer rates. The second time, you should then get statistics based on the time between the two calls ...
The first time you are calling one of these functions, you will get `-1` for transfer rates. The second time, you should then get statistics based on the time between the two calls ...
So basically, if you e.g. need a values for network stats every second, your code should look like this:
So basically, if you e.g. need a value for network stats every second, your code should look like this:
```js
const si = require('systeminformation');

View File

@ -3,10 +3,10 @@
First of all: thank you for contributing to this repository. We are always looking for quality contributions and will be happy to accept your pull requests as long as they adhere to some basic rules:
* Please make sure that your contribution fits well in the project's context:
* We are aiming to provide a high quality multi platform system information library.
* We are aiming to provide a high quality multi-platform system information library.
* This package should stay without any dependencies on any external JavaScript library.
* Please assure that you are submitting quality code, specifically make sure that:
* Your commits should not be braking changes - if possible.
* Your PR are well testet - if possible on multiple platforms / machines (please provide information against what systems it was tested).
* Your commits should not be breaking changes - if possible.
* Your PR are well tested - if possible on multiple platforms / machines (please provide information against what systems it was tested).
* If your commit needs a major version bump (breaking change), please leave a clear message in your comments. We try to keep the breaking changes as low as possible to avoid compatibility issues.

View File

@ -83,6 +83,11 @@
</tr>
</thead>
<tbody>
<tr>
<th scope="row">4.27.4</th>
<td>2020-09-16</td>
<td><span class="code">networkInterfaceDefault()</span> optimization (macOS)</td>
</tr>
<tr>
<th scope="row">4.27.3</th>
<td>2020-08-26</td>

View File

@ -168,7 +168,7 @@
<img class="logo" src="assets/logo.png">
<div class="title">systeminformation</div>
<div class="subtitle"><span id="typed"></span></div>
<div class="version">Current Version: <span id="version">4.27.3</span></div>
<div class="version">Current Version: <span id="version">4.27.4</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>
</div>
<div class="down">
@ -207,7 +207,7 @@
<div class="title">Downloads last month</div>
</div>
<div class="col-xl-4 col-lg-4 col-md-4 col-12">
<div class="numbers">335</div>
<div class="numbers">349</div>
<div class="title">Dependends</div>
</div>
</div>

View File

@ -106,7 +106,7 @@ function getDefaultNetworkInterface() {
if (_darwin || _freebsd || _openbsd || _netbsd || _sunos) {
let cmd = '';
if (_linux) cmd = 'ip route 2> /dev/null | grep default | awk \'{print $5}\'';
if (_darwin) cmd = 'route get 0.0.0.0 2>/dev/null | grep interface: | awk \'{print $2}\'';
if (_darwin) cmd = 'route -n get default 2>/dev/null | grep interface: | awk \'{print $2}\'';
if (_freebsd || _openbsd || _netbsd || _sunos) cmd = 'route get 0.0.0.0 | grep interface:';
let result = execSync(cmd);
ifacename = result.toString().split('\n')[0];