Module: check_mk
Branch: master
Commit: 5b49273efc1968aca5afe3f6f85faac15b6fd337
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5b49273efc1968…
Author: Moritz Kiemer <mo(a)mathias-kettner.de>
Date: Sat Mar 23 13:41:57 2019 +0100
7223 FIX db2_tablespaces: Occasionally wrong CRIT state
In some cases the state of the check went to CRIT, although the
reported values where fine.
Avoid using the reported 'free' variable to guarante consistency
between info text and state.
Change-Id: If5d54019118dad4a5903e1dfc6865f21547b2c48
---
.werks/7223 | 12 ++++++++++++
checks/db2_tablespaces | 18 ++++++++++--------
2 files changed, 22 insertions(+), 8 deletions(-)
diff --git a/.werks/7223 b/.werks/7223
new file mode 100644
index 0000000..027dca8
--- /dev/null
+++ b/.werks/7223
@@ -0,0 +1,12 @@
+Title: db2_tablespaces: Occasionally wrong CRIT state
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.6.0i1
+Date: 1553344784
+Class: fix
+
+In some cases the state of the check went to CRIT, although the
+reported values where fine.
+
diff --git a/checks/db2_tablespaces b/checks/db2_tablespaces
index a21f51a..3ef95e5 100644
--- a/checks/db2_tablespaces
+++ b/checks/db2_tablespaces
@@ -84,27 +84,29 @@ def check_db2_tablespaces(item, params, parsed):
if tbsp_type == "SMS":
usable = free # for SMS free size is the amount of disk space available to the
db file
- perc_free = 100.0 - used / usable * 100.0
warn, crit, levels_text, as_perc = db_get_tablespace_levels_in_bytes(usable, params)
+ infotext = "%s of %s used" % (get_bytes_human_readable(used),
get_bytes_human_readable(usable))
perfdata = [("tablespace_size", usable, max(0, total - (warn or 0)), max(
0, total - (crit or 0))), ("tablespace_used", used),
("tablespace_max_size", total)]
+ yield 0, infotext, perfdata
- yield 0, "%s of %s used" % (get_bytes_human_readable(used),
get_bytes_human_readable(usable))
- yield 0, "s% free" % get_percent_human_readable(perc_free), perfdata
+ perc_free = 100.0 - used / usable * 100.0
+ abs_free = usable - used
state = 0
- if crit and free <= crit:
+ infotext = "%s free" % get_percent_human_readable(perc_free)
+ if crit is not None and abs_free <= crit:
state = 2
- elif warn and free <= warn:
+ elif warn is not None and abs_free <= warn:
state = 1
if state:
if as_perc:
value_str = get_percent_human_readable(perc_free)
else:
- # TODO: check if "used" is correct (should't it be
"free"?)
- value_str = get_bytes_human_readable(used)
- yield state, "only %s left %s" % (value_str, levels_text)
+ value_str = get_bytes_human_readable(abs_free)
+ infotext = "only %s left %s" % (value_str, levels_text)
+ yield state, infotext
yield tbsp_state.lower() != "normal" and 1 or 0, "State: %s" %
tbsp_state
yield 0, "Type: %s" % tbsp_type