Add guest disk usage via virsh guestinfo --filesystem
Query each running VM's filesystem stats through the guest agent. Show root filesystem used/total GB with color-coded bar in VM table. Cached at 30s TTL since disk usage changes slowly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -160,6 +160,7 @@
|
||||
.vm-mem-fill { height: 100%; border-radius: 4px; transition: width 0.3s; }
|
||||
.vm-table td.vm-cpu { font-weight: bold; }
|
||||
.vm-table td.vm-mem { white-space: nowrap; }
|
||||
.vm-table td.vm-disk { white-space: nowrap; }
|
||||
|
||||
@media (max-width: 700px) {
|
||||
body { padding: 12px; }
|
||||
@@ -353,7 +354,7 @@ function renderDetail(srv) {
|
||||
return a.name.localeCompare(b.name);
|
||||
});
|
||||
html += '<table class="vm-table"><thead><tr>' +
|
||||
'<th>Name</th><th>State</th><th>CPU</th><th>Memory</th><th>vCPUs</th><th>Autostart</th>' +
|
||||
'<th>Name</th><th>State</th><th>CPU</th><th>Memory</th><th>Disk</th><th>vCPUs</th><th>Autostart</th>' +
|
||||
'</tr></thead><tbody>';
|
||||
for (const vm of sorted) {
|
||||
const isRunning = vm.state === 'running';
|
||||
@@ -361,6 +362,14 @@ function renderDetail(srv) {
|
||||
const memUsed = vm.memory_used_mb || 0;
|
||||
const memTotal = vm.memory_total_mb || vm.memory_mb || 0;
|
||||
const memPct = memTotal > 0 ? (memUsed / memTotal * 100) : 0;
|
||||
const vmDisks = vm.disks || [];
|
||||
const rootDisk = vmDisks.find(d => d.mountpoint === '/') || vmDisks[0];
|
||||
let diskHtml = '—';
|
||||
if (isRunning && rootDisk) {
|
||||
const diskPct = rootDisk.total_gb > 0 ? (rootDisk.used_gb / rootDisk.total_gb * 100) : 0;
|
||||
diskHtml = rootDisk.used_gb + ' / ' + rootDisk.total_gb + ' GB' +
|
||||
'<div class="vm-mem-bar"><div class="vm-mem-fill" style="width:' + diskPct + '%;background:' + usageColor(diskPct) + '"></div></div>';
|
||||
}
|
||||
html += '<tr>' +
|
||||
'<td>' + vm.name + '</td>' +
|
||||
'<td><span class="vm-state ' + vmStateClass(vm.state) + '">' + vm.state + '</span></td>' +
|
||||
@@ -370,6 +379,7 @@ function renderDetail(srv) {
|
||||
'<div class="vm-mem-bar"><div class="vm-mem-fill" style="width:' + memPct + '%;background:' + usageColor(memPct) + '"></div></div>'
|
||||
: (isRunning ? formatMB(vm.memory_mb) : '—')) +
|
||||
'</td>' +
|
||||
'<td class="vm-disk">' + diskHtml + '</td>' +
|
||||
'<td>' + vm.vcpus + '</td>' +
|
||||
'<td>' + (vm.autostart ? 'yes' : 'no') + '</td>' +
|
||||
'</tr>';
|
||||
|
||||
Reference in New Issue
Block a user