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.

Disambiguate linked host-agent alert names

rcourtman15657d9a0a97
diff --git a/internal/alerts/host.go b/internal/alerts/host.go
index c5bfb47639..ab5fe19027 100644
--- a/internal/alerts/host.go
+++ b/internal/alerts/host.go
@@ -27,16 +27,29 @@ func stripHostResourcePrefix(resourceID string) string {
}
func hostDisplayName(host models.Host) string {
+ base := "Agent"
if name := strings.TrimSpace(host.DisplayName); name != "" {
- return name
- }
- if name := strings.TrimSpace(host.Hostname); name != "" {
- return name
- }
- if host.ID != "" {
- return host.ID
+ base = name
+ } else if name := strings.TrimSpace(host.Hostname); name != "" {
+ base = name
+ } else if host.ID != "" {
+ base = host.ID
+ }
+
+ // When a host agent is linked to a Proxmox node/VM/container, qualify its
+ // name so its alerts are not confused with the linked resource's alerts.
+ if strings.TrimSpace(host.LinkedNodeID) != "" ||
+ strings.TrimSpace(host.LinkedVMID) != "" ||
+ strings.TrimSpace(host.LinkedContainerID) != "" {
+ if strings.EqualFold(base, "Agent") {
+ return "Host Agent"
+ }
+ if !strings.Contains(strings.ToLower(base), "host agent") {
+ return fmt.Sprintf("%s (Host Agent)", base)
+ }
}
- return "Agent"
+
+ return base
}
func hostInstanceName(host models.Host) string {
@@ -316,7 +329,7 @@ func (m *Manager) CheckHost(host models.Host) {
// Use specific resource ID for the disk: hostID/disk-temp:device
tempResourceID := fmt.Sprintf("%s/disk_temp:%s", hostResourceID(host.ID), sanitizeHostComponent(disk.Device))
- tempResourceName := fmt.Sprintf("%s (%s Temp)", host.DisplayName, disk.Device)
+ tempResourceName := fmt.Sprintf("%s (%s Temp)", hostDisplayName(host), disk.Device)
diskTempMetadata := cloneMetadata(baseMetadata)
diskTempMetadata["metric"] = "diskTemperature"
diff --git a/internal/alerts/utility_test.go b/internal/alerts/utility_test.go
index 20282f7259..a4781633cf 100644
--- a/internal/alerts/utility_test.go
+++ b/internal/alerts/utility_test.go
@@ -710,6 +710,33 @@ func TestHostDisplayName(t *testing.T) {
},
want: "Server Name",
},
+ {
+ name: "linked host agent display name is qualified",
+ host: models.Host{
+ ID: "id-123",
+ DisplayName: "Hamster",
+ LinkedVMID: "Main:node1:101",
+ },
+ want: "Hamster (Host Agent)",
+ },
+ {
+ name: "linked host agent hostname fallback is qualified",
+ host: models.Host{
+ ID: "id-123",
+ Hostname: "proxmoxn3",
+ LinkedContainerID: "Main:node1:102",
+ },
+ want: "proxmoxn3 (Host Agent)",
+ },
+ {
+ name: "existing host agent suffix is not duplicated",
+ host: models.Host{
+ ID: "id-123",
+ DisplayName: "Hamster (Host Agent)",
+ LinkedNodeID: "Main-node1",
+ },
+ want: "Hamster (Host Agent)",
+ },
}
for _, tc := range tests {