Module: check_mk
Branch: master
Commit: 18affd4e2c392d51d5154de5fed840a82009d099
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=18affd4e2c392d…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Mon Dec 12 10:48:07 2016 +0100
4112 FIX db2_logsizes: fixed invalid data handling
Change-Id: I259a66e4993cf296817502053145fe00b15f61fb
---
.werks/4112 | 10 ++++++++++
ChangeLog | 1 +
checks/db2_logsizes | 20 ++++++++++++++------
3 files changed, 25 insertions(+), 6 deletions(-)
diff --git a/.werks/4112 b/.werks/4112
new file mode 100644
index 0000000..5bbcb8e
--- /dev/null
+++ b/.werks/4112
@@ -0,0 +1,10 @@
+Title: db2_logsizes: fixed invalid data handling
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.4.0i3
+Date: 1481536045
+
+
diff --git a/ChangeLog b/ChangeLog
index 85e2f71..3152378 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -48,6 +48,7 @@
* 4099 FIX: msexch_rpcclientaccess: Previously nonfunctional WATO rule and default
parameters now work...
NOTE: Please refer to the migration notes!
* 4000 FIX: Windows Agent: fixed broken mrpe section...
+ * 4112 FIX: db2_logsizes: fixed invalid data handling
Multisite:
* 4070 Added a painter for the service check period
diff --git a/checks/db2_logsizes b/checks/db2_logsizes
index 6e8849b..c72f896 100644
--- a/checks/db2_logsizes
+++ b/checks/db2_logsizes
@@ -37,6 +37,7 @@ factory_settings["db2_logsizes_default_levels"] = {
}
def parse_db2_logsizes(info):
+ pprint.pprint(info)
pre_parsed = parse_db2_dbs(info)
global_timestamp = pre_parsed[0]
parsed = {}
@@ -46,8 +47,8 @@ def parse_db2_logsizes(info):
instance_info.setdefault(value[0], []).append(" ".join(map(str,
(value[1:]))))
# Some databases run in DPF mode. Means that the database is split over several
nodes
# Each node has its own logfile for the same database. We create one service for
each logfile
- if "TIMESTAMP" not in instance_info:
- instance_info["TIMESTAMP"] = [ global_timestamp ]
+ if "TIMESTAMP" not in instance_info:
+ instance_info["TIMESTAMP"] = [ global_timestamp ]
if "node" in instance_info:
for node in instance_info["node"]:
@@ -57,9 +58,12 @@ def parse_db2_logsizes(info):
return parsed
+
def inventory_db2_logsizes(parsed):
- for key in parsed:
- yield key, {}
+ for db, db_info in parsed.items():
+ if "logfilsiz" not in db_info:
+ yield db, {}
+
def check_db2_logsizes(item, params, parsed):
db = parsed.get(item)
@@ -88,8 +92,12 @@ def check_db2_logsizes(item, params, parsed):
data_offset = 0
timestamp = int(db["TIMESTAMP"][0])
- total = int(db["logfilsiz"][data_offset]) *
(int(db["logprimary"][data_offset])\
- + int(db["logsecond"][data_offset])) * 4096
+
+ if "logfilsiz" not in db:
+ return 3, "Invalid database info"
+
+ total = int(db["logfilsiz"][data_offset]) *
(int(db["logprimary"][data_offset]) + \
+ int(db["logsecond"][data_offset])) * 4096
free = total - int(db["usedspace"][data_offset])
return df_check_filesystem_single(g_hostname, item, total / 1024**2, free / 1024**2,
0,