Module: check_mk
Branch: master
Commit: b7229afe04206f53552986c5def53834b17f0c32
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b7229afe04206f…
Author: Marcel Arentz <ma(a)mathias-kettner.de>
Date: Fri May 5 13:32:50 2017 +0200
4641 FIX mysql_capacity: Fixed crash if schema contains spaces
Change-Id: I7ba3fce4413c3531960b2f4cd6df3714f77f619a
---
.werks/4641 | 10 ++++++++++
checks/mysql_capacity | 14 +++++++++++---
2 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/.werks/4641 b/.werks/4641
new file mode 100644
index 0000000..35b6f5f
--- /dev/null
+++ b/.werks/4641
@@ -0,0 +1,10 @@
+Title: mysql_capacity: Fixed crash if schema contains spaces
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.5.0i1
+Date: 1493983948
+Class: fix
+
+
diff --git a/checks/mysql_capacity b/checks/mysql_capacity
index c17e63d..ed64d87 100644
--- a/checks/mysql_capacity
+++ b/checks/mysql_capacity
@@ -63,7 +63,11 @@ def parse_mysql_capacity(info):
def inventory_mysql_size(parsed):
for instance, values in parsed.items():
- for dbname, used, avail in values:
+ for line in values:
+ dbname = " ".join(line[:-2])
+ used = line[-2]
+ avail = line[-1]
+
if dbname not in [ "information_schema", "mysql",
"performance_schema" ] \
and used != 'NULL' and avail != 'NULL':
yield "%s:%s" % (instance, dbname), None
@@ -80,7 +84,11 @@ def check_mysql_size(item, params, parsed):
dbs = parsed[instance]
# size and avail are given as bytes
- for db, size, avail in dbs:
+ for line in dbs:
+ db = " ".join(line[:-2])
+ size = line[-2]
+ avail = line[-1]
+
if db == dbname:
if size == 'NULL':
return 3, "Missing information - Size is reported as
'NULL'"
@@ -92,7 +100,7 @@ def check_mysql_size(item, params, parsed):
warn_b = warn * 1024
crit_b = crit * 1024
perfdata = [("database_size", size, warn_b, crit_b)]
- if size > crit_b:
+ if size > crit_b:
state = 2
infotext += " (critical at %s)" %
get_bytes_human_readable(crit_b)
elif size > warn_b: