Module: check_mk
Branch: master
Commit: dc77fc89e3998fa8680609aea56ab2bb3c39289a
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=dc77fc89e3998f…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Tue Jun 26 10:08:22 2018 +0200
6142 FIX qnap_disks: Fixed undetected error if SMART information is missing
Change-Id: Ia6c16ed530b01ce6273f37b040971e6e777ee9e2
---
.werks/6142 | 10 ++++++++++
checks/qnap_disks | 26 +++++++++++++++++++-------
2 files changed, 29 insertions(+), 7 deletions(-)
diff --git a/.werks/6142 b/.werks/6142
new file mode 100644
index 0000000..d0af018
--- /dev/null
+++ b/.werks/6142
@@ -0,0 +1,10 @@
+Title: qnap_disks: Fixed undetected error if SMART information is missing
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.6.0i1
+Date: 1530000435
+Class: fix
+
+
diff --git a/checks/qnap_disks b/checks/qnap_disks
index 79bc311..ab6dda9 100644
--- a/checks/qnap_disks
+++ b/checks/qnap_disks
@@ -24,18 +24,31 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
+
def inventory_qnap_disks(info):
return [ (x[0], None) for x in info if x[2] != "-5"]
+
def check_qnap_disks(item, _no_params, info):
+ map_states = {
+ "0" : (0, "ready"),
+ "-4": (2, "unknown"),
+ "-5": (2, "no disk"),
+ "-6": (2, "invalid"),
+ "-9": (2, "read write error"),
+ }
+
for desc, temp, status, model, size, cond in info:
if desc == item:
- msg = "Model: %s, Temperatur: %s, Size: %s" % \
- ( model, temp, size )
- if int(status) != 0:
- return 2, "Status: %s (Code: %s) %s" % ( cond, status, msg)
- return 0, msg
- return 3, "Disk not longer found in output"
+ state, state_readable = map_states.get(status, (3, "unknown"))
+ yield state, "Status: %s (%s)" % (state_readable, cond)
+
+ if "--" in cond:
+ yield 1, "SMART Information missing"
+
+ yield 0 , "Model: %s, Temperatur: %s, Size: %s" % \
+ (model, temp, size)
+
check_info["qnap_disks"] = {
"check_function" : check_qnap_disks,
@@ -52,4 +65,3 @@ check_info["qnap_disks"] = {
"snmp_scan_function" : lambda oid:
oid('.1.3.6.1.2.1.1.1.0').startswith('Linux TS-') \
or
oid('.1.3.6.1.2.1.1.1.0').startswith('NAS QR802')
}
-