From 820b4e6c483734ba1d57ecdd28838657d18b3159 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Thu, 22 Jan 2026 09:44:59 +0200 Subject: fix OK checks incorrectly shown in suppressed section OK checks should appear in "OK checks" section, not "Suppressed alerts". Suppression now only applies to non-OK checks (Critical, Warning, Unknown). Co-Authored-By: Claude Opus 4.5 --- internal/html.go | 16 +++++++++------- internal/state.go | 21 ++++++++++++--------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/internal/html.go b/internal/html.go index e2843db..71f17e4 100644 --- a/internal/html.go +++ b/internal/html.go @@ -194,11 +194,12 @@ func (s state) htmlReportStaleAlerts(sb *strings.Builder, conf config) int { } // htmlReportSuppressed generates HTML for suppressed checks. -// Shows which checks are currently muted via OnlyIfNotExists for visibility. +// Shows which non-OK checks are currently muted via OnlyIfNotExists for visibility. +// OK checks are never shown as suppressed since there's nothing to suppress. func (s state) htmlReportSuppressed(sb *strings.Builder, conf config) (count int) { for name, cs := range s.checks { - if !isCheckSuppressed(name, conf) { - continue + if cs.Status == nagiosOk || !isCheckSuppressed(name, conf) { + continue // OK checks are never shown as suppressed } count++ @@ -219,10 +220,11 @@ func (s state) htmlReportSuppressed(sb *strings.Builder, conf config) (count int return } -// countSuppressed counts the number of suppressed checks. +// countSuppressed counts the number of suppressed non-OK checks. +// OK checks are never counted as suppressed since there's nothing to suppress. func (s state) countSuppressed(conf config) (count int) { for name := range s.checks { - if isCheckSuppressed(name, conf) { + if s.checks[name].Status != nagiosOk && isCheckSuppressed(name, conf) { count++ } } @@ -242,8 +244,8 @@ func (s state) htmlReportBy(sb *strings.Builder, showStatusChange, isStaleReport if !isStaleReport && cs.Epoch < s.staleEpoch { continue // skip stale checks in non-stale report } - if isCheckSuppressed(name, conf) { - continue // skip suppressed checks + if cs.Status != nagiosOk && isCheckSuppressed(name, conf) { + continue // skip suppressed checks (OK checks are never suppressed) } count++ diff --git a/internal/state.go b/internal/state.go index 4df7757..9deb178 100644 --- a/internal/state.go +++ b/internal/state.go @@ -233,12 +233,13 @@ func (s state) reportStaleAlerts(sb *strings.Builder, conf config) int { }) } -// reportSuppressed lists all checks that are currently suppressed via OnlyIfNotExists. +// reportSuppressed lists all non-OK checks that are currently suppressed via OnlyIfNotExists. // This provides visibility into which alerts are being muted during maintenance windows. +// OK checks are never shown as suppressed since there's nothing to suppress. func (s state) reportSuppressed(sb *strings.Builder, conf config) (count int) { for name, cs := range s.checks { - if !isCheckSuppressed(name, conf) { - continue + if cs.Status == nagiosOk || !isCheckSuppressed(name, conf) { + continue // OK checks are never shown as suppressed } count++ @@ -263,7 +264,8 @@ func (s state) reportSuppressed(sb *strings.Builder, conf config) (count int) { } // reportBy iterates over checks matching the filter and writes them to sb. -// Checks that are suppressed via OnlyIfNotExists are excluded from the report. +// Non-OK checks that are suppressed via OnlyIfNotExists are excluded from the report. +// OK checks are never suppressed since there's nothing to suppress. func (s state) reportBy(sb *strings.Builder, showStatusChange, isStaleReport bool, conf config, filter func(cs checkState) bool, ) (count int) { @@ -274,8 +276,8 @@ func (s state) reportBy(sb *strings.Builder, showStatusChange, isStaleReport boo if !isStaleReport && cs.Epoch < s.staleEpoch { continue // skip stale checks in non-stale report } - if isCheckSuppressed(name, conf) { - continue // skip suppressed checks + if cs.Status != nagiosOk && isCheckSuppressed(name, conf) { + continue // skip suppressed checks (OK checks are never suppressed) } count++ @@ -309,11 +311,12 @@ func (s state) reportBy(sb *strings.Builder, showStatusChange, isStaleReport boo return } -// countBy counts checks matching the filter, excluding suppressed checks. +// countBy counts checks matching the filter, excluding suppressed non-OK checks. +// OK checks are never suppressed since there's nothing to suppress. func (s state) countBy(conf config, filter func(cs checkState) bool) (count int) { for name, cs := range s.checks { - if isCheckSuppressed(name, conf) { - continue // skip suppressed checks + if cs.Status != nagiosOk && isCheckSuppressed(name, conf) { + continue // skip suppressed checks (OK checks are never suppressed) } if filter(cs) { count++ -- cgit v1.2.3