add macos storage volumes using df

Signed-off-by: si458 <simonsmith5521@gmail.com>
This commit is contained in:
si458 2024-05-14 00:13:46 +01:00
parent e3f68226d2
commit be3e333b40
4 changed files with 1854 additions and 1787 deletions

View File

@ -712,6 +712,14 @@ function macos_identifiers()
ret.identifiers.storage_devices = devices;
}
// Fetch storage volumes using df
child = require('child_process').execFile('/bin/sh', ['sh']);
child.stdout.str = ''; child.stdout.on('data', dataHandler);
child.stdin.write('df -aHY | awk \'NR>1 {printf "{\\"size\\":\\"%s\\",\\"used\\":\\"%s\\",\\"available\\":\\"%s\\",\\"mount_point\\":\\"%s\\",\\"type\\":\\"%s\\"},", $3, $4, $5, $10, $2}\' | sed \'$ s/,$//\' | awk \'BEGIN {printf "["} {printf "%s", $0} END {printf "]"}\'\nexit\n');
child.waitExit();
try { ret.darwin.volumes = JSON.parse(child.stdout.str.trim()); } catch (xx) { }
child = null;
// MacOS Last Boot Up Time
try {
child = require('child_process').execFile('/usr/sbin/sysctl', ['', 'kern.boottime']); // must include blank value at begining for some reason?

File diff suppressed because it is too large Load Diff

View File

@ -6378,7 +6378,6 @@
x += '<div style=margin-bottom:3px><b>' + EscapeHtml((m.DeviceLocator ? m.DeviceLocator : 'Unknown')) + '</b></div>';
if (m.Size && m.Speed) { x += addDetailItem("Capacity / Speed", format("{0}, {1}", m.Size, m.Speed), s); }
else if (m.Size) { x += addDetailItem("Capacity", format("{0}", (m.Size)), s); }
console.log(m.Manufacturer);
if (m.PartNumber) { x += addDetailItem("Part Number", EscapeHtml((m.Manufacturer && m.Manufacturer != '')?(m.Manufacturer + ', '):'') + EscapeHtml(m.PartNumber), s); }
x += '</div>';
}
@ -6485,6 +6484,29 @@
if (x != '') { sections.push({ name: "Storage Volumes", html: '<table style=width:100%>' + x + '</table>', img: 'storage'}); }
}
// MacOS Volumes
if (hardware.darwin && hardware.darwin.volumes) {
var x = '';
for (var i in hardware.darwin.volumes) {
var m = hardware.darwin.volumes[i];
if(m.mount_point.startsWith('/var/lib/docker/overlay2')) continue;
x += '<tr><td><div class=style10 style=border-radius:5px;padding:8px>';
x += '<div style=margin-bottom:3px><b>' + m.mount_point + '</b></div>';
if (m.size) {
x += addDetailItem("Capacity", EscapeHtml(m.size), s);
}
if (m.available) {
x += addDetailItem("Capacity Remaining", EscapeHtml(m.available), s);
}
if (m.type) {
var type = (m.removable == true ? "Removable" : (m.cdrom == true ? "CD-ROM" : ''));
x += addDetailItem("File System", (type != '' ? (type + ' / ') : '') + (m.type == 'Unknown' ? "Unknown" : EscapeHtml(m.type)), s);
}
x += '</div>';
}
if (x != '') { sections.push({ name: "Storage Volumes", html: '<table style=width:100%>' + x + '</table>', img: 'storage'}); }
}
// Render the sections
var x = '';
for (var i in sections) {

View File

@ -12297,6 +12297,29 @@
if (x != '') { sections.push({ name: "Storage Volumes", html: '<table style=width:100%>' + x + '</table>', img: 'storage64.png'}); }
}
// MacOS Volumes
if (hardware.darwin && hardware.darwin.volumes) {
var x = '';
for (var i in hardware.darwin.volumes) {
var m = hardware.darwin.volumes[i];
if(m.mount_point.startsWith('/var/lib/docker/overlay2')) continue;
x += '<tr><td><div class=style10 style=border-radius:5px;padding:8px>';
x += '<div style=margin-bottom:3px><b>' + m.mount_point + '</b></div>';
if (m.size) {
x += addDetailItem("Capacity", EscapeHtml(m.size), s);
}
if (m.available) {
x += addDetailItem("Capacity Remaining", EscapeHtml(m.available), s);
}
if (m.type) {
var type = (m.removable == true ? "Removable" : (m.cdrom == true ? "CD-ROM" : ''));
x += addDetailItem("File System", (type != '' ? (type + ' / ') : '') + (m.type == 'Unknown' ? "Unknown" : EscapeHtml(m.type)), s);
}
x += '</div>';
}
if (x != '') { sections.push({ name: "Storage Volumes", html: '<table style=width:100%>' + x + '</table>', img: 'storage64.png'}); }
}
// Render the sections
var x = '';
for (var i in sections) {