fsStats(), blockDevices() improvements, updated docs v4
This commit is contained in:
+4
-4
@@ -509,13 +509,13 @@ 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 2>/dev/null | grep /', function (error, stdout) {
|
||||
exec('lsblk -r 2>/dev/null | grep /', function (error, stdout) {
|
||||
if (!error) {
|
||||
let lines = stdout.toString().split('\n');
|
||||
let fs_filter = [];
|
||||
lines.forEach(function (line) {
|
||||
if (line !== '') {
|
||||
line = line.replace(/[├─│└]+/g, '').trim().split(' ');
|
||||
line = line.trim().split(' ');
|
||||
if (fs_filter.indexOf(line[0]) === -1) { fs_filter.push(line[0]); }
|
||||
}
|
||||
});
|
||||
@@ -799,14 +799,14 @@ function diskLayout(callback) {
|
||||
try {
|
||||
const outJSON = JSON.parse(out);
|
||||
if (outJSON && {}.hasOwnProperty.call(outJSON, 'blockdevices')) {
|
||||
devices = outJSON.blockdevices.filter(item => { return (item.group === 'disk' || item.type === 'disk') && item.size > 0 && (item.model !== null || (item.mountpoint === null && item.label === null && item.fsType === null && item.parttype === null)); });
|
||||
devices = outJSON.blockdevices.filter(item => { return (item.type === 'disk') && item.size > 0 && (item.model !== null || (item.mountpoint === null && item.label === null && item.fsType === null && item.parttype === null)); });
|
||||
}
|
||||
} 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 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.type === 'disk') && item.size > 0 && ((item.model !== null && item.model !== '') || (item.mountpoint === '' && item.label === '' && item.fsType === '')); });
|
||||
devices = data.filter(item => { return (item.type === 'disk') && item.size > 0 && ((item.model !== null && item.model !== '') || (item.mountpoint === '' && item.label === '' && item.fsType === '')); });
|
||||
}
|
||||
devices.forEach((device) => {
|
||||
let mediumType = '';
|
||||
|
||||
Reference in New Issue
Block a user