mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-09-21 18:53:37 +00:00
fix: show dash instead of 0% for VMs without guest agent disk data
addresses #367 - when VMs don't have working guest agent data, display a dash instead of misleading 0% disk usage
This commit is contained in:
@@ -69,6 +69,8 @@ export function GuestRow(props: GuestRowProps) {
|
||||
});
|
||||
const diskPercent = createMemo(() => {
|
||||
if (!props.guest.disk || props.guest.disk.total === 0) return 0;
|
||||
// Check if usage is -1 (unknown/no guest agent)
|
||||
if (props.guest.disk.usage === -1) return -1;
|
||||
return (props.guest.disk.used / props.guest.disk.total) * 100;
|
||||
});
|
||||
|
||||
@@ -185,7 +187,7 @@ export function GuestRow(props: GuestRowProps) {
|
||||
{/* Disk */}
|
||||
<td class="p-1 px-2 w-[140px]">
|
||||
<Show
|
||||
when={props.guest.disk && props.guest.disk.total > 0}
|
||||
when={props.guest.disk && props.guest.disk.total > 0 && diskPercent() !== -1}
|
||||
fallback={<span class="text-gray-400 text-sm">-</span>}
|
||||
>
|
||||
<MetricBar
|
||||
|
||||
@@ -958,6 +958,12 @@ func (m *Monitor) pollVMsAndContainersEfficient(ctx context.Context, instanceNam
|
||||
diskFree := diskTotal - diskUsed
|
||||
diskUsage := safePercentage(float64(diskUsed), float64(diskTotal))
|
||||
|
||||
// If VM shows 0 disk usage but has allocated disk, it's likely guest agent issue
|
||||
// Set to -1 to indicate "unknown" rather than showing misleading 0%
|
||||
if res.Type == "qemu" && diskUsed == 0 && diskTotal > 0 && res.Status == "running" {
|
||||
diskUsage = -1
|
||||
}
|
||||
|
||||
// For running VMs, try to get filesystem info from guest agent
|
||||
if res.Status == "running" {
|
||||
// First check if agent is enabled by getting VM status
|
||||
@@ -1355,6 +1361,12 @@ func (m *Monitor) pollVMsWithNodes(ctx context.Context, instanceName string, cli
|
||||
diskFree := diskTotal - diskUsed
|
||||
diskUsage := safePercentage(float64(diskUsed), float64(diskTotal))
|
||||
|
||||
// If VM shows 0 disk usage but has allocated disk, it's likely guest agent issue
|
||||
// Set to -1 to indicate "unknown" rather than showing misleading 0%
|
||||
if diskUsed == 0 && diskTotal > 0 && vm.Status == "running" {
|
||||
diskUsage = -1
|
||||
}
|
||||
|
||||
// If VM has guest agent enabled and is running, try to get filesystem info
|
||||
if vm.Agent > 0 && vm.Status == "running" {
|
||||
log.Debug().
|
||||
|
||||
Reference in New Issue
Block a user