Module: check_mk
Branch: master
Commit: c58efe5130a0e97fcae5f8a1898cc89d81ecd259
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c58efe5130a0e9…
Author: Konstantin Büttner <kb(a)mathias-kettner.de>
Date: Wed Nov 15 14:17:39 2017 +0100
5227 FIX Checkgroup humidity: Fix swapped lower levels and definition of only one kind of
levels
Previously, all checks of the checkgroup humidity would crash if only lower or only upper
levels
were configured. Lower levels configured in the GUI would be swapped in the check, ie the
warn level would be interpreted as the crit level and vice versa. This has been fixed.
Change-Id: I8de1a0654373790c31fd9031613425c312f349af
---
.werks/5227 | 13 +++++++++++++
checks/humidity.include | 28 +++++++++++++++-------------
2 files changed, 28 insertions(+), 13 deletions(-)
diff --git a/.werks/5227 b/.werks/5227
new file mode 100644
index 0000000..4ebf96c
--- /dev/null
+++ b/.werks/5227
@@ -0,0 +1,13 @@
+Title: Checkgroup humidity: Fix swapped lower levels and definition of only one kind of
levels
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.5.0i1
+Date: 1510751624
+
+Previously, all checks of the checkgroup humidity would crash if only lower or only upper
levels
+were configured. Lower levels configured in the GUI would be swapped in the check, ie
the
+warn level would be interpreted as the crit level and vice versa. This has been fixed.
diff --git a/checks/humidity.include b/checks/humidity.include
index 59a97ab..f9ae72a 100644
--- a/checks/humidity.include
+++ b/checks/humidity.include
@@ -34,37 +34,39 @@ def check_humidity(humidity, params):
}
elif type(params) in [ list, tuple ]:
params = {
- "levels_lower" : (params[0], params[1]),
+ "levels_lower" : (params[1], params[0]),
"levels" : (params[2], params[3]),
}
- crit_lower, warn_lower = params.get("levels_lower", [-1, -1])
- warn_upper, crit_upper = params.get("levels", [101, 101])
+ warn_lower, crit_lower = params.get("levels_lower", (None, None))
+ warn_upper, crit_upper = params.get("levels", (None, None))
perfdata = [ ("humidity", humidity, warn_upper, crit_upper, 0, 100) ]
infotext = get_percent_human_readable(humidity)
- levelstext_lower = " (warn/crit below %s/%s)" % (
- get_percent_human_readable(warn_lower),
- get_percent_human_readable(crit_lower))
- levelstext_upper = " (warn/crit at %s/%s)" % (
- get_percent_human_readable(warn_upper),
- get_percent_human_readable(crit_upper))
+ if warn_lower and crit_lower:
+ levelstext_lower = " (warn/crit below %s/%s)" % (
+ get_percent_human_readable(warn_lower),
+ get_percent_human_readable(crit_lower))
+ if warn_upper and crit_upper:
+ levelstext_upper = " (warn/crit at %s/%s)" % (
+ get_percent_human_readable(warn_upper),
+ get_percent_human_readable(crit_upper))
status = 0
levelstext = ""
- if humidity < crit_lower:
+ if crit_lower and humidity < crit_lower:
status = 2
levelstext = levelstext_lower
- elif humidity >= crit_upper:
+ elif crit_upper and humidity >= crit_upper:
status = 2
levelstext = levelstext_upper
- elif humidity < warn_lower:
+ elif warn_lower and humidity < warn_lower:
status = 1
levelstext = levelstext_lower
- elif humidity >= warn_upper:
+ elif warn_upper and humidity >= warn_upper:
status = 1
levelstext = levelstext_upper