diff options
| author | Paul Buetow <paul@buetow.org> | 2023-04-22 14:43:56 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2023-04-22 14:43:56 +0300 |
| commit | 64daf1a2849d8ed239912a6d0f46e95bee194713 (patch) | |
| tree | 1bde499208c1bae00ec1391096f2ec16b13c3c4b | |
| parent | 06319fdbbbd49201ea4632f10d77bb3231321500 (diff) | |
dont show status change for unhandled report
| -rw-r--r-- | internal/state.go | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/internal/state.go b/internal/state.go index d318ca9..aaa54e9 100644 --- a/internal/state.go +++ b/internal/state.go @@ -105,25 +105,25 @@ func (s state) report(renotify bool) (string, string, bool) { } func (s state) reportChanged(sb *strings.Builder) (changed bool) { - if 0 < s.reportBy(sb, func(cs checkState) bool { + if 0 < s.reportBy(sb, true, func(cs checkState) bool { return cs.Status == critical && cs.changed() }) { changed = true } - if 0 < s.reportBy(sb, func(cs checkState) bool { + if 0 < s.reportBy(sb, true, func(cs checkState) bool { return cs.Status == warning && cs.changed() }) { changed = true } - if 0 < s.reportBy(sb, func(cs checkState) bool { + if 0 < s.reportBy(sb, true, func(cs checkState) bool { return cs.Status == unknown && cs.changed() }) { changed = true } - if 0 < s.reportBy(sb, func(cs checkState) bool { + if 0 < s.reportBy(sb, true, func(cs checkState) bool { return cs.Status == ok && cs.changed() }) { changed = true @@ -135,15 +135,15 @@ func (s state) reportChanged(sb *strings.Builder) (changed bool) { func (s state) reportUnhandled(sb *strings.Builder) (numCriticals, numWarnings, numUnknown, numOK int) { - numCriticals = s.reportBy(sb, func(cs checkState) bool { return cs.Status == critical }) - numWarnings = s.reportBy(sb, func(cs checkState) bool { return cs.Status == warning }) - numUnknown = s.reportBy(sb, func(cs checkState) bool { return cs.Status == unknown }) + numCriticals = s.reportBy(sb, false, func(cs checkState) bool { return cs.Status == critical }) + numWarnings = s.reportBy(sb, false, func(cs checkState) bool { return cs.Status == warning }) + numUnknown = s.reportBy(sb, false, func(cs checkState) bool { return cs.Status == unknown }) numOK = s.countBy(func(cs checkState) bool { return cs.Status == ok }) return } -func (s state) reportBy(sb *strings.Builder, +func (s state) reportBy(sb *strings.Builder, showStatusChange bool, filter func(cs checkState) bool) (count int) { for name, cs := range s.checks { @@ -152,7 +152,7 @@ func (s state) reportBy(sb *strings.Builder, } count++ - if cs.changed() { + if showStatusChange && cs.changed() { sb.WriteString(nagiosCode(cs.PrevStatus).Str()) sb.WriteString("->") } |
