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.

Unify Proxmox discovery and integrate PMG Patrol

rcourtman2d29b3dcd776
diff --git a/frontend-modern/src/api/patrol.ts b/frontend-modern/src/api/patrol.ts
index 2353bf0d09..835d017c4c 100644
--- a/frontend-modern/src/api/patrol.ts
+++ b/frontend-modern/src/api/patrol.ts
@@ -347,6 +347,7 @@ export interface PatrolRunRecord {
storage_checked: number;
hosts_checked: number;
pbs_checked: number;
+ pmg_checked: number;
kubernetes_checked: number;
new_findings: number;
existing_findings: number;
diff --git a/frontend-modern/src/components/patrol/RunHistoryEntry.tsx b/frontend-modern/src/components/patrol/RunHistoryEntry.tsx
index 7a43ac5001..bd8fe1b3b6 100644
--- a/frontend-modern/src/components/patrol/RunHistoryEntry.tsx
+++ b/frontend-modern/src/components/patrol/RunHistoryEntry.tsx
@@ -29,6 +29,7 @@ import ZapIcon from 'lucide-solid/icons/zap';
import AlertTriangleIcon from 'lucide-solid/icons/alert-triangle';
import FilterXIcon from 'lucide-solid/icons/filter-x';
import SparklesIcon from 'lucide-solid/icons/sparkles';
+import MailIcon from 'lucide-solid/icons/mail';
interface PatrolStreamState {
phase: Accessor<string>;
@@ -204,6 +205,11 @@ export function RunHistoryEntry(props: RunHistoryEntryProps) {
<DatabaseIcon class="w-3 h-3" /> {run.pbs_checked} PBS
</span>
</Show>
+ <Show when={run.pmg_checked > 0}>
+ <span class="inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium bg-orange-50 text-orange-700 dark:bg-orange-900/30 dark:text-orange-300">
+ <MailIcon class="w-3 h-3" /> {run.pmg_checked} PMG
+ </span>
+ </Show>
<Show when={run.kubernetes_checked > 0}>
<span class="inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium bg-sky-50 text-sky-700 dark:bg-sky-900/30 dark:text-sky-300">
<ActivityIcon class="w-3 h-3" /> {run.kubernetes_checked} K8s
diff --git a/internal/ai/patrol.go b/internal/ai/patrol.go
index 644b2b545d..43bd066fd4 100644
--- a/internal/ai/patrol.go
+++ b/internal/ai/patrol.go
@@ -114,6 +114,7 @@ type PatrolRunRecord struct {
StorageChecked int `json:"storage_checked"`
HostsChecked int `json:"hosts_checked"`
PBSChecked int `json:"pbs_checked"`
+ PMGChecked int `json:"pmg_checked"`
KubernetesChecked int `json:"kubernetes_checked"`
// Findings from this run
NewFindings int `json:"new_findings"`
diff --git a/internal/ai/patrol_ai.go b/internal/ai/patrol_ai.go
index d199fabf17..77ab0442ef 100644
--- a/internal/ai/patrol_ai.go
+++ b/internal/ai/patrol_ai.go
@@ -556,6 +556,9 @@ func patrolResourceCount(state models.StateSnapshot, cfg PatrolConfig) int {
if cfg.AnalyzeKubernetes {
resourceCount += len(state.KubernetesClusters)
}
+ if cfg.AnalyzePMG {
+ resourceCount += len(state.PMGInstances)
+ }
return resourceCount
}
@@ -921,6 +924,7 @@ You are provided with the current state of the user's infrastructure below, incl
- Use **pulse_read** to check logs on resources that look unhealthy or abnormal.
- Use **pulse_storage** to check snapshot ages, replication status, or backup job details.
- Use **pulse_query** to check resource configuration for misconfigurations.
+- Use **pulse_pmg** to check mail queues or spam volume if mail flow looks abnormal.
**Step 3 — Report or resolve findings.** Report findings for confirmed issues. Resolve active findings that are no longer issues based on current data.
Always call patrol_get_findings before reporting or resolving findings.
@@ -1040,6 +1044,7 @@ func (p *PatrolService) buildSeedContext(state models.StateSnapshot, scope *Patr
sb.WriteString(p.seedPreviousRun(now))
intel := p.seedPrecomputeIntelligence(state, scopedSet, now)
sb.WriteString(p.seedResourceInventory(state, scopedSet, cfg, now, intel.isQuiet))
+ p.seedPMGSnapshot(&sb, state, scopedSet, cfg, intel.isQuiet)
sb.WriteString(p.seedBackupAnalysis(state, now))
sb.WriteString(p.seedHealthAndAlerts(state, scopedSet, cfg, now))
sb.WriteString(p.seedIntelligenceContext(intel, now))
@@ -1558,6 +1563,82 @@ func (p *PatrolService) seedResourceInventory(state models.StateSnapshot, scoped
return sb.String()
}
+// seedPMGSnapshot adds Proxmox Mail Gateway status to the seed context
+func (p *PatrolService) seedPMGSnapshot(sb *strings.Builder, state models.StateSnapshot, scopedSet map[string]bool, cfg PatrolConfig, isQuiet bool) {
+ if !cfg.AnalyzePMG || len(state.PMGInstances) == 0 {
+ return
+ }
+
+ var scopedPMG []models.PMGInstance
+ for _, pmg := range state.PMGInstances {
+ if seedIsInScope(scopedSet, pmg.ID) {
+ scopedPMG = append(scopedPMG, pmg)
+ }
+ }
+
+ if len(scopedPMG) == 0 {
+ return
+ }
+
+ if isQuiet && scopedSet == nil {
+ allHealthy := true
+ for _, pmg := range scopedPMG {
+ if pmg.Status != "online" {
+ allHealthy = false
+ break
+ }
+ // basic health check on mail stats if available
+ if pmg.MailStats != nil {
+ // if average process time > 5s, consider it noteworthy/unhealthy for quiet mode
+ if pmg.MailStats.AverageProcessTimeMs > 5000 {
+ allHealthy = false
+ break
+ }
+ }
+ }
+ if allHealthy {
+ sb.WriteString(fmt.Sprintf("# PMG: %d gateways, all healthy and processing mail normally.\n\n", len(scopedPMG)))
+ return
+ }
+ }
+
+ sb.WriteString("# Proxmox Mail Gateway (PMG)\n")
+ sb.WriteString("| Instance | Status | Version | In/Out | Spam/Virus | Avg Time | Queue (Active/Deferred/Hold) |\n")
+ sb.WriteString("|----------|--------|---------|--------|------------|----------|------------------------------|\n")
+
+ for _, pmg := range scopedPMG {
+ version := pmg.Version
+ if version == "" {
+ version = "—"
+ }
+
+ traffic := "—"
+ spamVirus := "—"
+ avgTime := "—"
+
+ if stats := pmg.MailStats; stats != nil {
+ traffic = fmt.Sprintf("%.0f/%.0f", stats.CountIn, stats.CountOut)
+ spamVirus = fmt.Sprintf("%.0f/%.0f", stats.SpamIn+stats.SpamOut, stats.VirusIn+stats.VirusOut)
+ avgTime = fmt.Sprintf("%.0fms", stats.AverageProcessTimeMs)
+ }
+
+ // Aggregate queues from nodes
+ active, deferred, hold := 0, 0, 0
+ for _, node := range pmg.Nodes {
+ if node.QueueStatus != nil {
+ active += node.QueueStatus.Active
+ deferred += node.QueueStatus.Deferred
+ hold += node.QueueStatus.Hold
+ }
+ }
+ queueStr := fmt.Sprintf("%d/%d/%d", active, deferred, hold)
+
+ sb.WriteString(fmt.Sprintf("| %s | %s | %s | %s | %s | %s | %s |\n",
+ pmg.Name, pmg.Status, version, traffic, spamVirus, avgTime, queueStr))
+ }
+ sb.WriteString("\n")
+}
+
// seedBackupAnalysis builds the backup status section.
func (p *PatrolService) seedBackupAnalysis(state models.StateSnapshot, now time.Time) string {
type backupInfo struct {
diff --git a/internal/ai/patrol_init.go b/internal/ai/patrol_init.go
index d3797133af..2c8c4926c2 100644
--- a/internal/ai/patrol_init.go
+++ b/internal/ai/patrol_init.go
@@ -138,6 +138,8 @@ type PatrolConfig struct {
AnalyzeHosts bool `json:"analyze_hosts"`
// AnalyzeKubernetes controls whether to analyze Kubernetes clusters
AnalyzeKubernetes bool `json:"analyze_kubernetes"`
+ // AnalyzePMG controls whether to analyze Proxmox Mail Gateway instances
+ AnalyzePMG bool `json:"analyze_pmg"`
}
// GetInterval returns the effective patrol interval, handling migration from old config
@@ -165,6 +167,7 @@ func DefaultPatrolConfig() PatrolConfig {
AnalyzePBS: true,
AnalyzeHosts: true,
AnalyzeKubernetes: true,
+ AnalyzePMG: true,
}
}
diff --git a/internal/ai/patrol_run.go b/internal/ai/patrol_run.go
index e8e6cb172f..fc2ac9bc34 100644
--- a/internal/ai/patrol_run.go
+++ b/internal/ai/patrol_run.go
@@ -228,6 +228,7 @@ func (p *PatrolService) runPatrolWithTrigger(ctx context.Context, trigger Trigge
storageChecked int
hostsChecked int
pbsChecked int
+ pmgChecked int
kubernetesChecked int
newFindings int
existingFindings int
@@ -284,6 +285,9 @@ func (p *PatrolService) runPatrolWithTrigger(ctx context.Context, trigger Trigge
if cfg.AnalyzePBS {
runStats.pbsChecked = len(state.PBSInstances)
}
+ if cfg.AnalyzePMG {
+ runStats.pmgChecked = len(state.PMGInstances)
+ }
if cfg.AnalyzeHosts {
runStats.hostsChecked = len(state.Hosts)
}
@@ -291,7 +295,7 @@ func (p *PatrolService) runPatrolWithTrigger(ctx context.Context, trigger Trigge
runStats.kubernetesChecked = len(state.KubernetesClusters)
}
runStats.resourceCount = runStats.nodesChecked + runStats.guestsChecked +
- runStats.dockerChecked + runStats.storageChecked + runStats.pbsChecked + runStats.hostsChecked +
+ runStats.dockerChecked + runStats.storageChecked + runStats.pbsChecked + runStats.pmgChecked + runStats.hostsChecked +
runStats.kubernetesChecked
// Determine if we can run LLM analysis (requires AI service + circuit breaker not open)
@@ -479,6 +483,7 @@ func (p *PatrolService) runPatrolWithTrigger(ctx context.Context, trigger Trigge
StorageChecked: runStats.storageChecked,
HostsChecked: runStats.hostsChecked,
PBSChecked: runStats.pbsChecked,
+ PMGChecked: runStats.pmgChecked,
KubernetesChecked: runStats.kubernetesChecked,
NewFindings: runStats.newFindings,
ExistingFindings: runStats.existingFindings,
@@ -608,6 +613,7 @@ func (p *PatrolService) runScopedPatrol(ctx context.Context, scope PatrolScope)
storageChecked int
hostsChecked int
pbsChecked int
+ pmgChecked int
kubernetesChecked int
newFindings int
existingFindings int
@@ -651,6 +657,9 @@ func (p *PatrolService) runScopedPatrol(ctx context.Context, scope PatrolScope)
if cfg.AnalyzeKubernetes {
resourceCount += len(filteredState.KubernetesClusters)
}
+ if cfg.AnalyzePMG {
+ resourceCount += len(filteredState.PMGInstances)
+ }
if resourceCount == 0 {
log.Debug().
@@ -687,6 +696,9 @@ func (p *PatrolService) runScopedPatrol(ctx context.Context, scope PatrolScope)
if cfg.AnalyzeKubernetes {
runStats.kubernetesChecked = len(filteredState.KubernetesClusters)
}
+ if cfg.AnalyzePMG {
+ runStats.pmgChecked = len(filteredState.PMGInstances)
+ }
runStats.resourceCount = resourceCount
// Determine if we can run LLM analysis
@@ -782,6 +794,7 @@ func (p *PatrolService) runScopedPatrol(ctx context.Context, scope PatrolScope)
StorageChecked: runStats.storageChecked,
HostsChecked: runStats.hostsChecked,
PBSChecked: runStats.pbsChecked,
+ PMGChecked: runStats.pmgChecked,
KubernetesChecked: runStats.kubernetesChecked,
NewFindings: runStats.newFindings,
ExistingFindings: runStats.existingFindings,