Module: check_mk
Branch: master
Commit: ff8f8e5f783e0e05eb73add77042cec74d402506
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ff8f8e5f783e0e…
Author: Konstantin Büttner <kb(a)mathias-kettner.de>
Date: Thu Jun 8 15:50:52 2017 +0200
4800 FIX zpool: Enable check to handle variant output of zpool list command
Change-Id: Ic6c30af99962ec9aab0a30307c45388324639bb3
---
.werks/4800 | 11 +++++++++++
checks/zpool | 25 +++++++++++++++++++++----
2 files changed, 32 insertions(+), 4 deletions(-)
diff --git a/.werks/4800 b/.werks/4800
new file mode 100644
index 0000000..35676dd
--- /dev/null
+++ b/.werks/4800
@@ -0,0 +1,11 @@
+Title: zpool: Enable check to handle variant output of zpool list command
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.5.0i1
+Date: 1496929769
+
+
diff --git a/checks/zpool b/checks/zpool
index fc62178..2188f68 100644
--- a/checks/zpool
+++ b/checks/zpool
@@ -29,13 +29,30 @@
# app02 39.8G 14.1G 25.6G 35% ONLINE -
# rpool 39.8G 32.9G 6.81G 82% ONLINE -
+# Or also:
+# NAME SIZE USED AVAIL CAP HEALTH ALTROOT
+# sth_ds 278G 127G 151G 45% ONLINE -
+
+
def parse_zpool(info):
+
+ def canonize_header_entry(entry):
+ if entry == "used":
+ return "alloc"
+ elif entry == "avail":
+ return "free"
+ else:
+ return entry
+
result = {}
- header = [item.lower() for item in info[0]]
- for line in info[1:]:
- result[line[0]] = dict(zip(header, line))
- return result
+ if len(info) == 0:
+ return result
+ else:
+ header = [ canonize_header_entry(item.lower()) for item in info[0]]
+ for line in info[1:]:
+ result[line[0]] = dict(zip(header, line))
+ return result
def inventory_zpool(parsed):
return df_inventory(parsed.keys())