fsSize() alpine linux support
This commit is contained in:
parent
8a5f36816e
commit
e682abb657
@ -30,6 +30,7 @@ For major (breaking) changes - version 3 and 2 see end of page.
|
||||
|
||||
| Version | Date | Comment |
|
||||
| -------------- | -------------- | -------- |
|
||||
| 4.17.1 | 2020-01-04 | `fsSize()` alpine linux support |
|
||||
| 4.17.0 | 2020-01-04 | `networkInterfaces()` added dhcp, dnsSuffix, ieee8021xAuth, ieee8021xState |
|
||||
| 4.16.1 | 2020-01-02 | `networkInterfaces()` bug fix (osx) |
|
||||
| 4.16.0 | 2019-11-27 | `networkGatewayDefault()` added |
|
||||
|
||||
@ -83,6 +83,11 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th scope="row">4.17.1</th>
|
||||
<td>2020-01-04</td>
|
||||
<td><span class="code">fsSize()</span> alpine linux support</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">4.17.0</th>
|
||||
<td>2020-01-04</td>
|
||||
|
||||
@ -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.17.0</span></div>
|
||||
<div class="version">Current Version: <span id="version">4.17.1</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">
|
||||
|
||||
@ -37,6 +37,34 @@ let _disk_io = {};
|
||||
|
||||
function fsSize(callback) {
|
||||
|
||||
function parseDf(lines) {
|
||||
let data = [];
|
||||
lines.forEach(function (line) {
|
||||
if (line !== '') {
|
||||
line = line.replace(/ +/g, ' ').split(' ');
|
||||
if (line && (line[0].startsWith('/')) || (line[6] && line[6] === '/')) {
|
||||
const fs = line[0];
|
||||
const fstype = ((_linux || _freebsd || _openbsd || _netbsd) ? line[1] : 'HFS');
|
||||
const size = parseInt(((_linux || _freebsd || _openbsd || _netbsd) ? line[2] : line[1])) * 1024;
|
||||
const used = parseInt(((_linux || _freebsd || _openbsd || _netbsd) ? line[3] : line[2])) * 1024;
|
||||
const use = parseFloat((100.0 * ((_linux || _freebsd || _openbsd || _netbsd) ? line[3] : line[2]) / ((_linux || _freebsd || _openbsd || _netbsd) ? line[2] : line[1])).toFixed(2));
|
||||
const mount = line[line.length - 1];
|
||||
if (!data.find(el => (el.fs === fs && el.type === fstype))) {
|
||||
data.push({
|
||||
fs,
|
||||
type: fstype,
|
||||
size,
|
||||
used,
|
||||
use,
|
||||
mount
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return data;
|
||||
}
|
||||
|
||||
return new Promise((resolve) => {
|
||||
process.nextTick(() => {
|
||||
let data = [];
|
||||
@ -48,22 +76,16 @@ function fsSize(callback) {
|
||||
exec(cmd, function (error, stdout) {
|
||||
if (!error) {
|
||||
let lines = stdout.toString().split('\n');
|
||||
//lines.splice(0, 1);
|
||||
lines.forEach(function (line) {
|
||||
if (line !== '') {
|
||||
line = line.replace(/ +/g, ' ').split(' ');
|
||||
if (line && (line[0].startsWith('/')) || (line[6] && line[6] === '/')) {
|
||||
data.push({
|
||||
'fs': line[0],
|
||||
'type': ((_linux || _freebsd || _openbsd || _netbsd) ? line[1] : 'HFS'),
|
||||
'size': parseInt(((_linux || _freebsd || _openbsd || _netbsd) ? line[2] : line[1])) * 1024,
|
||||
'used': parseInt(((_linux || _freebsd || _openbsd || _netbsd) ? line[3] : line[2])) * 1024,
|
||||
'use': parseFloat((100.0 * ((_linux || _freebsd || _openbsd || _netbsd) ? line[3] : line[2]) / ((_linux || _freebsd || _openbsd || _netbsd) ? line[2] : line[1])).toFixed(2)),
|
||||
'mount': line[line.length - 1]
|
||||
});
|
||||
data = parseDf(lines);
|
||||
if (callback) {
|
||||
callback(data);
|
||||
}
|
||||
}
|
||||
});
|
||||
resolve(data);
|
||||
} else {
|
||||
exec('df -kPT', function (error, stdout) {
|
||||
if (!error) {
|
||||
let lines = stdout.toString().split('\n');
|
||||
data = parseDf(lines);
|
||||
}
|
||||
if (callback) {
|
||||
callback(data);
|
||||
@ -71,6 +93,8 @@ function fsSize(callback) {
|
||||
resolve(data);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
if (_sunos) {
|
||||
if (callback) { callback(data); }
|
||||
resolve(data);
|
||||
@ -282,7 +306,7 @@ function blockDevices(callback) {
|
||||
if (_linux) {
|
||||
// see https://wiki.ubuntuusers.de/lsblk/
|
||||
// exec("lsblk -bo NAME,TYPE,SIZE,FSTYPE,MOUNTPOINT,UUID,ROTA,RO,TRAN,SERIAL,LABEL,MODEL,OWNER,GROUP,MODE,ALIGNMENT,MIN-IO,OPT-IO,PHY-SEC,LOG-SEC,SCHED,RQ-SIZE,RA,WSAME", function (error, stdout) {
|
||||
exec('lsblk -bPo NAME,TYPE,SIZE,FSTYPE,MOUNTPOINT,UUID,ROTA,RO,RM,TRAN,SERIAL,LABEL,MODEL,OWNER', function (error, stdout) {
|
||||
exec('lsblk -bPo NAME,TYPE,SIZE,FSTYPE,MOUNTPOINT,UUID,ROTA,RO,RM,TRAN,SERIAL,LABEL,MODEL,OWNER 2>/dev/null', function (error, stdout) {
|
||||
if (!error) {
|
||||
let lines = blkStdoutToObject(stdout).split('\n');
|
||||
data = parseBlk(lines);
|
||||
@ -291,7 +315,7 @@ function blockDevices(callback) {
|
||||
}
|
||||
resolve(data);
|
||||
} else {
|
||||
exec('lsblk -bPo NAME,TYPE,SIZE,FSTYPE,MOUNTPOINT,UUID,ROTA,RO,RM,LABEL,MODEL,OWNER', function (error, stdout) {
|
||||
exec('lsblk -bPo NAME,TYPE,SIZE,FSTYPE,MOUNTPOINT,UUID,ROTA,RO,RM,LABEL,MODEL,OWNER 2>/dev/null', function (error, stdout) {
|
||||
if (!error) {
|
||||
let lines = blkStdoutToObject(stdout).split('\n');
|
||||
data = parseBlk(lines);
|
||||
@ -439,7 +463,7 @@ function fsStats(callback) {
|
||||
if ((_fs_speed && !_fs_speed.ms) || (_fs_speed && _fs_speed.ms && Date.now() - _fs_speed.ms >= 500)) {
|
||||
if (_linux) {
|
||||
// exec("df -k | grep /dev/", function(error, stdout) {
|
||||
exec('lsblk | grep /', function (error, stdout) {
|
||||
exec('lsblk 2>/dev/null | grep /', function (error, stdout) {
|
||||
if (!error) {
|
||||
let lines = stdout.toString().split('\n');
|
||||
let fs_filter = [];
|
||||
@ -594,7 +618,7 @@ function disksIO(callback) {
|
||||
// prints Block layer statistics for all mounted volumes
|
||||
// var cmd = "for mount in `lsblk | grep / | sed -r 's/│ └─//' | cut -d ' ' -f 1`; do cat /sys/block/$mount/stat | sed -r 's/ +/;/g' | sed -r 's/^;//'; done";
|
||||
// var cmd = "for mount in `lsblk | grep / | sed 's/[│└─├]//g' | awk '{$1=$1};1' | cut -d ' ' -f 1 | sort -u`; do cat /sys/block/$mount/stat | sed -r 's/ +/;/g' | sed -r 's/^;//'; done";
|
||||
let cmd = 'for mount in `lsblk | grep " disk " | sed "s/[│└─├]//g" | awk \'{$1=$1};1\' | cut -d " " -f 1 | sort -u`; do cat /sys/block/$mount/stat | sed -r "s/ +/;/g" | sed -r "s/^;//"; done';
|
||||
let cmd = 'for mount in `lsblk 2>/dev/null | grep " disk " | sed "s/[│└─├]//g" | awk \'{$1=$1};1\' | cut -d " " -f 1 | sort -u`; do cat /sys/block/$mount/stat | sed -r "s/ +/;/g" | sed -r "s/^;//"; done';
|
||||
|
||||
exec(cmd, function (error, stdout) {
|
||||
if (!error) {
|
||||
@ -713,7 +737,7 @@ function diskLayout(callback) {
|
||||
let cmd = '';
|
||||
|
||||
if (_linux) {
|
||||
exec('export LC_ALL=C; lsblk -ablJO; unset LC_ALL', function (error, stdout) {
|
||||
exec('export LC_ALL=C; lsblk -ablJO 2>/dev/null; unset LC_ALL', function (error, stdout) {
|
||||
if (!error) {
|
||||
try {
|
||||
const out = stdout.toString().trim();
|
||||
@ -725,7 +749,7 @@ function diskLayout(callback) {
|
||||
}
|
||||
} catch (e) {
|
||||
// fallback to older version of lsblk
|
||||
const out2 = execSync('export LC_ALL=C; lsblk -bPo NAME,TYPE,SIZE,FSTYPE,MOUNTPOINT,UUID,ROTA,RO,RM,LABEL,MODEL,OWNER,GROUP; unset LC_ALL').toString();
|
||||
const out2 = execSync('export LC_ALL=C; lsblk -bPo NAME,TYPE,SIZE,FSTYPE,MOUNTPOINT,UUID,ROTA,RO,RM,LABEL,MODEL,OWNER,GROUP 2>/dev/null; unset LC_ALL').toString();
|
||||
let lines = blkStdoutToObject(out2).split('\n');
|
||||
const data = parseBlk(lines);
|
||||
devices = data.filter(item => { return item.group === 'disk' && item.size > 0 && item.model !== null && item.model !== ''; });
|
||||
|
||||
@ -474,7 +474,7 @@ function getDarwinNics() {
|
||||
|
||||
|
||||
function getLinuxIfaceConnectionName(interfaceName) {
|
||||
const cmd = `nmcli device status | grep ${interfaceName}`;
|
||||
const cmd = `nmcli device status 2>/dev/null | grep ${interfaceName}`;
|
||||
|
||||
try {
|
||||
const result = execSync(cmd).toString();
|
||||
@ -490,7 +490,7 @@ function getLinuxIfaceConnectionName(interfaceName) {
|
||||
function getLinuxIfaceDHCPstatus(connectionName) {
|
||||
let result = false;
|
||||
if (connectionName) {
|
||||
const cmd = `nmcli connection show "${connectionName}" \| grep ipv4.method;`;
|
||||
const cmd = `nmcli connection show "${connectionName}" 2>/dev/null \| grep ipv4.method;`;
|
||||
try {
|
||||
const result = execSync(cmd).toString();
|
||||
const resultFormat = result.replace(/\s+/g, ' ').trim();
|
||||
@ -516,7 +516,7 @@ function getLinuxIfaceDHCPstatus(connectionName) {
|
||||
|
||||
function getLinuxIfaceDNSsuffix(connectionName) {
|
||||
if (connectionName) {
|
||||
const cmd = `nmcli connection show "${connectionName}" \| grep ipv4.dns-search;`;
|
||||
const cmd = `nmcli connection show "${connectionName}" 2>/dev/null \| grep ipv4.dns-search;`;
|
||||
try {
|
||||
const result = execSync(cmd).toString();
|
||||
const resultFormat = result.replace(/\s+/g, ' ').trim();
|
||||
@ -532,7 +532,7 @@ function getLinuxIfaceDNSsuffix(connectionName) {
|
||||
|
||||
function getLinuxIfaceIEEE8021xAuth(connectionName) {
|
||||
if (connectionName) {
|
||||
const cmd = `nmcli connection show "${connectionName}" \| grep 802-1x.eap;`;
|
||||
const cmd = `nmcli connection show "${connectionName}" 2>/dev/null \| grep 802-1x.eap;`;
|
||||
try {
|
||||
const result = execSync(cmd).toString();
|
||||
const resultFormat = result.replace(/\s+/g, ' ').trim();
|
||||
|
||||
@ -155,7 +155,7 @@ function getLogoFile(distro) {
|
||||
else if (distro.indexOf('robolinux') !== -1) {
|
||||
result = 'robolinux';
|
||||
} else if (_linux && distro) {
|
||||
result = distro.toLowerCase();
|
||||
result = distro.toLowerCase().trim().replace(/\s+/g, '-');
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -117,7 +117,7 @@ function wifiNetworks(callback) {
|
||||
process.nextTick(() => {
|
||||
let result = [];
|
||||
if (_linux) {
|
||||
let cmd = 'nmcli --terse --fields active,ssid,bssid,mode,chan,freq,signal,security,wpa-flags,rsn-flags device wifi list';
|
||||
let cmd = 'nmcli --terse --fields active,ssid,bssid,mode,chan,freq,signal,security,wpa-flags,rsn-flags device wifi list 2>/dev/null';
|
||||
exec(cmd, { maxBuffer: 1024 * 20000 }, function (error, stdout) {
|
||||
|
||||
const parts = stdout.toString().split('ACTIVE:');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user