Module: check_mk
Branch: master
Commit: cee58e34da855a34165d9fe5352979fe57ed6143
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=cee58e34da855a…
Author: Moritz Kiemer <mo(a)mathias-kettner.de>
Date: Sat Mar 23 13:04:55 2019 +0100
db2_tablespaces: re-arrange yields and refactor
Change-Id: Id4d1f8bc4dde5f6218ad7d7f62da7f69a8206b93
---
checks/db2_tablespaces | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/checks/db2_tablespaces b/checks/db2_tablespaces
index 8e111f7..a21f51a 100644
--- a/checks/db2_tablespaces
+++ b/checks/db2_tablespaces
@@ -89,15 +89,22 @@ def check_db2_tablespaces(item, params, parsed):
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, "%.1f%% free" % perc_free, 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
+
+ state = 0
if crit and free <= crit:
- yield 2, "only %s left %s" % (as_perc and ("%.1f%%" %
perc_free) or \
- get_bytes_human_readable(used), levels_text)
+ state = 2
elif warn and free <= warn:
- yield 1, "only %s left %s" % (as_perc and ("%.1f%%" %
perc_free) or \
- get_bytes_human_readable(used), levels_text)
- yield 0, "%s of %s used" % (get_bytes_human_readable(used),
get_bytes_human_readable(usable))
+ 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)
yield tbsp_state.lower() != "normal" and 1 or 0, "State: %s" %
tbsp_state
yield 0, "Type: %s" % tbsp_type