Module: check_mk
Branch: master
Commit: cb528d8df09dcb9f53e2bff56fbb78f8a3acc729
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=cb528d8df09dcb…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Aug 11 16:30:16 2011 +0200
canon_pages: make compatible with new SNMP handling
---
checks/canon_pages | 53 +++++++++++++++++++++------------------------------
1 files changed, 22 insertions(+), 31 deletions(-)
diff --git a/checks/canon_pages b/checks/canon_pages
index a472f21..f5d8fe9 100644
--- a/checks/canon_pages
+++ b/checks/canon_pages
@@ -24,48 +24,39 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
-# Author: Lars Michelsen <lm(a)mathias-kettner.de>de>, 2011-03-16
-
-# [[['301', '28495']], [['112', '24']], [['113',
'14880']], [['122', '146']], [['123', '15870']],
[['501', '3761']], [['101', '30920']]]
+# [['301', '28495']], [['112', '24']], [['113',
'14880']], [['122', '146']], [['123', '15870']],
[['501', '3761']], [['101', '30920']]
canon_pages_map = {
- '101': 'total',
- '112': 'b/w A3',
- '113': 'b/w A4',
- '122': 'color A3',
- '123': 'color A4',
- '301': 'print total',
- '501': 'scan',
+ 'total' : '101',
+ 'b/w A3' : '112',
+ 'b/w A4' : '113',
+ 'color A3' : '122',
+ 'color A4' : '123',
+ 'print total' : '301',
+ 'scan' : '501',
}
def inventory_canon_pages(checkname, info):
inventory = []
- for data in info:
- if data:
- inventory.append((canon_pages_map.get(data[0][0],
- 'unknown-%s' % data[0][0]), None))
+ for endoid, value in info:
+ for name, eo in canon_pages_map.items():
+ if eo == endoid:
+ inventory.append((name, None))
return inventory
-def check_canon_pages(item, params, info):
- for data in info:
- if not data or not data[0]:
- continue
- index, value = data[0]
- if canon_pages_map.get(index, 'unknown-'+index) == item:
- return (0, 'OK - Current count: %s' % value, [('count',
value)])
+def check_canon_pages(item, _no_params, info):
+ if item not in canon_pages_map:
+ return (3, "UNKNOWN - unknown counter type %s" % item)
+ for endoid, value in info:
+ if endoid == canon_pages_map[item]:
+ return (0, 'OK - Current count: %s' % value, [('count',
int(value))])
+
+ return (3, 'UNKNOWN - Item not found in SNMP data')
- return (3, 'UNKNOWN - Item not found in SNMP')
check_info['canon_pages'] = (check_canon_pages, "Pages %s", 1,
inventory_canon_pages)
-snmp_info['canon_pages'] = [
- ( ".1.3.6.1.4.1.1602.1.11.1.3.1.4", [ OID_END, 101 ]), # count total
- ( ".1.3.6.1.4.1.1602.1.11.1.3.1.4", [ OID_END, 112 ]), # count b/w A3
- ( ".1.3.6.1.4.1.1602.1.11.1.3.1.4", [ OID_END, 113 ]), # count b/w A4
- ( ".1.3.6.1.4.1.1602.1.11.1.3.1.4", [ OID_END, 122 ]), # count color A3
- ( ".1.3.6.1.4.1.1602.1.11.1.3.1.4", [ OID_END, 123 ]), # count color A4
- ( ".1.3.6.1.4.1.1602.1.11.1.3.1.4", [ OID_END, 301 ]), # print total
- ( ".1.3.6.1.4.1.1602.1.11.1.3.1.4", [ OID_END, 501 ]), # scan
-]
+snmp_info['canon_pages'] = \
+ ( ".1.3.6.1.4.1.1602.1.11.1.3.1.4", [ OID_END, "" ])
snmp_scan_functions['canon_pages'] = lambda oid:
oid(".1.3.6.1.4.1.1602.1.1.1.1.0") != None