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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Cover pbsPollingInterval in the live polling-cadence setters
[email protected]df72955144b6
diff --git a/internal/api/system_settings.go b/internal/api/system_settings.goindex 4daf68e9d6..37d5555fb5 100644--- a/internal/api/system_settings.go+++ b/internal/api/system_settings.go@@ -35,6 +35,7 @@ type SystemSettingsMonitor interface {GetNotificationManager() *notifications.NotificationManagerSetBackupPollingEnabled(enabled bool)SetBackupPollingInterval(interval time.Duration)+ SetPBSPollingInterval(interval time.Duration)SetPMGPollingInterval(interval time.Duration)}@@ -1028,6 +1029,9 @@ func (h *SystemSettingsHandler) HandleUpdateSystemSettings(w http.ResponseWriterif settings.ConnectionTimeout > 0 {h.config.ConnectionTimeout = time.Duration(settings.ConnectionTimeout) * time.Second}+ if settings.PBSPollingInterval > 0 {+ h.config.PBSPollingInterval = time.Duration(settings.PBSPollingInterval) * time.Second+ }if settings.PMGPollingInterval > 0 {h.config.PMGPollingInterval = time.Duration(settings.PMGPollingInterval) * time.Second}@@ -1128,6 +1132,12 @@ func (h *SystemSettingsHandler) HandleUpdateSystemSettings(w http.ResponseWriterm.SetBackupPollingInterval(interval)})}+ if _, ok := rawRequest["pbsPollingInterval"]; ok && settings.PBSPollingInterval > 0 {+ interval := time.Duration(settings.PBSPollingInterval) * time.Second+ h.forEachTenantMonitor(r, func(m SystemSettingsMonitor) {+ m.SetPBSPollingInterval(interval)+ })+ }if _, ok := rawRequest["pmgPollingInterval"]; ok && settings.PMGPollingInterval > 0 {interval := time.Duration(settings.PMGPollingInterval) * time.Secondh.forEachTenantMonitor(r, func(m SystemSettingsMonitor) {diff --git a/internal/api/system_settings_handlers_test.go b/internal/api/system_settings_handlers_test.goindex db9be5df6b..33f69f35a5 100644--- a/internal/api/system_settings_handlers_test.go+++ b/internal/api/system_settings_handlers_test.go@@ -24,6 +24,7 @@ import (type mockMonitor struct {backupPollingEnabledCalls []boolbackupPollingIntervalCalls []time.Duration+ pbsPollingIntervalCalls []time.DurationpmgPollingIntervalCalls []time.Duration}@@ -40,6 +41,9 @@ func (m *mockMonitor) SetBackupPollingEnabled(enabled bool) {func (m *mockMonitor) SetBackupPollingInterval(interval time.Duration) {m.backupPollingIntervalCalls = append(m.backupPollingIntervalCalls, interval)}+func (m *mockMonitor) SetPBSPollingInterval(interval time.Duration) {+ m.pbsPollingIntervalCalls = append(m.pbsPollingIntervalCalls, interval)+}func (m *mockMonitor) SetPMGPollingInterval(interval time.Duration) {m.pmgPollingIntervalCalls = append(m.pmgPollingIntervalCalls, interval)}@@ -275,10 +279,11 @@ func TestHandleUpdateSystemSettings_Basic(t *testing.T) {}}-// Regression test for #1619: backupPollingInterval, pmgPollingInterval and-// backupPollingEnabled must be pushed into live monitors on save. Mutating-// h.config alone never reaches a running monitor (each polls a detached-// config copy), and these settings do not trigger a monitor reload.+// Regression test for #1619: backupPollingInterval, pbsPollingInterval,+// pmgPollingInterval and backupPollingEnabled must be pushed into live+// monitors on save. Mutating h.config alone never reaches a running monitor+// (each polls a detached config copy), and these settings do not trigger a+// monitor reload.func TestHandleUpdateSystemSettings_PollingCadencePushedToLiveMonitors(t *testing.T) {tempDir := t.TempDir()cfg := &config.Config{@@ -286,6 +291,7 @@ func TestHandleUpdateSystemSettings_PollingCadencePushedToLiveMonitors(t *testinConfigPath: tempDir,EnableBackupPolling: true,BackupPollingInterval: time.Hour,+ PBSPollingInterval: time.Minute,PMGPollingInterval: time.Minute,}persistence := config.NewConfigPersistence(tempDir)@@ -303,6 +309,7 @@ func TestHandleUpdateSystemSettings_PollingCadencePushedToLiveMonitors(t *testinupdates := map[string]interface{}{"backupPollingInterval": 600,+ "pbsPollingInterval": 90,"pmgPollingInterval": 120,"backupPollingEnabled": false,}@@ -321,6 +328,9 @@ func TestHandleUpdateSystemSettings_PollingCadencePushedToLiveMonitors(t *testinif len(monitor.backupPollingIntervalCalls) != 1 || monitor.backupPollingIntervalCalls[0] != 600*time.Second {t.Errorf("expected SetBackupPollingInterval(600s) on live monitor, got %v", monitor.backupPollingIntervalCalls)}+ if len(monitor.pbsPollingIntervalCalls) != 1 || monitor.pbsPollingIntervalCalls[0] != 90*time.Second {+ t.Errorf("expected SetPBSPollingInterval(90s) on live monitor, got %v", monitor.pbsPollingIntervalCalls)+ }if len(monitor.pmgPollingIntervalCalls) != 1 || monitor.pmgPollingIntervalCalls[0] != 120*time.Second {t.Errorf("expected SetPMGPollingInterval(120s) on live monitor, got %v", monitor.pmgPollingIntervalCalls)}@@ -335,6 +345,9 @@ func TestHandleUpdateSystemSettings_PollingCadencePushedToLiveMonitors(t *testinif cfg.BackupPollingInterval != 600*time.Second {t.Errorf("expected base config BackupPollingInterval 600s, got %v", cfg.BackupPollingInterval)}+ if cfg.PBSPollingInterval != 90*time.Second {+ t.Errorf("expected base config PBSPollingInterval 90s, got %v", cfg.PBSPollingInterval)+ }if cfg.PMGPollingInterval != 120*time.Second {t.Errorf("expected base config PMGPollingInterval 120s, got %v", cfg.PMGPollingInterval)}diff --git a/internal/monitoring/monitor.go b/internal/monitoring/monitor.goindex 698fc7be53..f11faaf521 100644--- a/internal/monitoring/monitor.go+++ b/internal/monitoring/monitor.go@@ -1109,6 +1109,7 @@ type Monitor struct {runtimePollingMu sync.RWMutex // Guards the polling-cadence overrides below; polling goroutines read them every cyclebackupPollingEnabledOverride *bool // Runtime override for config.EnableBackupPolling (nil = use config)backupPollingIntervalOverride *time.Duration // Runtime override for config.BackupPollingInterval (nil = use config)+ pbsPollingIntervalOverride *time.Duration // Runtime override for config.PBSPollingInterval (nil = use config)pmgPollingIntervalOverride *time.Duration // Runtime override for config.PMGPollingInterval (nil = use config)runtimeCtx context.Context // Context used while monitor is runningwsHub *websocket.Hub // Hub used for broadcasting state@@ -1956,7 +1957,7 @@ func (m *Monitor) baseIntervalForInstanceType(instanceType InstanceType) time.Ducase InstanceTypePVE:return m.effectivePVEPollingInterval()case InstanceTypePBS:- return clampInterval(m.config.PBSPollingInterval, 10*time.Second, time.Hour)+ return clampInterval(m.pbsPollingIntervalSetting(), 10*time.Second, time.Hour)case InstanceTypePMG:return clampInterval(m.pmgPollingIntervalSetting(), 10*time.Second, time.Hour)default:diff --git a/internal/monitoring/monitor_runtime_settings.go b/internal/monitoring/monitor_runtime_settings.goindex ec12c2e8c8..80d13f7b1f 100644--- a/internal/monitoring/monitor_runtime_settings.go+++ b/internal/monitoring/monitor_runtime_settings.go@@ -40,6 +40,21 @@ func (m *Monitor) backupPollingIntervalSetting() time.Duration {return m.config.BackupPollingInterval}+// pbsPollingIntervalSetting returns the effective PBSPollingInterval before+// clamping.+func (m *Monitor) pbsPollingIntervalSetting() time.Duration {+ if m == nil || m.config == nil {+ return 0+ }+ m.runtimePollingMu.RLock()+ override := m.pbsPollingIntervalOverride+ m.runtimePollingMu.RUnlock()+ if override != nil {+ return *override+ }+ return m.config.PBSPollingInterval+}+// pmgPollingIntervalSetting returns the effective PMGPollingInterval before// clamping.func (m *Monitor) pmgPollingIntervalSetting() time.Duration {@@ -104,6 +119,18 @@ func (m *Monitor) SetBackupPollingInterval(interval time.Duration) {}}+// SetPBSPollingInterval updates the PBS polling cadence on the live monitor.+// The scheduler re-reads the base interval every cycle, so no further action+// is needed.+func (m *Monitor) SetPBSPollingInterval(interval time.Duration) {+ if m == nil || interval <= 0 {+ return+ }+ m.runtimePollingMu.Lock()+ m.pbsPollingIntervalOverride = &interval+ m.runtimePollingMu.Unlock()+}+// SetPMGPollingInterval updates the PMG polling cadence on the live monitor.// The scheduler re-reads the base interval every cycle, so no further action// is needed.diff --git a/internal/monitoring/monitor_runtime_settings_test.go b/internal/monitoring/monitor_runtime_settings_test.goindex 7aaafb7eeb..23eabfea42 100644--- a/internal/monitoring/monitor_runtime_settings_test.go+++ b/internal/monitoring/monitor_runtime_settings_test.go@@ -91,6 +91,26 @@ func TestSetBackupPollingEnabledReachesLiveMonitor(t *testing.T) {}}+func TestSetPBSPollingIntervalReachesLiveMonitor(t *testing.T) {+ base := &config.Config{PBSPollingInterval: 2 * time.Minute}+ m := &Monitor{config: base.DeepCopy()}++ if got := m.baseIntervalForInstanceType(InstanceTypePBS); got != 2*time.Minute {+ t.Fatalf("expected 2m from config, got %v", got)+ }++ m.SetPBSPollingInterval(5 * time.Minute)+ if got := m.baseIntervalForInstanceType(InstanceTypePBS); got != 5*time.Minute {+ t.Fatalf("expected 5m after live update, got %v", got)+ }++ // Clamping still applies to live updates.+ m.SetPBSPollingInterval(2 * time.Hour)+ if got := m.baseIntervalForInstanceType(InstanceTypePBS); got != time.Hour {+ t.Fatalf("expected live update clamped to 1h, got %v", got)+ }+}+func TestSetPMGPollingIntervalReachesLiveMonitor(t *testing.T) {base := &config.Config{PMGPollingInterval: 2 * time.Minute}m := &Monitor{config: base.DeepCopy()}diff --git a/internal/monitoring/poll_providers.go b/internal/monitoring/poll_providers.goindex 16809d6de8..212e8a2b12 100644--- a/internal/monitoring/poll_providers.go+++ b/internal/monitoring/poll_providers.go@@ -386,7 +386,7 @@ func newPBSPollProvider() PollProvider {prefix: "pbs-",configInstances: pbsInstanceConfigs,clients: pbsClientMap,- pollingInterval: func(m *Monitor) time.Duration { return m.config.PBSPollingInterval },+ pollingInterval: func(m *Monitor) time.Duration { return m.pbsPollingIntervalSetting() },buildPollTask: func(m *Monitor, instanceName string) (PollTask, error) {if m == nil {return PollTask{}, fmt.Errorf("monitor is nil")