networkInterfaces(), chassis() fixed smaller issues
This commit is contained in:
parent
af0d906a91
commit
3d2e6edc3b
@ -30,6 +30,8 @@ For major (breaking) changes - version 3 and 2 see end of page.
|
||||
|
||||
| Version | Date | Comment |
|
||||
| -------------- | -------------- | -------- |
|
||||
| 4.0.2 | 2019-02-03 | `networkInterfaces(), chassis()` fixed smaller issues |
|
||||
| 4.0.1 | 2019-02-02 | updated docs |
|
||||
| 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 |
|
||||
|
||||
@ -80,7 +80,7 @@ You can find all changes here: [detailed changelog][changelog-url]
|
||||
|
||||
[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.
|
||||
|
||||
I was able to test it on several Debian, Raspbian, Ubuntu distributions as well as macOS (Mavericks, Yosemite, El Captain, Sierra, High Sierra) and some Windows 7, Windows 10, FreeBSD 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.
|
||||
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 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.
|
||||
|
||||
If you have comments, suggestions & reports, please feel free to contact me!
|
||||
|
||||
|
||||
@ -55,6 +55,21 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th scope="row">4.0.2</th>
|
||||
<td>2019-02-03</td>
|
||||
<td><span class="code">networkInterfaces(), chassis()</span> fixed smaller issues</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">4.0.1</th>
|
||||
<td>2019-02-02</td>
|
||||
<td>updated docs</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">4.0.0</th>
|
||||
<td>2019-02-02</td>
|
||||
<td>new major version 4</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">3.54.0</th>
|
||||
<td>2018-12-30</td>
|
||||
|
||||
@ -311,7 +311,7 @@ function networkInterfaces(callback) {
|
||||
}
|
||||
});
|
||||
if (_linux) {
|
||||
let iface = dev.split(':')[0];
|
||||
let iface = dev.split(':')[0].trim().toLowerCase();
|
||||
const cmd = `echo -n "addr_assign_type: "; cat /sys/class/net/${iface}/addr_assign_type 2>/dev/null; echo;
|
||||
echo -n "address: "; cat /sys/class/net/${iface}/address 2>/dev/null; echo;
|
||||
echo -n "addr_len: "; cat /sys/class/net/${iface}/addr_len 2>/dev/null; echo;
|
||||
@ -335,7 +335,7 @@ function networkInterfaces(callback) {
|
||||
echo -n "speed: "; cat /sys/class/net/${iface}/speed 2>/dev/null; echo;
|
||||
echo -n "tx_queue_len: "; cat /sys/class/net/${iface}/tx_queue_len 2>/dev/null; echo;
|
||||
echo -n "type: "; cat /sys/class/net/${iface}/type 2>/dev/null; echo;
|
||||
echo -n "wireless: "; cat /proc/net/wireless \| grep ${iface};
|
||||
echo -n "wireless: "; cat /proc/net/wireless 2>/dev/null \| grep ${iface};
|
||||
echo -n "wirelessspeed: "; iw dev ${iface} link 2>&1 \| grep bitrate; echo;`;
|
||||
let lines = [];
|
||||
try {
|
||||
@ -356,6 +356,7 @@ function networkInterfaces(callback) {
|
||||
carrierChanges = parseInt(util.getValue(lines, 'carrier_changes'), 10);
|
||||
operstate = util.getValue(lines, 'operstate');
|
||||
type = operstate === 'up' ? (util.getValue(lines, 'wireless').trim() ? 'wireless' : 'wired') : 'unknown';
|
||||
if (iface === 'lo' || iface.startsWith('bond')) { type = 'virtual'; }
|
||||
// rx_bytes = parseInt(util.getValue(lines, 'rx_bytes'), 10);
|
||||
// rx_dropped = parseInt(util.getValue(lines, 'rx_dropped'), 10);
|
||||
// rx_errors = parseInt(util.getValue(lines, 'rx_errors'), 10);
|
||||
|
||||
@ -532,7 +532,7 @@ function chassis(callback) {
|
||||
result.manufacturer = util.getValue(lines, 'manufacturer', '=');
|
||||
result.model = util.getValue(lines, 'model', '=');
|
||||
const ctype = parseInt(util.getValue(lines, 'ChassisTypes', '=').replace(/\D/g, ''));
|
||||
result.type = (ctype && !isNaN(ctype) && ctype < chassisTypes.length) ? chassisTypes[ctype] : '';
|
||||
result.type = (ctype && !isNaN(ctype) && ctype < chassisTypes.length) ? chassisTypes[ctype - 1] : '';
|
||||
result.version = util.getValue(lines, 'version', '=');
|
||||
result.serial = util.getValue(lines, 'serialnumber', '=');
|
||||
result.assetTag = util.getValue(lines, 'partnumber', '=');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user