Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Alert on expected QEMU guest agent outages

rcourtman477c1e3da6ba
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 6058dc9a13..44e54b5dab 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -2511,6 +2511,13 @@ a new API state machine, queue contract, or verification-accounting field.
chip option counts, and grouping all collapse to the canonical
platform vocabulary instead of leaking storage technology labels
into operator chrome.
+35. Keep Proxmox VM guest-agent reachability on the shared API payloads instead
+ of deriving it in page-local code. Backend VM payloads and
+ `frontend-modern/src/types/api.ts` may carry optional
+ `guestAgentStatus` and `guestAgentExpected` fields. `expected-unreachable`
+ means the VM is still powered/running in Proxmox but a previously healthy
+ QEMU guest agent stopped responding; consumers must not reinterpret that
+ field as the VM power state.
## Forbidden Paths
diff --git a/docs/release-control/v6/internal/subsystems/monitoring.md b/docs/release-control/v6/internal/subsystems/monitoring.md
index 47b166d9cd..54b4d34e51 100644
--- a/docs/release-control/v6/internal/subsystems/monitoring.md
+++ b/docs/release-control/v6/internal/subsystems/monitoring.md
@@ -19,6 +19,10 @@
Own polling, typed collection, runtime state assembly, and canonical monitoring
truth for live infrastructure data.
+Monitoring also owns the distinction between Proxmox VM power state and QEMU
+guest-agent reachability: fresh or never-healthy VMs with an enabled but
+unavailable guest agent stay `not-running`, while only VMs with recent healthy
+guest-agent evidence may become `expected-unreachable`.
## Canonical Files
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index 78b324f2fc..42b3df239c 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -2068,6 +2068,12 @@ must not reinterpret the finding ID or approval-required chat mode as backup
freshness, restore authorization, storage remediation permission, or recovery
transport state, and must not treat the context-only handoff as a
storage/recovery-authored diagnostic prompt.
+Proxmox VM QEMU guest-agent outage incidents follow the same incident-context
+boundary. Storage and recovery may display or link from the resulting
+`availability_unreachable` resource incident when explaining why a VM lacks
+fresh guest telemetry, but they must not reinterpret `guestAgentStatus`,
+`guestAgentExpected`, or source `qemu-guest-agent` as backup freshness, restore
+eligibility, protection status, or recovery ownership.
Patrol queued-fix approvals that seed shared action-audit records follow the
same rule: storage and recovery may display the resulting action history as
incident-adjacent context, including the requester identity that distinguishes
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index 389ccfe231..cdb2a9a126 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -414,6 +414,11 @@ agent-backed resource and their `ProxmoxData.LinkedAgentID` must inherit the
parent Pulse agent ID. That linked agent ID is the only source for Proxmox
workload `discoveryTarget.agentId`; node names and VMIDs alone are not enough
to authorize browser action targets.
+Proxmox VM guest-agent outage projection is also a unified-resource boundary.
+When monitoring marks a running VM's expected QEMU guest agent as unreachable,
+the resource adapter must surface a Proxmox-authored `availability_unreachable`
+`resource-incident` with source `qemu-guest-agent`; it must leave VM power
+status online/warning rather than rewriting the VM to stopped/offline.
Service-discovery readiness is a unified-resource payload contract, not a
drawer-local decoration. Resource list/detail payloads that expose a
@@ -2801,9 +2806,10 @@ ownership.
Canonical Proxmox guest metadata now carries workload boundary fields such as
guest OS identity, guest agent version, guest network interfaces, VM disk
-status reason, and container OCI/Docker-detection metadata so monitoring can
-derive `models.VM` and `models.Container` from unified views without depending
-on legacy snapshot ownership.
+status reason, QEMU guest-agent runtime status/expectation, and container
+OCI/Docker-detection metadata so monitoring can derive `models.VM` and
+`models.Container` from unified views without depending on legacy snapshot
+ownership.
Canonical PBS metadata now carries full instance boundary payload such as host
and guest URLs, full datastore details, and PBS job arrays so monitoring can
diff --git a/frontend-modern/src/types/__tests__/resource.test.ts b/frontend-modern/src/types/__tests__/resource.test.ts
index f5274071d7..899aabcc7d 100644
--- a/frontend-modern/src/types/__tests__/resource.test.ts
+++ b/frontend-modern/src/types/__tests__/resource.test.ts
@@ -183,6 +183,39 @@ describe('Resource Type Guards', () => {
});
describe('Resource Helper Functions', () => {
+ describe('ResourceProxmoxMeta', () => {
+ it('accepts guest-agent outage metadata and availability incidents on VM resources', () => {
+ const proxmox: ResourceProxmoxMeta = {
+ vmid: 101,
+ nodeName: 'pve-a',
+ instance: 'cluster-a',
+ diskStatusReason: 'agent-not-running',
+ guestAgentStatus: 'expected-unreachable',
+ guestAgentExpected: true,
+ };
+ const resource: Resource = createResource({
+ type: 'vm',
+ proxmox,
+ incidents: [
+ {
+ provider: 'proxmox',
+ nativeId: 'cluster-a:pve-a:101',
+ source: 'qemu-guest-agent',
+ code: 'availability_unreachable',
+ severity: 'warning',
+ summary: 'QEMU guest agent stopped responding while the VM is still running',
+ startedAt: '2026-07-02T22:45:00Z',
+ },
+ ],
+ });
+
+ expect(resource.proxmox?.guestAgentStatus).toBe('expected-unreachable');
+ expect(resource.proxmox?.guestAgentExpected).toBe(true);
+ expect(resource.proxmox?.diskStatusReason).toBe('agent-not-running');
+ expect(resource.incidents?.[0]?.source).toBe('qemu-guest-agent');
+ });
+ });
+
describe('ResourceDockerMeta', () => {
it('accepts Docker host runtime and Swarm evidence in the canonical resource contract', () => {
const docker: ResourceDockerMeta = {
diff --git a/frontend-modern/src/types/api.ts b/frontend-modern/src/types/api.ts
index cfbdf2dfc8..d780f4ea1f 100644
--- a/frontend-modern/src/types/api.ts
+++ b/frontend-modern/src/types/api.ts
@@ -183,6 +183,8 @@ export interface VM {
disk: Disk;
disks?: Disk[];
diskStatusReason?: string;
+ guestAgentStatus?: string;
+ guestAgentExpected?: boolean;
ipAddresses?: string[];
osName?: string;
osVersion?: string;
diff --git a/frontend-modern/src/types/resource.ts b/frontend-modern/src/types/resource.ts
index 64f7aab133..f9c706016a 100644
--- a/frontend-modern/src/types/resource.ts
+++ b/frontend-modern/src/types/resource.ts
@@ -628,6 +628,9 @@ export interface ResourceProxmoxMeta {
cpus?: number;
template?: boolean;
disks?: Disk[];
+ diskStatusReason?: string;
+ guestAgentStatus?: string;
+ guestAgentExpected?: boolean;
swapUsed?: number;
swapTotal?: number;
balloon?: number;
diff --git a/internal/models/converters.go b/internal/models/converters.go
index 9aab2e2c0e..2ac2c78d1d 100644
--- a/internal/models/converters.go
+++ b/internal/models/converters.go
@@ -65,27 +65,29 @@ func (n Node) ToFrontend() NodeFrontend {
// ToFrontend converts a VM to VMFrontend
func (v VM) ToFrontend() VMFrontend {
vm := VMFrontend{
- ID: v.ID,
- VMID: v.VMID,
- Name: v.Name,
- Node: v.Node,
- Pool: v.Pool,
- Instance: v.Instance,
- Status: v.Status,
- Type: v.Type,
- CPU: v.CPU,
- CPUs: v.CPUs,
- Mem: v.Memory.Used,
- MaxMem: v.Memory.Total,
- NetIn: zeroIfNegative(v.NetworkIn),
- NetOut: zeroIfNegative(v.NetworkOut),
- DiskRead: zeroIfNegative(v.DiskRead),
- DiskWrite: zeroIfNegative(v.DiskWrite),
- Uptime: v.Uptime,
- Template: v.Template,
- Lock: v.Lock,
- LastSeen: timeToUnixMillis(v.LastSeen),
- DiskStatusReason: v.DiskStatusReason,
+ ID: v.ID,
+ VMID: v.VMID,
+ Name: v.Name,
+ Node: v.Node,
+ Pool: v.Pool,
+ Instance: v.Instance,
+ Status: v.Status,
+ Type: v.Type,
+ CPU: v.CPU,
+ CPUs: v.CPUs,
+ Mem: v.Memory.Used,
+ MaxMem: v.Memory.Total,
+ NetIn: zeroIfNegative(v.NetworkIn),
+ NetOut: zeroIfNegative(v.NetworkOut),
+ DiskRead: zeroIfNegative(v.DiskRead),
+ DiskWrite: zeroIfNegative(v.DiskWrite),
+ Uptime: v.Uptime,
+ Template: v.Template,
+ Lock: v.Lock,
+ LastSeen: timeToUnixMillis(v.LastSeen),
+ DiskStatusReason: v.DiskStatusReason,
+ GuestAgentStatus: v.GuestAgentStatus,
+ GuestAgentExpected: v.GuestAgentExpected,
}
// Convert tags array to string
diff --git a/internal/models/converters_test.go b/internal/models/converters_test.go
index 1d37e6d225..c65346dd91 100644
--- a/internal/models/converters_test.go
+++ b/internal/models/converters_test.go
@@ -185,28 +185,30 @@ func TestVMToFrontend(t *testing.T) {
lastBackup := now.Add(-24 * time.Hour)
vm := VM{
- ID: "vm-100",
- VMID: 100,
- Name: "test-vm",
- Node: "pve1",
- Instance: "default",
- Status: "running",
- Type: "qemu",
- CPU: 0.15,
- CPUs: 4,
- Memory: Memory{Total: 8000000000, Used: 4000000000},
- Disk: Disk{Total: 100000000000, Used: 50000000000},
- NetworkIn: 1000000,
- NetworkOut: 500000,
- DiskRead: 100000,
- DiskWrite: 50000,
- Uptime: 3600,
- Tags: []string{"production", "web"},
- LastSeen: now,
- LastBackup: lastBackup,
- IPAddresses: []string{"192.168.1.50", "10.0.0.50"},
- OSName: "Ubuntu",
- OSVersion: "22.04",
+ ID: "vm-100",
+ VMID: 100,
+ Name: "test-vm",
+ Node: "pve1",
+ Instance: "default",
+ Status: "running",
+ Type: "qemu",
+ CPU: 0.15,
+ CPUs: 4,
+ Memory: Memory{Total: 8000000000, Used: 4000000000},
+ Disk: Disk{Total: 100000000000, Used: 50000000000},
+ NetworkIn: 1000000,
+ NetworkOut: 500000,
+ DiskRead: 100000,
+ DiskWrite: 50000,
+ Uptime: 3600,
+ Tags: []string{"production", "web"},
+ LastSeen: now,
+ LastBackup: lastBackup,
+ IPAddresses: []string{"192.168.1.50", "10.0.0.50"},
+ OSName: "Ubuntu",
+ OSVersion: "22.04",
+ GuestAgentStatus: "expected-unreachable",
+ GuestAgentExpected: true,
}
frontend := vm.ToFrontend()
@@ -223,6 +225,12 @@ func TestVMToFrontend(t *testing.T) {
if frontend.Status != vm.Status {
t.Errorf("Status = %q, want %q", frontend.Status, vm.Status)
}
+ if frontend.GuestAgentStatus != vm.GuestAgentStatus {
+ t.Errorf("GuestAgentStatus = %q, want %q", frontend.GuestAgentStatus, vm.GuestAgentStatus)
+ }
+ if frontend.GuestAgentExpected != vm.GuestAgentExpected {
+ t.Errorf("GuestAgentExpected = %t, want %t", frontend.GuestAgentExpected, vm.GuestAgentExpected)
+ }
if frontend.CPU != vm.CPU {
t.Errorf("CPU = %f, want %f", frontend.CPU, vm.CPU)
}
diff --git a/internal/models/models.go b/internal/models/models.go
index 7db8359bb8..7106c61980 100644
--- a/internal/models/models.go
+++ b/internal/models/models.go
@@ -135,36 +135,38 @@ func (n Node) NormalizeCollections() Node {
// VM represents a virtual machine
type VM struct {
- ID string `json:"id"`
- VMID int `json:"vmid"`
- Name string `json:"name"`
- Node string `json:"node"`
- Pool string `json:"pool,omitempty"`
- Instance string `json:"instance"`
- Status string `json:"status"`
- Type string `json:"type"`
- CPU float64 `json:"cpu"`
- CPUs int `json:"cpus"`
- Memory Memory `json:"memory"`
- Disk Disk `json:"disk"`
- Disks []Disk `json:"disks,omitempty"`
- DiskStatusReason string `json:"diskStatusReason,omitempty"` // Why disk stats are unavailable
- IPAddresses []string `json:"ipAddresses,omitempty"`
- OSName string `json:"osName,omitempty"`
- OSVersion string `json:"osVersion,omitempty"`
- AgentVersion string `json:"agentVersion,omitempty"`
- NetworkInterfaces []GuestNetworkInterface `json:"networkInterfaces,omitempty"`
- NetworkIn int64 `json:"networkIn"`
- NetworkOut int64 `json:"networkOut"`
- DiskRead int64 `json:"diskRead"`
- DiskWrite int64 `json:"diskWrite"`
- Uptime int64 `json:"uptime"`
- Template bool `json:"template"`
- OnBoot *bool `json:"onBoot,omitempty"`
- LastBackup time.Time `json:"lastBackup,omitempty"`
- Tags []string `json:"tags,omitempty"`
- Lock string `json:"lock,omitempty"`
- LastSeen time.Time `json:"lastSeen"`
+ ID string `json:"id"`
+ VMID int `json:"vmid"`
+ Name string `json:"name"`
+ Node string `json:"node"`
+ Pool string `json:"pool,omitempty"`
+ Instance string `json:"instance"`
+ Status string `json:"status"`
+ Type string `json:"type"`
+ CPU float64 `json:"cpu"`
+ CPUs int `json:"cpus"`
+ Memory Memory `json:"memory"`
+ Disk Disk `json:"disk"`
+ Disks []Disk `json:"disks,omitempty"`
+ DiskStatusReason string `json:"diskStatusReason,omitempty"` // Why disk stats are unavailable
+ GuestAgentStatus string `json:"guestAgentStatus,omitempty"` // QEMU guest-agent runtime status
+ GuestAgentExpected bool `json:"guestAgentExpected,omitempty"`
+ IPAddresses []string `json:"ipAddresses,omitempty"`
+ OSName string `json:"osName,omitempty"`
+ OSVersion string `json:"osVersion,omitempty"`
+ AgentVersion string `json:"agentVersion,omitempty"`
+ NetworkInterfaces []GuestNetworkInterface `json:"networkInterfaces,omitempty"`
+ NetworkIn int64 `json:"networkIn"`
+ NetworkOut int64 `json:"networkOut"`
+ DiskRead int64 `json:"diskRead"`
+ DiskWrite int64 `json:"diskWrite"`
+ Uptime int64 `json:"uptime"`
+ Template bool `json:"template"`
+ OnBoot *bool `json:"onBoot,omitempty"`
+ LastBackup time.Time `json:"lastBackup,omitempty"`
+ Tags []string `json:"tags,omitempty"`
+ Lock string `json:"lock,omitempty"`
+ LastSeen time.Time `json:"lastSeen"`
}
func (v VM) NormalizeCollections() VM {
diff --git a/internal/models/models_frontend.go b/internal/models/models_frontend.go
index 4308daec22..4b3ddf3520 100644
--- a/internal/models/models_frontend.go
+++ b/internal/models/models_frontend.go
@@ -45,37 +45,39 @@ func (n NodeFrontend) NormalizeCollections() NodeFrontend {
// VMFrontend represents a VM with frontend-friendly field names
type VMFrontend struct {
- ID string `json:"id"`
- VMID int `json:"vmid"`
- Name string `json:"name"`
- Node string `json:"node"`
- Pool string `json:"pool,omitempty"`
- Instance string `json:"instance"`
- Status string `json:"status"`
- Type string `json:"type"`
- CPU float64 `json:"cpu"`
- CPUs int `json:"cpus"`
- Memory *Memory `json:"memory,omitempty"` // Full memory object
- Mem int64 `json:"mem"` // Maps to Memory.Used
- MaxMem int64 `json:"maxmem"` // Maps to Memory.Total
- DiskObj *Disk `json:"disk,omitempty"` // Full disk object
- Disks []Disk `json:"disks"` // Individual filesystem/disk usage
- DiskStatusReason string `json:"diskStatusReason,omitempty"` // Why disk stats are unavailable
- OSName string `json:"osName,omitempty"`
- OSVersion string `json:"osVersion,omitempty"`
- AgentVersion string `json:"agentVersion,omitempty"`
- NetworkInterfaces []GuestNetworkInterface `json:"networkInterfaces"`
- IPAddresses []string `json:"ipAddresses"`
- NetIn int64 `json:"networkIn"` // Maps to NetworkIn (camelCase for frontend)
- NetOut int64 `json:"networkOut"` // Maps to NetworkOut (camelCase for frontend)
- DiskRead int64 `json:"diskRead"` // Maps to DiskRead (camelCase for frontend)
- DiskWrite int64 `json:"diskWrite"` // Maps to DiskWrite (camelCase for frontend)
- Uptime int64 `json:"uptime"`
- Template bool `json:"template"`
- LastBackup int64 `json:"lastBackup,omitempty"` // Unix timestamp
- Tags string `json:"tags,omitempty"` // Joined string
- Lock string `json:"lock,omitempty"`
- LastSeen int64 `json:"lastSeen"` // Unix timestamp
+ ID string `json:"id"`
+ VMID int `json:"vmid"`
+ Name string `json:"name"`
+ Node string `json:"node"`
+ Pool string `json:"pool,omitempty"`
+ Instance string `json:"instance"`
+ Status string `json:"status"`
+ Type string `json:"type"`
+ CPU float64 `json:"cpu"`
+ CPUs int `json:"cpus"`
+ Memory *Memory `json:"memory,omitempty"` // Full memory object
+ Mem int64 `json:"mem"` // Maps to Memory.Used
+ MaxMem int64 `json:"maxmem"` // Maps to Memory.Total
+ DiskObj *Disk `json:"disk,omitempty"` // Full disk object
+ Disks []Disk `json:"disks"` // Individual filesystem/disk usage
+ DiskStatusReason string `json:"diskStatusReason,omitempty"` // Why disk stats are unavailable
+ GuestAgentStatus string `json:"guestAgentStatus,omitempty"` // QEMU guest-agent runtime status
+ GuestAgentExpected bool `json:"guestAgentExpected,omitempty"`
+ OSName string `json:"osName,omitempty"`
+ OSVersion string `json:"osVersion,omitempty"`
+ AgentVersion string `json:"agentVersion,omitempty"`
+ NetworkInterfaces []GuestNetworkInterface `json:"networkInterfaces"`
+ IPAddresses []string `json:"ipAddresses"`
+ NetIn int64 `json:"networkIn"` // Maps to NetworkIn (camelCase for frontend)
+ NetOut int64 `json:"networkOut"` // Maps to NetworkOut (camelCase for frontend)
+ DiskRead int64 `json:"diskRead"` // Maps to DiskRead (camelCase for frontend)
+ DiskWrite int64 `json:"diskWrite"` // Maps to DiskWrite (camelCase for frontend)
+ Uptime int64 `json:"uptime"`
+ Template bool `json:"template"`
+ LastBackup int64 `json:"lastBackup,omitempty"` // Unix timestamp
+ Tags string `json:"tags,omitempty"` // Joined string
+ Lock string `json:"lock,omitempty"`
+ LastSeen int64 `json:"lastSeen"` // Unix timestamp
}
func (v VMFrontend) NormalizeCollections() VMFrontend {
diff --git a/internal/monitoring/canonical_guardrails_test.go b/internal/monitoring/canonical_guardrails_test.go
index 50bfc52842..615f81e57f 100644
--- a/internal/monitoring/canonical_guardrails_test.go
+++ b/internal/monitoring/canonical_guardrails_test.go
@@ -851,7 +851,9 @@ func TestProxmoxGuestDiskCarryForwardUsesCanonicalStabilityHelper(t *testing.T)
},
"monitor_pve_guest_builders.go": {
"state.diskTotal, state.diskUsed, state.diskFree, state.diskUsage, state.individualDisks, state.diskStatusReason = stabilizeGuestLowTrustDisk(",
- "DiskStatusReason: state.diskStatusReason,",
+ "DiskStatusReason: state.diskStatusReason,",
+ "GuestAgentStatus: state.guestAgentStatus,",
+ "GuestAgentExpected: state.guestAgentExpected,",
"return nil, classifyGuestAgentDiskStatusError(err), false",
},
"monitor_polling_vm.go": {
diff --git a/internal/monitoring/guest_agent_evidence.go b/internal/monitoring/guest_agent_evidence.go
index 7a1f0f272d..caf19fd1ce 100644
--- a/internal/monitoring/guest_agent_evidence.go
+++ b/internal/monitoring/guest_agent_evidence.go
@@ -22,6 +22,7 @@ func hasRecentGuestAgentEvidence(prev *models.VM, now time.Time) bool {
}
if prev.AgentVersion != "" ||
+ prev.GuestAgentStatus == "available" ||
len(prev.IPAddresses) > 0 ||
len(prev.NetworkInterfaces) > 0 ||
prev.OSName != "" ||
diff --git a/internal/monitoring/guest_agent_evidence_test.go b/internal/monitoring/guest_agent_evidence_test.go
index 61d59f4f7a..92ff25a72f 100644
--- a/internal/monitoring/guest_agent_evidence_test.go
+++ b/internal/monitoring/guest_agent_evidence_test.go
@@ -23,6 +23,22 @@ func TestHasRecentGuestAgentEvidenceAcceptsUnifiedReadStateStatus(t *testing.T)
}
}
+func TestHasRecentGuestAgentEvidenceAcceptsGuestAgentStatus(t *testing.T) {
+ now := time.Now()
+
+ prev := &models.VM{
+ Type: "qemu",
+ Status: "running",
+ GuestAgentStatus: "available",
+ GuestAgentExpected: true,
+ LastSeen: now.Add(-time.Minute),
+ }
+
+ if !hasRecentGuestAgentEvidence(prev, now) {
+ t.Fatal("expected previous guest-agent available status to count as recent evidence")
+ }
+}
+
func TestHasRecentGuestAgentEvidenceRejectsStaleSnapshots(t *testing.T) {
now := time.Now()
diff --git a/internal/monitoring/monitor_extra_coverage_test.go b/internal/monitoring/monitor_extra_coverage_test.go
index e02e280b54..d3da293eb5 100644
--- a/internal/monitoring/monitor_extra_coverage_test.go
+++ b/internal/monitoring/monitor_extra_coverage_test.go
@@ -1269,6 +1269,121 @@ func TestBuildVMFromClusterResource_ContinuesGuestAgentQueriesAfterTransientStat
}
}
+func TestBuildVMFromClusterResource_MarksExpectedGuestAgentUnreachable(t *testing.T) {
+ monitor := &Monitor{
+ rateTracker: NewRateTracker(),
+ guestMetadataCache: make(map[string]guestMetadataCacheEntry),
+ guestMetadataLimiter: make(map[string]time.Time),
+ }
+ guestID := makeGuestID("pve1", "node1", 100)
+ prevVM := &models.VM{
+ ID: guestID,
+ Instance: "pve1",
+ Node: "node1",
+ VMID: 100,
+ Name: "win-app",
+ Type: "qemu",
+ Status: "running",
+ AgentVersion: "8.2.0",
+ LastSeen: time.Now(),
+ }
+ client := &mockPVEClientExtra{
+ vmStatus: &proxmox.VMStatus{
+ Status: "running",
+ MaxMem: 8 * 1024 * 1024 * 1024,
+ Mem: 2 * 1024 * 1024 * 1024,
+ Agent: proxmox.VMAgentField{
+ Enabled: 1,
+ Available: 0,
+ AvailabilityKnown: true,
+ },
+ },
+ }
+
+ vm, _, _, _, _, ok := monitor.buildVMFromClusterResource(
+ context.Background(),
+ "pve1",
+ proxmox.ClusterResource{
+ Type: "qemu",
+ Node: "node1",
+ Name: "win-app",
+ Status: "running",
+ VMID: 100,
+ MaxCPU: 4,
+ MaxMem: 8 * 1024 * 1024 * 1024,
+ Mem: 2 * 1024 * 1024 * 1024,
+ MaxDisk: 100 * 1024 * 1024 * 1024,
+ },
+ client,
+ guestID,
+ nil,
+ prevVM,
+ )
+ if !ok {
+ t.Fatal("expected VM to be built")
+ }
+ if vm.Status != "running" {
+ t.Fatalf("VM Status = %q, want running", vm.Status)
+ }
+ if vm.GuestAgentStatus != "expected-unreachable" {
+ t.Fatalf("GuestAgentStatus = %q, want expected-unreachable", vm.GuestAgentStatus)
+ }
+ if !vm.GuestAgentExpected {
+ t.Fatal("expected GuestAgentExpected to be true")
+ }
+ if vm.DiskStatusReason != "agent-not-running" {
+ t.Fatalf("DiskStatusReason = %q, want agent-not-running", vm.DiskStatusReason)
+ }
+}
+
+func TestBuildVMFromClusterResource_DoesNotExpectNeverHealthyGuestAgent(t *testing.T) {
+ monitor := &Monitor{
+ rateTracker: NewRateTracker(),
+ guestMetadataCache: make(map[string]guestMetadataCacheEntry),
+ guestMetadataLimiter: make(map[string]time.Time),
+ }
+ client := &mockPVEClientExtra{
+ vmStatus: &proxmox.VMStatus{
+ Status: "running",
+ MaxMem: 4 * 1024 * 1024 * 1024,
+ Mem: 1024 * 1024 * 1024,
+ Agent: proxmox.VMAgentField{
+ Enabled: 1,
+ Available: 0,
+ AvailabilityKnown: true,
+ },
+ },
+ }
+
+ vm, _, _, _, _, ok := monitor.buildVMFromClusterResource(
+ context.Background(),
+ "pve1",
+ proxmox.ClusterResource{
+ Type: "qemu",
+ Node: "node1",
+ Name: "fresh-vm",
+ Status: "running",
+ VMID: 101,
+ MaxMem: 4 * 1024 * 1024 * 1024,
+ Mem: 1024 * 1024 * 1024,
+ MaxDisk: 20 * 1024 * 1024 * 1024,
+ },
+ client,
+ makeGuestID("pve1", "node1", 101),
+ nil,
+ nil,
+ )
+ if !ok {
+ t.Fatal("expected VM to be built")
+ }
+ if vm.GuestAgentStatus != "not-running" {
+ t.Fatalf("GuestAgentStatus = %q, want not-running", vm.GuestAgentStatus)
+ }
+ if vm.GuestAgentExpected {
+ t.Fatal("expected GuestAgentExpected to be false")
+ }
+}
+
func TestPollVMsAndContainersEfficient_ContinuesGuestAgentQueriesAfterTransientStatusFailure(t *testing.T) {
t.Setenv("PULSE_DATA_DIR", t.TempDir())
diff --git a/internal/monitoring/monitor_pve_guest_builders.go b/internal/monitoring/monitor_pve_guest_builders.go
index 9a5edba28b..cca26c69cc 100644
--- a/internal/monitoring/monitor_pve_guest_builders.go
+++ b/internal/monitoring/monitor_pve_guest_builders.go
@@ -13,28 +13,30 @@ import (
)
type vmBuildState struct {
- memTotal uint64
- memUsed uint64
- memorySource string
- guestRaw VMMemoryRaw
- diskReadBytes int64
- diskWriteBytes int64
- networkInBytes int64
- networkOutBytes int64
- diskTotal uint64
- diskUsed uint64
- diskFree uint64
- diskUsage float64
- diskFromAgent bool
- diskStatusReason string
- individualDisks []models.Disk
- ipAddresses []string
- networkInterfaces []models.GuestNetworkInterface
- osName string
- osVersion string
- agentVersion string
- detailedStatus *proxmox.VMStatus
- onBoot *bool
+ memTotal uint64
+ memUsed uint64
+ memorySource string
+ guestRaw VMMemoryRaw
+ diskReadBytes int64
+ diskWriteBytes int64
+ networkInBytes int64
+ networkOutBytes int64
+ diskTotal uint64
+ diskUsed uint64
+ diskFree uint64
+ diskUsage float64
+ diskFromAgent bool
+ diskStatusReason string
+ guestAgentStatus string
+ guestAgentExpected bool
+ individualDisks []models.Disk
+ ipAddresses []string
+ networkInterfaces []models.GuestNetworkInterface
+ osName string
+ osVersion string
+ agentVersion string
+ detailedStatus *proxmox.VMStatus
+ onBoot *bool
}
func (m *Monitor) applyVMStatusDetails(
@@ -45,6 +47,7 @@ func (m *Monitor) applyVMStatusDetails(
guestID string,
vmIDToHostAgent map[string]models.Host,
status *proxmox.VMStatus,
+ recentGuestAgentEvidence bool,
state *vmBuildState,
) {
if status == nil || state == nil {
@@ -52,6 +55,7 @@ func (m *Monitor) applyVMStatusDetails(
}
state.detailedStatus = status
+ state.guestAgentStatus, state.guestAgentExpected = vmGuestAgentRuntimeState(status, recentGuestAgentEvidence)
state.memTotal, state.memUsed, state.memorySource = m.resolveGuestStatusMemory(
ctx,
client,
@@ -128,6 +132,22 @@ func (m *Monitor) applyVMStatusDetails(
}
+func vmGuestAgentRuntimeState(status *proxmox.VMStatus, recentGuestAgentEvidence bool) (string, bool) {
+ if status == nil {
+ return "", false
+ }
+ if status.Agent.IsAvailable() {
+ return "available", true
+ }
+ if status.Agent.IsEnabled() {
+ if recentGuestAgentEvidence {
+ return "expected-unreachable", true
+ }
+ return "not-running", false
+ }
+ return "disabled", false
+}
+
func (m *Monitor) buildVMFromClusterResource(
ctx context.Context,
instanceName string,
@@ -146,6 +166,9 @@ func (m *Monitor) buildVMFromClusterResource(
guestID = makeGuestID(instanceName, res.Node, res.VMID)
}
prevSnapshot := m.previousGuestSnapshot(instanceName, "qemu", res.Node, res.VMID)
+ prePollTime := time.Now()
+ recentGuestAgentEvidence := hasRecentGuestAgentEvidence(prevVM, prePollTime) ||
+ m.hasRecentGuestMetadataEvidence(instanceName, res.Node, res.VMID, prePollTime)
state := vmBuildState{
memTotal: res.MaxMem,
@@ -189,7 +212,7 @@ func (m *Monitor) buildVMFromClusterResource(
Int("vmid", res.VMID).
Msg("Could not get VM status to check guest agent availability")
} else if status != nil {
- m.applyVMStatusDetails(ctx, instanceName, res, client, guestID, vmIDToHostAgent, status, &state)
+ m.applyVMStatusDetails(ctx, instanceName, res, client, guestID, vmIDToHostAgent, status, recentGuestAgentEvidence, &state)
} else {
if state.diskTotal > 0 {
state.diskStatusReason = "no-status"
@@ -245,6 +268,10 @@ func (m *Monitor) buildVMFromClusterResource(
if len(fsDisks) > 0 {
state.individualDisks = fsDisks
}
+ state.guestAgentExpected = true
+ if len(guestIPs) > 0 || len(guestIfaces) > 0 || guestOSName != "" || guestOSVersion != "" || guestAgentVersion != "" || state.diskFromAgent {
+ state.guestAgentStatus = "available"
+ }
}
var preferred bool
@@ -359,21 +386,23 @@ func (m *Monitor) buildVMFromClusterResource(
Free: int64(state.diskFree),
Usage: state.diskUsage,
},
- Disks: state.individualDisks,
- DiskStatusReason: state.diskStatusReason,
- IPAddresses: state.ipAddresses,
- OSName: state.osName,
- OSVersion: state.osVersion,
- AgentVersion: state.agentVersion,
- NetworkInterfaces: state.networkInterfaces,
- NetworkIn: max(0, int64(netInRate)),
- NetworkOut: max(0, int64(netOutRate)),
- DiskRead: max(0, int64(diskReadRate)),
- DiskWrite: max(0, int64(diskWriteRate)),
- Uptime: int64(res.Uptime),
- Template: res.Template == 1,
- OnBoot: state.onBoot,
- LastSeen: sampleTime,
+ Disks: state.individualDisks,
+ DiskStatusReason: state.diskStatusReason,
+ GuestAgentStatus: state.guestAgentStatus,
+ GuestAgentExpected: state.guestAgentExpected,
+ IPAddresses: state.ipAddresses,
+ OSName: state.osName,
+ OSVersion: state.osVersion,
+ AgentVersion: state.agentVersion,
+ NetworkInterfaces: state.networkInterfaces,
+ NetworkIn: max(0, int64(netInRate)),
+ NetworkOut: max(0, int64(netOutRate)),
+ DiskRead: max(0, int64(diskReadRate)),
+ DiskWrite: max(0, int64(diskWriteRate)),
+ Uptime: int64(res.Uptime),
+ Template: res.Template == 1,
+ OnBoot: state.onBoot,
+ LastSeen: sampleTime,
}
// Parse tags
diff --git a/internal/unifiedresources/adapter_coverage_test.go b/internal/unifiedresources/adapter_coverage_test.go
index fe447b0c1d..93644b02c6 100644
--- a/internal/unifiedresources/adapter_coverage_test.go
+++ b/internal/unifiedresources/adapter_coverage_test.go
@@ -118,6 +118,64 @@ func TestMonitorSourceType(t *testing.T) {
}
}
+func TestResourceFromVMProjectsExpectedGuestAgentOutageIncident(t *testing.T) {
+ now := time.Now()
+ resource, _ := resourceFromVM(models.VM{
+ ID: "cluster-a:pve-a:101",
+ Name: "win-app",
+ Node: "pve-a",
+ Instance: "cluster-a",
+ VMID: 101,
+ Status: "running",
+ Type: "qemu",
+ GuestAgentStatus: "expected-unreachable",
+ GuestAgentExpected: true,
+ LastSeen: now,
+ })
+
+ if resource.Status != StatusWarning {
+ t.Fatalf("Status = %q, want warning", resource.Status)
+ }
+ if resource.Proxmox == nil || resource.Proxmox.GuestAgentStatus != "expected-unreachable" || !resource.Proxmox.GuestAgentExpected {
+ t.Fatalf("expected proxmox guest-agent status projection, got %+v", resource.Proxmox)
+ }
+ if len(resource.Incidents) != 1 {
+ t.Fatalf("expected one guest-agent incident, got %+v", resource.Incidents)
+ }
+ incident := resource.Incidents[0]
+ if incident.Provider != "proxmox" || incident.Source != "qemu-guest-agent" || incident.Code != "availability_unreachable" {
+ t.Fatalf("unexpected incident identity: %+v", incident)
+ }
+ if incident.Severity != storagehealth.RiskWarning {
+ t.Fatalf("incident severity = %q, want %q", incident.Severity, storagehealth.RiskWarning)
+ }
+ if !incident.StartedAt.Equal(now) {
+ t.Fatalf("incident StartedAt = %s, want %s", incident.StartedAt, now)
+ }
+}
+
+func TestResourceFromVMIgnoresNeverHealthyGuestAgent(t *testing.T) {
+ resource, _ := resourceFromVM(models.VM{
+ ID: "cluster-a:pve-a:102",
+ Name: "new-vm",
+ Node: "pve-a",
+ Instance: "cluster-a",
+ VMID: 102,
+ Status: "running",
+ Type: "qemu",
+ GuestAgentStatus: "not-running",
+ GuestAgentExpected: false,
+ LastSeen: time.Now(),
+ })
+
+ if resource.Status != StatusOnline {
+ t.Fatalf("Status = %q, want online", resource.Status)
+ }
+ if len(resource.Incidents) != 0 {
+ t.Fatalf("expected no incident, got %+v", resource.Incidents)
+ }
+}
+
func TestMonitorHostnamePriority(t *testing.T) {
tests := []struct {
name string
diff --git a/internal/unifiedresources/adapters.go b/internal/unifiedresources/adapters.go
index f9f67f4000..788f48be69 100644
--- a/internal/unifiedresources/adapters.go
+++ b/internal/unifiedresources/adapters.go
@@ -1532,26 +1532,28 @@ func resourceFromVM(vm models.VM) (Resource, ResourceIdentity) {
sourceID := proxmoxVMSourceID(vm)
metrics := metricsFromVM(vm)
proxmox := &ProxmoxData{
- SourceID: sourceID,
- NodeName: vm.Node,
- Pool: vm.Pool,
- Instance: vm.Instance,
- VMID: vm.VMID,
- CPUs: vm.CPUs,
- Uptime: vm.Uptime,
- Template: vm.Template,
- LastBackup: vm.LastBackup,
- DiskStatusReason: vm.DiskStatusReason,
- OSName: vm.OSName,
- OSVersion: vm.OSVersion,
- AgentVersion: vm.AgentVersion,
- NetworkInterfaces: convertGuestInterfaces(vm.NetworkInterfaces),
- Disks: convertDisks(vm.Disks),
- SwapUsed: vm.Memory.SwapUsed,
- SwapTotal: vm.Memory.SwapTotal,
- Balloon: vm.Memory.Balloon,
- MemoryCache: vm.Memory.Cache,
- Lock: vm.Lock,
+ SourceID: sourceID,
+ NodeName: vm.Node,
+ Pool: vm.Pool,
+ Instance: vm.Instance,
+ VMID: vm.VMID,
+ CPUs: vm.CPUs,
+ Uptime: vm.Uptime,
+ Template: vm.Template,
+ LastBackup: vm.LastBackup,
+ DiskStatusReason: vm.DiskStatusReason,
+ GuestAgentStatus: vm.GuestAgentStatus,
+ GuestAgentExpected: vm.GuestAgentExpected,
+ OSName: vm.OSName,
+ OSVersion: vm.OSVersion,
+ AgentVersion: vm.AgentVersion,
+ NetworkInterfaces: convertGuestInterfaces(vm.NetworkInterfaces),
+ Disks: convertDisks(vm.Disks),
+ SwapUsed: vm.Memory.SwapUsed,
+ SwapTotal: vm.Memory.SwapTotal,
+ Balloon: vm.Memory.Balloon,
+ MemoryCache: vm.Memory.Cache,
+ Lock: vm.Lock,
}
resource := Resource{
Type: ResourceTypeVM,
@@ -1564,6 +1566,10 @@ func resourceFromVM(vm models.VM) (Resource, ResourceIdentity) {
Proxmox: proxmox,
Tags: vm.Tags,
}
+ if incident, ok := vmGuestAgentIncident(vm); ok {
+ resource.Incidents = append(resource.Incidents, incident)
+ resource.Status = incidentsStatus(resource.Status, resource.Incidents)
+ }
resource.Capabilities = proxmoxGuestLifecycleCapabilities("vm", "qemu", vm.Status, vm.Template, vm.Lock)
identity := ResourceIdentity{
Hostnames: uniqueStrings([]string{vm.Name}),
@@ -1572,6 +1578,21 @@ func resourceFromVM(vm models.VM) (Resource, ResourceIdentity) {
return resource, identity
}
+func vmGuestAgentIncident(vm models.VM) (ResourceIncident, bool) {
+ if !vm.GuestAgentExpected || vm.GuestAgentStatus != "expected-unreachable" || !strings.EqualFold(strings.TrimSpace(vm.Status), "running") {
+ return ResourceIncident{}, false
+ }
+ return ResourceIncident{
+ Provider: "proxmox",
+ NativeID: proxmoxVMSourceID(vm),
+ Code: "availability_unreachable",
+ Severity: storagehealth.RiskWarning,
+ Source: "qemu-guest-agent",
+ Summary: "QEMU guest agent stopped responding while the VM is still running",
+ StartedAt: vm.LastSeen,
+ }, true
+}
+
func resourceFromContainer(ct models.Container) (Resource, ResourceIdentity) {
sourceID := proxmoxContainerSourceID(ct)
metrics := metricsFromContainer(ct)
diff --git a/internal/unifiedresources/canonical_identity_test.go b/internal/unifiedresources/canonical_identity_test.go
index 0692bede31..ba1f61b908 100644
--- a/internal/unifiedresources/canonical_identity_test.go
+++ b/internal/unifiedresources/canonical_identity_test.go
@@ -3,6 +3,8 @@ package unifiedresources
import (
"reflect"
"testing"
+
+ "github.com/rcourtman/pulse-go-rewrite/internal/models"
)
func TestRefreshCanonicalIdentityPrefersTargetsAndCanonicalHostData(t *testing.T) {
@@ -73,6 +75,27 @@ func TestRefreshCanonicalIdentityPrefersTargetsAndCanonicalHostData(t *testing.T
}
}
+func TestVMGuestAgentIncidentUsesCanonicalSourceID(t *testing.T) {
+ vm := models.VM{
+ ID: "cluster-a:pve-a:101",
+ Name: "win-app",
+ Node: "pve-a",
+ Instance: "cluster-a",
+ VMID: 101,
+ Status: "running",
+ Type: "qemu",
+ GuestAgentStatus: "expected-unreachable",
+ GuestAgentExpected: true,
+ }
+ resource, _ := resourceFromVM(vm)
+ if len(resource.Incidents) != 1 {
+ t.Fatalf("expected one incident, got %+v", resource.Incidents)
+ }
+ if got, want := resource.Incidents[0].NativeID, proxmoxVMSourceID(vm); got != want {
+ t.Fatalf("incident NativeID = %q, want %q", got, want)
+ }
+}
+
func TestRefreshCanonicalIdentityFallsBackWithoutTargets(t *testing.T) {
resource := Resource{
ID: "pbs-1",
diff --git a/internal/unifiedresources/types.go b/internal/unifiedresources/types.go
index cdd9836161..c5016cf9a7 100644
--- a/internal/unifiedresources/types.go
+++ b/internal/unifiedresources/types.go
@@ -339,6 +339,8 @@ type ProxmoxData struct {
Uptime int64 `json:"uptime,omitempty"`
LastBackup time.Time `json:"lastBackup,omitempty"`
DiskStatusReason string `json:"diskStatusReason,omitempty"`
+ GuestAgentStatus string `json:"guestAgentStatus,omitempty"`
+ GuestAgentExpected bool `json:"guestAgentExpected,omitempty"`
OSName string `json:"osName,omitempty"`
OSVersion string `json:"osVersion,omitempty"`
AgentVersion string `json:"agentVersion,omitempty"`