Module: check_mk
Branch: master
Commit: af337e558b8fecbb5ee93bc81722f84c7bab2dd9
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=af337e558b8fec…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon May 21 10:31:45 2012 +0200
printer_alerts: new configuration variable printer_alerts_text_map
---
ChangeLog | 2 ++
checkman/printer_alerts | 10 ++++++++++
checks/printer_alerts | 22 ++++++++++++++++++++--
3 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index a982db3..a986b12 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -58,6 +58,8 @@
* FIX: Logwatch: Logwatch services in rules configured using WATO must be
given as item, not as whole service name
* New active check via WATO: check_ldap
+ * printer_alerts: new configuration variable printer_alerts_text_map. Make
+ 'Energiesparen' on Brother printers an OK state.
BI:
* FIX: make rotating folding arrows black (white was not visible)
diff --git a/checkman/printer_alerts b/checkman/printer_alerts
index 85ab277..b217657 100644
--- a/checkman/printer_alerts
+++ b/checkman/printer_alerts
@@ -23,9 +23,19 @@ examples:
0: [ 4, 6, 7, 19, 20, 23, 24, 25, 27, 35, 36, 37, 38, 502, 503, 504, 505, 506, 507,
802, 803, 804, 805, 806, 807, 808, 809, 810, 1001, 1002, 1005, 1106, 1107, 1108, 1111,
1113, 1302, 1304, 1501, 1502, 1503, 1504, 1505, 1506, 1509 ],
}
+ # Make 'Energiesparen' an OK state
+ printer_alerts_text_map = {
+ 'Energiesparen' : 0,
+ }
+
[configuration]
printer_alerts_state_map(dict): Can be used to configure state codes
reported by the printer to result in individual nagios states. This
dictionary contains three elements. One for each nagios state. Each
element holds a list of state codes to result in this state.
Take a look at the example section to see the defaults.
+
+printer_alerts_text_map(dict): Some printers send a status code of {-1} in some cases.
+ But you can use the additional descriptive text sent by the printer for assigning
+ a monitoring state by using this dictionary. The key is the descriptive text. The
+ value is 0 (OK), 1 (WARN), 2 (CRIT) or 3 (UNKNOWN).
diff --git a/checks/printer_alerts b/checks/printer_alerts
index 58ba220..95ac1dc 100644
--- a/checks/printer_alerts
+++ b/checks/printer_alerts
@@ -70,6 +70,14 @@ printer_alerts_state_map = {
1503, 1504, 1505, 1506, 1509 ],
}
+# Some printers send a code of -1 but an additional text
+# that allows us to generate a useful state - at the price
+# of providing texts in the native language of the country
+# of the printers user.
+printer_alerts_text_map = {
+ 'Energiesparen' : 0,
+}
+
def inventory_printer_alerts(info):
return [ (None, None) ]
@@ -84,10 +92,16 @@ def check_printer_alerts(_not_used, _not_used1, info):
for sev, group, group_index, code, desc in info:
state = 3 # UNKNOWN
+ if desc in printer_alerts_text_map:
+ state = printer_alerts_text_map[desc]
+ sum_txt.append("%s - %s" % (nagios_state_names[state], desc))
+ break
+
for s in [ 2, 1, 0 ]:
if saveint(code) in printer_alerts_state_map[s]:
state = s
break
+
# Code not found -> take into account severity
if state == 3 and sev == '1':
state = 0
@@ -103,8 +117,11 @@ def check_printer_alerts(_not_used, _not_used1, info):
elif state > sum_state:
sum_state = state
- sum_txt.append('%s - %s - %s (%s)' % (nagios_state_names[state],
- group_txt, desc, code))
+ info_text = '%s - %s - %s' % (nagios_state_names[state], group_txt,
desc)
+ if state == 3 and code != -1:
+ info_text += " (code: %d)" % code
+
+ sum_txt.append(info_text)
return (sum_state, ', '.join(sum_txt))
@@ -119,6 +136,7 @@ snmp_info['printer_alerts'] = (
".1.3.6.1.2.1.43.18.1.1", [
] )
check_config_variables.append("printer_alerts_state_map")
+check_config_variables.append("printer_alerts_text_map")
snmp_scan_functions['printer_alerts'] = \
lambda oid: oid(".1.3.6.1.2.1.43.11.1.1.6.1.1") != None