diff options
| author | Paul Buetow <paul@buetow.org> | 2025-05-28 22:02:18 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-05-28 22:02:18 +0300 |
| commit | 00d8b2eec47830423cc39c0b2dc403ecd1b1273b (patch) | |
| tree | 07a6c08324aa8d5783933e12716214b1adad711e /internal | |
| parent | 7bc06643e310d52c22c5ad757c8c5c6ae0422ebe (diff) | |
fix unknown handling
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/check.go | 8 |
1 files changed, 7 insertions, 1 deletions
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 { |
