Module: check_mk
Branch: master
Commit: fda56cc19971017c2f6b150f55c3537d491d93b0
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=fda56cc1997101…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Thu Jan 17 15:45:34 2019 +0100
7010 quantum_libsmall_status: Supports Quantum Tape Library which provides SNMP table
.1.3.6.1.4.1.3764
Change-Id: I902bac18cf73e4ea20f58ca4e5a9fca63ecf696c
---
.werks/7010 | 10 +++
checks/quantum_libsmall_status | 85 +++++++++++++---------
.../quantum_libsmall_status_12_regression.py | 29 ++++++++
.../quantum_libsmall_status_15_regression.py | 29 ++++++++
4 files changed, 119 insertions(+), 34 deletions(-)
diff --git a/.werks/7010 b/.werks/7010
new file mode 100644
index 0000000..dc60d9c
--- /dev/null
+++ b/.werks/7010
@@ -0,0 +1,10 @@
+Title: quantum_libsmall_status: Supports Quantum Tape Library which provides SNMP table
.1.3.6.1.4.1.3764
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.6.0i1
+Date: 1547736134
+Class: feature
+
+
diff --git a/checks/quantum_libsmall_status b/checks/quantum_libsmall_status
index ead4534..4adb2ce 100644
--- a/checks/quantum_libsmall_status
+++ b/checks/quantum_libsmall_status
@@ -24,55 +24,72 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
+DEVICE_TYPE_MAP = {
+ "1": "Power",
+ "2": "Cooling",
+ "3": "Control",
+ "4": "Connectivity",
+ "5": "Robotics",
+ "6": "Media",
+ "7": "Drive",
+ "8": "Operator action request",
+}
-def inventory_quantum_libsmall_status(info):
- if info:
- return [(None, None)]
+RAS_STATUS_MAP = {
+ "1": (0, "good"),
+ "2": (2, "failed"),
+ "3": (2, "degraded"),
+ "4": (1, "warning"),
+ "5": (0, "informational"),
+ "6": (3, "unknown"),
+ "7": (3, "invalid"),
+}
+OPNEED_STATUS_MAP = {
+ "0": (0, "no"),
+ "1": (2, "yes"),
+ "2": (0, "no"),
+}
-def check_quantum_libsmall_status(_no_item, _no_params, info):
- ras_status = {
- 1: (0, "good"),
- 2: (2, "failed"),
- 3: (2, "degraded"),
- 4: (1, "warning"),
- 5: (0, "informational"),
- 6: (3, "unknown"),
- 7: (3, "invalid"),
- }
+def parse_quantum_libsmall_status(info):
+ parsed = []
+ for line in info:
+ for oidend, dev_state in line:
+ dev_type = DEVICE_TYPE_MAP.get(oidend.split('.')[0])
+ if not (dev_type or dev_state):
+ continue
+ parsed.append((dev_type, dev_state))
+ return parsed
- opneed_status = {
- 0: (0, "no"),
- 1: (2, "yes"),
- }
- oidtothing = {
- "1": (ras_status, "Power"),
- "2": (ras_status, "Cooling"),
- "3": (ras_status, "Control"),
- "4": (ras_status, "Connectivity"),
- "5": (ras_status, "Robotics"),
- "6": (ras_status, "Media"),
- "7": (ras_status, "Drive"),
- "8": (opneed_status, "Operator action request"),
- }
+def inventory_quantum_libsmall_status(parsed):
+ if parsed:
+ return [(None, None)]
+
- for oidend, devstate in info:
- stateint = int(devstate)
- interpret, thing = oidtothing[oidend[0]]
- status, statname = interpret[stateint]
- yield status, thing + ": " + statname
+def check_quantum_libsmall_status(_no_item, _no_params, parsed):
+ for dev_type, dev_state in parsed:
+ if dev_type == "Operator action request":
+ state, state_readable = OPNEED_STATUS_MAP.get(dev_state, (3,
'unknown[%s]' % dev_state))
+ else:
+ state, state_readable = RAS_STATUS_MAP.get(dev_state, (3,
'unknown[%s]' % dev_state))
+ yield state, "%s: %s" % (dev_type, state_readable)
check_info['quantum_libsmall_status'] = {
+ "parse_function" : parse_quantum_libsmall_status,
"check_function" : check_quantum_libsmall_status,
"inventory_function" : inventory_quantum_libsmall_status,
"service_description" : "Tape library status",
- "snmp_info" : (".1.3.6.1.4.1.3697.1.10.10.1.15", [
+ "snmp_info" : [(".1.3.6.1.4.1.3697.1.10.10.1.15",
[
OID_END,
"10",
- ]),
+ ]),
+ (".1.3.6.1.4.1.3764.1.10.10", [
+ OID_END,
+ "12",
+ ])],
"snmp_scan_function" : lambda oid: "linux" in
oid(".1.3.6.1.2.1.1.1.0", "").lower() \
and "library" in
oid(".1.3.6.1.2.1.1.6.0", "").lower(),
}
diff --git
a/tests/unit/checks/generictests/datasets/quantum_libsmall_status_12_regression.py
b/tests/unit/checks/generictests/datasets/quantum_libsmall_status_12_regression.py
new file mode 100644
index 0000000..79c9e7a
--- /dev/null
+++ b/tests/unit/checks/generictests/datasets/quantum_libsmall_status_12_regression.py
@@ -0,0 +1,29 @@
+
+
+checkname = 'quantum_libsmall_status'
+
+
+info = [[],
+ [[u'1.0', u'1'],
+ [u'2.0', u'1'],
+ [u'3.0', u'1'],
+ [u'4.0', u'1'],
+ [u'5.0', u'1'],
+ [u'6.0', u'1'],
+ [u'7.0', u'1'],
+ [u'8.0', u'2']]]
+
+
+discovery = {'': [(None, None)]}
+
+
+checks = {'': [(None,
+ {},
+ [(0, 'Power: good', []),
+ (0, 'Cooling: good', []),
+ (0, 'Control: good', []),
+ (0, 'Connectivity: good', []),
+ (0, 'Robotics: good', []),
+ (0, 'Media: good', []),
+ (0, 'Drive: good', []),
+ (0, 'Operator action request: no', [])])]}
\ No newline at end of file
diff --git
a/tests/unit/checks/generictests/datasets/quantum_libsmall_status_15_regression.py
b/tests/unit/checks/generictests/datasets/quantum_libsmall_status_15_regression.py
new file mode 100644
index 0000000..c59283c
--- /dev/null
+++ b/tests/unit/checks/generictests/datasets/quantum_libsmall_status_15_regression.py
@@ -0,0 +1,29 @@
+
+
+checkname = 'quantum_libsmall_status'
+
+
+info = [[[u'1.0', u'1'],
+ [u'2.0', u'1'],
+ [u'3.0', u'1'],
+ [u'4.0', u'1'],
+ [u'5.0', u'1'],
+ [u'6.0', u'1'],
+ [u'7.0', u'1'],
+ [u'8.0', u'0']],
+ []]
+
+
+discovery = {'': [(None, None)]}
+
+
+checks = {'': [(None,
+ {},
+ [(0, 'Power: good', []),
+ (0, 'Cooling: good', []),
+ (0, 'Control: good', []),
+ (0, 'Connectivity: good', []),
+ (0, 'Robotics: good', []),
+ (0, 'Media: good', []),
+ (0, 'Drive: good', []),
+ (0, 'Operator action request: no', [])])]}
\ No newline at end of file