From aeab0f0e48ee164d12d75fed6ec7720babf52222 Mon Sep 17 00:00:00 2001
From: Thomas Bellman <bellman@lysator.liu.se>
Date: Thu, 3 Jan 2019 09:00:06 +0100
Subject: [PATCH] nagios_report(): Fix exit code for empty statuses.

When the statuses parameter to the nagios_report() function in
trh_nagioslib is empty, we try to return UNKNOWN as the exit code.
However, we apparently had a brainfart and added one to the value
the .index() method gave us searching the NAGIOSCODES variable.
That's just incorrect; the position of the names in NAGIOSCODES
*is* the right exit code, no offset needed.  Fix that.
---
 trh_nagioslib.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/trh_nagioslib.py b/trh_nagioslib.py
index d9f4d40..8eb5661 100644
--- a/trh_nagioslib.py
+++ b/trh_nagioslib.py
@@ -247,7 +247,7 @@ def nagios_report(statuses):
             message += st + ": " + msg + "\n"
 
     if max_level < 0:
-        max_level = NAGIOSCODES.index('UNKNOWN') + 1
+        max_level = NAGIOSCODES.index('UNKNOWN')
         message = "UNKNOWN: No status report\n"
 
     return max_level, message
-- 
GitLab