From 00d8b2eec47830423cc39c0b2dc403ecd1b1273b Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Wed, 28 May 2025 22:02:18 +0300 Subject: fix unknown handling --- internal/check.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'internal') diff --git a/internal/check.go b/internal/check.go index d762b66..189f417 100644 --- a/internal/check.go +++ b/internal/check.go @@ -43,7 +43,13 @@ func (c check) run(ctx context.Context, name string) checkResult { parts := strings.Split(bytes.String(), "|") output := strings.TrimSpace(parts[0]) - return checkResult{name, output, nagiosCode(cmd.ProcessState.ExitCode())} + ec := cmd.ProcessState.ExitCode() + if ec < int(nagiosOk) || ec > int(nagiosUnknown) { + // If the exit code is not in the range of known Nagios codes, treat it as unknown + ec = int(nagiosUnknown) + } + + return checkResult{name, output, nagiosCode(ec)} } func (c check) skip(name, output string) checkResult { -- cgit v1.2.3