networkInterfaces() added property virtual

This commit is contained in:
Sebastian Hildebrandt 2019-06-21 18:42:29 +02:00
parent 5acb0bb2ff
commit 0faa694b31
10 changed files with 41 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.12.0 | 2019-06-19 | `networkInterface()` added property virtual |
| 4.11.6 | 2019-06-19 | `util` bug fix |
| 4.11.5 | 2019-06-19 | `dockerAll()` bug fix |
| 4.11.4 | 2019-06-17 | type definitions bug fix |

View File

@ -357,7 +357,7 @@ I also created a nice little command line tool called [mmon][mmon-github-url] (
| Function | Result object | Linux | BSD | Mac | Win | Sun | Comments |
| --------------- | ------------- | ----- | ------- | --- | --- | --- | -------- |
| si.diskLayout(cb) | [{...}] | X | | X | X | | physical disk layout (array) |
| | [0].type | X | | X | | | e.g. /dev/sda |
| | [0].device | X | | X | | | e.g. /dev/sda |
| | [0].type | X | | X | X | | HD, SSD, NVMe |
| | [0].name | X | | X | X | | disk name |
| | [0].vendor | X | | | X | | vendor/producer |
@ -425,6 +425,7 @@ I also created a nice little command line tool called [mmon][mmon-github-url] (
| | [0].ip6 | X | X | X | X | X | ip6 address |
| | [0].mac | X | X | X | X | X | MAC address |
| | [0].internal | X | X | X | X | X | true if internal interface |
| | [0].virtual | X | X | X | X | X | true if virtual interface |
| | [0].operstate | X | | X | X | | up / down |
| | [0].type | X | | X | X | | wireless / wired |
| | [0].duplex | X | | X | | | duplex |

View File

@ -83,6 +83,11 @@
</tr>
</thead>
<tbody>
<tr>
<th scope="row">4.12.0</th>
<td>2019-06-21</td>
<td><span class="code">networkInterface()</span> added property virtual</td>
</tr>
<tr>
<th scope="row">4.11.6</th>
<td>2019-06-19</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.11.6</span></div>
<div class="version">Current Version: <span id="version">4.12.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>
</div>
<div class="down">
@ -199,7 +199,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">163</div>
<div class="numbers">164</div>
<div class="title">Dependends</div>
</div>
</div>

View File

@ -135,6 +135,16 @@
<td>X</td>
<td>true if internal interface</td>
</tr>
<tr>
<td></td>
<td>[0].virtual</td>
<td>X</td>
<td>X</td>
<td>X</td>
<td>X</td>
<td>X</td>
<td>true if virtual interface</td>
</tr>
<tr>
<td></td>
<td>[0].operstate</td>

1
lib/index.d.ts vendored
View File

@ -306,6 +306,7 @@ export namespace Systeminformation {
ip6: string;
mac: string;
internal: boolean;
virtual: boolean;
operstate: string;
type: string;
duplex: string;

View File

@ -264,6 +264,10 @@ function getDarwinNics() {
}
}
function testVirtualNic(iface, ifaceName, mac) {
const virtualMacs = ['00:03:FF', '00:05:69', '00:0C:29', '00:0F:4B', '00:0F:4B', '00:13:07', '00:13:BE', '00:15:5d', '00:16:3E', '00:1C:42', '00:21:F6', '00:21:F6', '00:24:0B', '00:24:0B', '00:50:56', '00:A0:B1', '00:E0:C8', '08:00:27', '0A:00:27', '18:92:2C', '3C:F3:92', '54:52:00', 'FC:15:97']
return virtualMacs.indexOf(mac.toUpperCase()) > -1 || iface.toLowerCase().indexOf(' virtual ') > -1 || ifaceName.toLowerCase().indexOf(' virtual ') > -1 || ifaceName.toLowerCase().indexOf('vethernet ') > -1 || ifaceName.toLowerCase().indexOf('vethernet ') > -1;
}
function networkInterfaces(callback) {
@ -397,6 +401,7 @@ function networkInterfaces(callback) {
});
}
let internal = (ifaces[dev] && ifaces[dev][0]) ? ifaces[dev][0].internal : null;
const virtual = testVirtualNic(dev, ifaceName, mac);
result.push({
iface: dev,
ifaceName,
@ -404,6 +409,7 @@ function networkInterfaces(callback) {
ip6,
mac,
internal,
virtual,
operstate,
type,
duplex,
@ -716,7 +722,7 @@ function networkConnections(callback) {
if (_linux || _freebsd || _openbsd || _netbsd) {
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 || _netbsd) 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, { maxBuffer: 1024 * 2000 }, function (error, stdout) {
exec(cmd, { maxBuffer: 1024 * 20000 }, function (error, stdout) {
if (!error) {
let lines = stdout.toString().split('\n');
lines.forEach(function (line) {
@ -758,7 +764,7 @@ function networkConnections(callback) {
resolve(result);
} else {
cmd = 'ss -tuna | grep "ESTAB\\|SYN-SENT\\|SYN-RECV\\|FIN-WAIT1\\|FIN-WAIT2\\|TIME-WAIT\\|CLOSE\\|CLOSE-WAIT\\|LAST-ACK\\|LISTEN\\|CLOSING"';
exec(cmd, { maxBuffer: 1024 * 2000 }, function (error, stdout) {
exec(cmd, { maxBuffer: 1024 * 20000 }, function (error, stdout) {
if (!error) {
let lines = stdout.toString().split('\n');
@ -807,7 +813,7 @@ function networkConnections(callback) {
}
if (_darwin) {
let cmd = 'netstat -nat | grep "ESTABLISHED\\|SYN_SENT\\|SYN_RECV\\|FIN_WAIT1\\|FIN_WAIT2\\|TIME_WAIT\\|CLOSE\\|CLOSE_WAIT\\|LAST_ACK\\|LISTEN\\|CLOSING\\|UNKNOWN"';
exec(cmd, { maxBuffer: 1024 * 2000 }, function (error, stdout) {
exec(cmd, { maxBuffer: 1024 * 20000 }, function (error, stdout) {
if (!error) {
let lines = stdout.toString().split('\n');

View File

@ -117,7 +117,7 @@ function services(srv, callback) {
}
let comm = (_darwin) ? 'ps -caxo pcpu,pmem,pid,command' : 'ps -axo pcpu,pmem,pid,command';
if (srv !== '' && srvs.length > 0) {
exec(comm + ' | grep -v grep | grep -iE "' + srv + '"', { maxBuffer: 1024 * 2000 }, function (error, stdout) {
exec(comm + ' | grep -v grep | grep -iE "' + srv + '"', { maxBuffer: 1024 * 20000 }, function (error, stdout) {
if (!error) {
let lines = stdout.toString().replace(/ +/g, ' ').replace(/,+/g, '.').split('\n');
srvs.forEach(function (srv) {
@ -158,7 +158,7 @@ function services(srv, callback) {
cmd += (';cat /proc/' + result[i].pids[j] + '/stat');
}
}
exec(cmd, { maxBuffer: 1024 * 2000 }, function (error, stdout) {
exec(cmd, { maxBuffer: 1024 * 20000 }, function (error, stdout) {
let curr_processes = stdout.toString().split('\n');
// first line (all - /proc/stat)
@ -208,7 +208,7 @@ function services(srv, callback) {
resolve(result);
}
} else {
exec('ps -o comm | grep -v grep | egrep "' + srv + '"', { maxBuffer: 1024 * 2000 }, function (error, stdout) {
exec('ps -o comm | grep -v grep | egrep "' + srv + '"', { maxBuffer: 1024 * 20000 }, function (error, stdout) {
if (!error) {
let lines = stdout.toString().replace(/ +/g, ' ').replace(/,+/g, '.').split('\n');
srvs.forEach(function (srv) {
@ -566,7 +566,7 @@ function processes(callback) {
if (_freebsd || _openbsd || _netbsd) cmd = 'export LC_ALL=C; ps -axo pid,ppid,pcpu,pmem,pri,vsz,rss,ni,lstart,state,tty,user,command; unset LC_ALL';
if (_darwin) cmd = 'export LC_ALL=C; ps -acxo pid,ppid,pcpu,pmem,pri,vsz,rss,nice,lstart,state,tty,user,command -r; unset LC_ALL';
if (_sunos) cmd = 'ps -Ao pid,ppid,pcpu,pmem,pri,vsz,rss,nice,stime,s,tty,user,comm';
exec(cmd, { maxBuffer: 1024 * 2000 }, function (error, stdout) {
exec(cmd, { maxBuffer: 1024 * 20000 }, function (error, stdout) {
if (!error) {
result.list = parseProcesses(stdout.toString().split('\n'));
result.all = result.list.length;
@ -586,7 +586,7 @@ function processes(callback) {
for (let i = 0; i < result.list.length; i++) {
cmd += (';cat /proc/' + result.list[i].pid + '/stat');
}
exec(cmd, { maxBuffer: 1024 * 2000 }, function (error, stdout) {
exec(cmd, { maxBuffer: 1024 * 20000 }, function (error, stdout) {
let curr_processes = stdout.toString().split('\n');
// first line (all - /proc/stat)
@ -637,7 +637,7 @@ function processes(callback) {
if (_sunos) {
cmd = 'ps -o pid,ppid,vsz,rss,nice,etime,s,tty,user,comm';
}
exec(cmd, { maxBuffer: 1024 * 2000 }, function (error, stdout) {
exec(cmd, { maxBuffer: 1024 * 20000 }, function (error, stdout) {
if (!error) {
let lines = stdout.toString().split('\n');
lines.shift();
@ -868,7 +868,7 @@ function processLoad(proc, callback) {
}
if (_darwin || _linux) {
exec('ps -axo pid,pcpu,pmem,comm | grep -i ' + proc + ' | grep -v grep', { maxBuffer: 1024 * 2000 }, function (error, stdout) {
exec('ps -axo pid,pcpu,pmem,comm | grep -i ' + proc + ' | grep -v grep', { maxBuffer: 1024 * 20000 }, function (error, stdout) {
if (!error) {
let lines = stdout.toString().split('\n');
@ -901,7 +901,7 @@ function processLoad(proc, callback) {
cmd += (';cat /proc/' + result.pids[i] + '/stat');
}
exec(cmd, { maxBuffer: 1024 * 2000 }, function (error, stdout) {
exec(cmd, { maxBuffer: 1024 * 20000 }, function (error, stdout) {
let curr_processes = stdout.toString().split('\n');
// first line (all - /proc/stat)

View File

@ -35,7 +35,7 @@ let codepage = '';
const execOptsWin = {
windowsHide: true,
maxBuffer: 1024 * 2000,
maxBuffer: 1024 * 20000,
encoding: 'UTF-8',
env: util._extend({}, process.env, { LANG: 'en_US.UTF-8' })
};

View File

@ -118,7 +118,7 @@ function wifiNetworks(callback) {
let result = [];
if (_linux) {
let cmd = 'nmcli --terse --fields active,ssid,bssid,mode,chan,freq,signal,security,wpa-flags,rsn-flags device wifi list';
exec(cmd, { maxBuffer: 1024 * 2000 }, function (error, stdout) {
exec(cmd, { maxBuffer: 1024 * 20000 }, function (error, stdout) {
const parts = stdout.toString().split('ACTIVE:');
parts.shift();
@ -151,7 +151,7 @@ function wifiNetworks(callback) {
});
} else if (_darwin) {
let cmd = '/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -s';
exec(cmd, { maxBuffer: 1024 * 2000 }, function (error, stdout) {
exec(cmd, { maxBuffer: 1024 * 20000 }, function (error, stdout) {
const lines = stdout.toString().split(os.EOL);
if (lines && lines.length > 1) {
const parsedhead = util.parseHead(lines[0], 1);