From 0cf8c8d99485ab06b09e7ddf92a0dc2cd4da97d5 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 22 Apr 2023 22:29:35 +0300 Subject: print out when there were no status changes or there are no unhandled alerts" --- internal/state.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'internal') diff --git a/internal/state.go b/internal/state.go index aaa54e9..3ac8e7d 100644 --- a/internal/state.go +++ b/internal/state.go @@ -92,16 +92,23 @@ func (s state) report(renotify bool) (string, string, bool) { sb.WriteString("# Alerts with status changed:\n\n") changed := s.reportChanged(&sb) + if !changed { + sb.WriteString("There were no status changes...\n\n") + } sb.WriteString("# Unhandled alerts:\n\n") numCriticals, numWarnings, numUnknown, numOK := s.reportUnhandled(&sb) + hasUnhandled := (numCriticals + numWarnings + numUnknown) > 0 + if !hasUnhandled { + sb.WriteString("There are no unhandled alerts...\n\n") + } sb.WriteString("Have a nice day!\n") subject := fmt.Sprintf("GOGIOS Report [C:%d W:%d U:%d OK:%d]", numCriticals, numWarnings, numUnknown, numOK) - return subject, sb.String(), changed || (renotify && (numCriticals+numWarnings+numUnknown) > 0) + return subject, sb.String(), changed || (renotify && hasUnhandled) } func (s state) reportChanged(sb *strings.Builder) (changed bool) { @@ -160,7 +167,7 @@ func (s state) reportBy(sb *strings.Builder, showStatusChange bool, sb.WriteString(nagiosCode(cs.Status).Str()) sb.WriteString(": ") sb.WriteString(name) - sb.WriteString(" ==>> ") + sb.WriteString(": ") sb.WriteString(cs.output) sb.WriteString("\n") } -- cgit v1.2.3