mem() prevent log messages, memgetDefaultNetworkInterface() catch errors
This commit is contained in:
parent
777b51fd40
commit
51bb375ca3
@ -30,6 +30,7 @@ For major (breaking) changes - version 3 and 2 see end of page.
|
|||||||
|
|
||||||
| Version | Date | Comment |
|
| Version | Date | Comment |
|
||||||
| -------------- | -------------- | -------- |
|
| -------------- | -------------- | -------- |
|
||||||
|
| 4.19.4 | 2020-01-24 | `mem()` prevent log messages, `memgetDefaultNetworkInterface()` catch errors |
|
||||||
| 4.19.3 | 2020-01-24 | `memLayout()` bank info fix macOS |
|
| 4.19.3 | 2020-01-24 | `memLayout()` bank info fix macOS |
|
||||||
| 4.19.2 | 2020-01-19 | `cpu()` muli-processor fix windows |
|
| 4.19.2 | 2020-01-19 | `cpu()` muli-processor fix windows |
|
||||||
| 4.19.1 | 2020-01-14 | `osInfo()` uefi fix windows |
|
| 4.19.1 | 2020-01-14 | `osInfo()` uefi fix windows |
|
||||||
|
|||||||
@ -83,6 +83,11 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">4.19.4</th>
|
||||||
|
<td>2020-01-24</td>
|
||||||
|
<td><span class="code">mem()</span> prevent log messages</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">4.19.3</th>
|
<th scope="row">4.19.3</th>
|
||||||
<td>2020-01-24</td>
|
<td>2020-01-24</td>
|
||||||
|
|||||||
@ -168,7 +168,7 @@
|
|||||||
<img class="logo" src="assets/logo.png">
|
<img class="logo" src="assets/logo.png">
|
||||||
<div class="title">systeminformation</div>
|
<div class="title">systeminformation</div>
|
||||||
<div class="subtitle"><span id="typed"></span></div>
|
<div class="subtitle"><span id="typed"></span></div>
|
||||||
<div class="version">Current Version: <span id="version">4.19.3</span></div>
|
<div class="version">Current Version: <span id="version">4.19.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>
|
<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>
|
||||||
<div class="down">
|
<div class="down">
|
||||||
|
|||||||
@ -142,7 +142,7 @@ function mem(callback) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (_linux) {
|
if (_linux) {
|
||||||
exec('export LC_ALL=C; cat /proc/meminfo ; unset LC_ALL', function (error, stdout) {
|
exec('export LC_ALL=C; cat /proc/meminfo 2>/dev/null ; unset LC_ALL', function (error, stdout) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
const lines = stdout.toString().split('\n');
|
const lines = stdout.toString().split('\n');
|
||||||
result.total = parseInt(util.getValue(lines, 'memtotal'), 10);
|
result.total = parseInt(util.getValue(lines, 'memtotal'), 10);
|
||||||
@ -174,7 +174,7 @@ function mem(callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (_freebsd || _openbsd || _netbsd) {
|
if (_freebsd || _openbsd || _netbsd) {
|
||||||
exec('/sbin/sysctl -a | grep -E "hw.realmem|hw.physmem|vm.stats.vm.v_page_count|vm.stats.vm.v_wire_count|vm.stats.vm.v_active_count|vm.stats.vm.v_inactive_count|vm.stats.vm.v_cache_count|vm.stats.vm.v_free_count|vm.stats.vm.v_page_size"', function (error, stdout) {
|
exec('/sbin/sysctl -a 2>/dev/null | grep -E "hw.realmem|hw.physmem|vm.stats.vm.v_page_count|vm.stats.vm.v_wire_count|vm.stats.vm.v_active_count|vm.stats.vm.v_inactive_count|vm.stats.vm.v_cache_count|vm.stats.vm.v_free_count|vm.stats.vm.v_page_size"', function (error, stdout) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
let lines = stdout.toString().split('\n');
|
let lines = stdout.toString().split('\n');
|
||||||
const pagesize = parseInt(util.getValue(lines, 'vm.stats.vm.v_page_size'), 10);
|
const pagesize = parseInt(util.getValue(lines, 'vm.stats.vm.v_page_size'), 10);
|
||||||
@ -202,7 +202,7 @@ function mem(callback) {
|
|||||||
resolve(result);
|
resolve(result);
|
||||||
}
|
}
|
||||||
if (_darwin) {
|
if (_darwin) {
|
||||||
exec('vm_stat | grep "Pages active"', function (error, stdout) {
|
exec('vm_stat 2>/dev/null | grep "Pages active"', function (error, stdout) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
let lines = stdout.toString().split('\n');
|
let lines = stdout.toString().split('\n');
|
||||||
|
|
||||||
@ -210,7 +210,7 @@ function mem(callback) {
|
|||||||
result.buffcache = result.used - result.active;
|
result.buffcache = result.used - result.active;
|
||||||
result.available = result.free + result.buffcache;
|
result.available = result.free + result.buffcache;
|
||||||
}
|
}
|
||||||
exec('sysctl -n vm.swapusage', function (error, stdout) {
|
exec('sysctl -n vm.swapusage 2>/dev/null', function (error, stdout) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
let lines = stdout.toString().split('\n');
|
let lines = stdout.toString().split('\n');
|
||||||
if (lines.length > 0) {
|
if (lines.length > 0) {
|
||||||
|
|||||||
@ -61,45 +61,48 @@ function getDefaultNetworkInterface() {
|
|||||||
}
|
}
|
||||||
ifacename = ifacename || ifacenameFirst || '';
|
ifacename = ifacename || ifacenameFirst || '';
|
||||||
|
|
||||||
if (_windows) {
|
try {
|
||||||
// https://www.inetdaemon.com/tutorials/internet/ip/routing/default_route.shtml
|
if (_windows) {
|
||||||
const cmd = 'netstat -r';
|
// https://www.inetdaemon.com/tutorials/internet/ip/routing/default_route.shtml
|
||||||
const result = execSync(cmd);
|
const cmd = 'netstat -r';
|
||||||
const lines = result.toString().split(os.EOL);
|
const result = execSync(cmd);
|
||||||
let defaultIp = '';
|
const lines = result.toString().split(os.EOL);
|
||||||
lines.forEach(line => {
|
let defaultIp = '';
|
||||||
line = line.replace(/\s+/g, ' ').trim();
|
lines.forEach(line => {
|
||||||
if (line.indexOf('0.0.0.0 0.0.0.0') > -1 && !(/[a-zA-Z]/.test(line))) {
|
line = line.replace(/\s+/g, ' ').trim();
|
||||||
const parts = line.split(' ');
|
if (line.indexOf('0.0.0.0 0.0.0.0') > -1 && !(/[a-zA-Z]/.test(line))) {
|
||||||
if (parts.length >= 5) {
|
const parts = line.split(' ');
|
||||||
defaultIp = parts[parts.length - 2];
|
if (parts.length >= 5) {
|
||||||
|
defaultIp = parts[parts.length - 2];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
if (defaultIp) {
|
||||||
if (defaultIp) {
|
for (let dev in ifaces) {
|
||||||
for (let dev in ifaces) {
|
if ({}.hasOwnProperty.call(ifaces, dev)) {
|
||||||
if ({}.hasOwnProperty.call(ifaces, dev)) {
|
ifaces[dev].forEach(function (details) {
|
||||||
ifaces[dev].forEach(function (details) {
|
if (details && details.address && details.address === defaultIp) {
|
||||||
if (details && details.address && details.address === defaultIp) {
|
ifacename = dev;
|
||||||
ifacename = dev;
|
}
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if (_linux || _darwin || _freebsd || _openbsd || _netbsd || _sunos) {
|
||||||
if (_linux || _darwin || _freebsd || _openbsd || _netbsd || _sunos) {
|
let cmd = '';
|
||||||
let cmd = '';
|
if (_linux) cmd = 'ip route 2> /dev/null | grep default | awk \'{print $5}\'';
|
||||||
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 get 0.0.0.0 2>/dev/null | grep interface: | awk \'{print $2}\'';
|
if (_freebsd || _openbsd || _netbsd || _sunos) cmd = 'route get 0.0.0.0 | grep interface:';
|
||||||
if (_freebsd || _openbsd || _netbsd || _sunos) cmd = 'route get 0.0.0.0 | grep interface:';
|
let result = execSync(cmd);
|
||||||
let result = execSync(cmd);
|
ifacename = result.toString().split('\n')[0];
|
||||||
ifacename = result.toString().split('\n')[0];
|
if (ifacename.indexOf(':') > -1) {
|
||||||
if (ifacename.indexOf(':') > -1) {
|
ifacename = ifacename.split(':')[1].trim();
|
||||||
ifacename = ifacename.split(':')[1].trim();
|
}
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
util.noop();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ifacename) _default_iface = ifacename;
|
if (ifacename) _default_iface = ifacename;
|
||||||
return _default_iface;
|
return _default_iface;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user