Cleanup config.nodes_of
[check_mk.git] / checks / printer_pages.include
blob7fc3e3d3ab366ccbc758e3ee19c4a2731e01387d
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2015 mk@mathias-kettner.de |
11 # +------------------------------------------------------------------+
13 # This file is part of Check_MK.
14 # The official homepage is at http://mathias-kettner.de/check_mk.
16 # check_mk is free software; you can redistribute it and/or modify it
17 # under the terms of the GNU General Public License as published by
18 # the Free Software Foundation in version 2. check_mk is distributed
19 # in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
20 # out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
21 # PARTICULAR PURPOSE. See the GNU General Public License for more de-
22 # tails. You should have received a copy of the GNU General Public
23 # License along with GNU Make; see the file COPYING. If not, write
24 # to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
25 # Boston, MA 02110-1301 USA.
27 # perfometer shows 'pages_total'
28 # checks' parse_function's output:
29 # { 'KEY1' : PAGES VALUE1, 'KEY2' : PAGES VALUE2, ... }
32 # Scan functions for some special printers that have their own MIBS
33 def scan_ricoh_printer(oid):
34 return ".1.3.6.1.4.1.367.1.1" in oid(".1.3.6.1.2.1.1.2.0") \
35 and oid(".1.3.6.1.4.1.367.3.2.1.2.19.5.1.5.1") is not None
38 def scan_canon_printer(oid):
39 return "canon" in oid(".1.3.6.1.2.1.1.1.0").lower() \
40 and oid(".1.3.6.1.4.1.1602.1.1.1.1.0") is not None \
41 and oid(".1.3.6.1.4.1.1602.1.11.1.3.1.4") is not None
44 def scan_generic_printer(oid):
45 return oid(".1.3.6.1.2.1.43.10.2.1.4.1.1") is not None \
46 and not scan_ricoh_printer(oid) \
47 and not scan_canon_printer(oid)
50 printer_pages_types = {
51 'pages_total': 'total prints',
52 'pages_color': 'color',
53 'pages_bw': 'b/w',
54 'pages_a4': 'A4',
55 'pages_a3': 'A3',
56 'pages_color_a4': 'color A4',
57 'pages_bw_a4': 'b/w A4',
58 'pages_color_a3': 'color A3',
59 'pages_bw_a3': 'b/w A3',
63 def inventory_printer_pages_types(parsed):
64 return [(None, None)]
67 def check_printer_pages_types(_no_item, _no_params, parsed):
68 if 'pages_total' not in parsed:
69 pages = sum(parsed.values())
70 yield 0, 'total prints: %d' % (pages), [('pages_total', pages)]
72 for pages_type, pages in sorted(parsed.items()):
73 if pages_type in printer_pages_types:
74 infotext = printer_pages_types[pages_type]
75 yield 0, "%s: %d" % (infotext, pages), [(pages_type, pages)]