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
perf: skip initial patrol if one ran recently
rcourtman8ee315eee4b7
diff --git a/internal/ai/patrol.go b/internal/ai/patrol.goindex b363c50158..911d917c34 100644--- a/internal/ai/patrol.go+++ b/internal/ai/patrol.go@@ -641,11 +641,28 @@ func (p *PatrolService) Stop() {// patrolLoop is the main background loopfunc (p *PatrolService) patrolLoop(ctx context.Context) {- // Run initial quick patrol shortly after startup+ // Run initial patrol shortly after startup, but only if one hasn't run recentlyinitialDelay := 30 * time.Secondselect {case <-time.After(initialDelay):- p.runPatrol(ctx)+ // Check if a patrol ran recently (within last hour) to avoid wasting tokens on restarts+ runHistory := p.GetRunHistory(1)++ skipInitial := false+ if len(runHistory) > 0 {+ lastRun := runHistory[0]+ timeSinceLastRun := time.Since(lastRun.CompletedAt)+ if timeSinceLastRun < 1*time.Hour {+ log.Info().+ Dur("time_since_last", timeSinceLastRun).+ Msg("AI Patrol: Skipping initial patrol - recent run exists")+ skipInitial = true+ }+ }++ if !skipInitial {+ p.runPatrol(ctx)+ }case <-p.stopCh:returncase <-ctx.Done():