summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-01-18 16:39:11 +0200
committerPaul Buetow <paul@buetow.org>2026-01-18 16:42:13 +0200
commit1f20bed4e77d2238e2b613b060fd05adb58ba116 (patch)
tree2478c9ad15d37c6ee092890478af55990ab4e56c
parent6d6ab671dbb600e790853ca1ab02046807f19b9c (diff)
exclude OK status from stale alerts report
Stale OK alerts are not concerning and shouldn't clutter the stale alerts section. Only report stale alerts with warning/critical/unknown status. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
-rw-r--r--internal/html.go9
-rw-r--r--internal/state.go3
2 files changed, 7 insertions, 5 deletions
diff --git a/internal/html.go b/internal/html.go
index 753a5b0..1ccb894 100644
--- a/internal/html.go
+++ b/internal/html.go
@@ -173,10 +173,11 @@ func (s state) htmlReportUnhandledContent(sb *strings.Builder) {
}
// htmlReportStaleAlerts generates HTML for stale checks.
-// Mirrors state.reportStaleAlerts() from state.go:216-220.
+// Only reports stale alerts that are not OK, since stale OK alerts aren't concerning.
+// Mirrors state.reportStaleAlerts() from state.go.
func (s state) htmlReportStaleAlerts(sb *strings.Builder) int {
return s.htmlReportBy(sb, false, true, func(cs checkState) bool {
- return cs.Epoch < s.staleEpoch
+ return cs.Epoch < s.staleEpoch && cs.Status != nagiosOk
})
}
@@ -228,11 +229,11 @@ func (s state) htmlReportBy(sb *strings.Builder, showStatusChange, isStaleReport
return
}
-// countStale counts the number of stale checks.
+// countStale counts the number of stale checks (excluding OK status).
// Helper function for generating summary counts.
func (s state) countStale() int {
return s.countBy(func(cs checkState) bool {
- return cs.Epoch < s.staleEpoch
+ return cs.Epoch < s.staleEpoch && cs.Status != nagiosOk
})
}
diff --git a/internal/state.go b/internal/state.go
index d71c71c..516e63a 100644
--- a/internal/state.go
+++ b/internal/state.go
@@ -214,8 +214,9 @@ func (s state) reportUnhandled(sb *strings.Builder) (numCriticals, numWarnings,
}
func (s state) reportStaleAlerts(sb *strings.Builder) int {
+ // Only report stale alerts that are not OK, since stale OK alerts aren't concerning
return s.reportBy(sb, false, true, func(cs checkState) bool {
- return cs.Epoch < s.staleEpoch
+ return cs.Epoch < s.staleEpoch && cs.Status != nagiosOk
})
}