Improved error handling
Message-ID: <55101f32.bhIUCpfW+JdsOmDA%bk(a)mathias-kettner.de>
User-Agent: Heirloom mailx 12.5 6/20/10
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Module: check_mk
Branch: master
Commit: 083f848e2bf089b4e1c0878026e198ae7f06902d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=083f848e2bf089…
Author: Bastian Kuhn <bk(a)mathias-kettner.de>
Date: Mon Mar 23 15:11:52 2015 +0100
db2_counters, db2_sort_overflow: Improved error handling
---
checks/db2_counters | 7 ++++++-
checks/db2_sort_overflow | 5 ++++-
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/checks/db2_counters b/checks/db2_counters
index c90eba5..7eeae53 100644
--- a/checks/db2_counters
+++ b/checks/db2_counters
@@ -62,7 +62,12 @@ def check_db2_counters(item, params, parsed):
wrapped = False
for counter, label in db2_counters_map.items():
- value = float(db[counter])
+ try:
+ value = float(db[counter])
+ except ValueError:
+ yield 2, "Invalid value: " + db[counter]
+ continue
+
countername = "db2_counters.%s.%s" % (item, counter)
try:
rate = get_rate("db2_counters.%s.%s" % (item, counter), timestamp,
value, onwrap = RAISE)
diff --git a/checks/db2_sort_overflow b/checks/db2_sort_overflow
index bd647ed..24efefa 100644
--- a/checks/db2_sort_overflow
+++ b/checks/db2_sort_overflow
@@ -43,7 +43,10 @@ def check_db2_sort_overflow(item, params, parsed):
return
total, overflows = tuple(map(lambda x: float(x[-1]), db))
- overflow_perc = overflows * 100 / total
+ if total > 0:
+ overflow_perc = overflows * 100 / total
+ else:
+ overflow_perc = 0.0
warn, crit = params.get("levels_perc")
if overflow_perc >= crit:
yield 2, "%.1f%% sort overflow (leves at %.1f%%/%.1f%%)" % \