Refactoring: Changed all check parameters starting with an 'o' to the new rulespec...
[check_mk.git] / checks / sentry_pdu_outlets
blob51afc25615d43d70afa4b63e846e253a851dee7d
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 # .1.3.6.1.4.1.1718.3.2.3.1.2.1.1.1 AA1
28 # .1.3.6.1.4.1.1718.3.2.3.1.2.1.1.2 AA2
29 # .1.3.6.1.4.1.1718.3.2.3.1.2.1.1.3 AA3
30 # .1.3.6.1.4.1.1718.3.2.3.1.2.1.1.4 AA4
31 # .1.3.6.1.4.1.1718.3.2.3.1.2.1.1.5 AA5
32 # .1.3.6.1.4.1.1718.3.2.3.1.2.1.1.6 AA6
33 # .1.3.6.1.4.1.1718.3.2.3.1.2.1.1.7 AA7
34 # .1.3.6.1.4.1.1718.3.2.3.1.2.1.1.8 AA8
35 # .1.3.6.1.4.1.1718.3.2.3.1.3.1.1.1 TowerA_InfeedA_Outlet1
36 # .1.3.6.1.4.1.1718.3.2.3.1.3.1.1.2 PRZ_FAB01_SW1_li
37 # .1.3.6.1.4.1.1718.3.2.3.1.3.1.1.3 TowerA_InfeedA_Outlet3
38 # .1.3.6.1.4.1.1718.3.2.3.1.3.1.1.4 TowerA_InfeedA_Outlet4
39 # .1.3.6.1.4.1.1718.3.2.3.1.3.1.1.5 TowerA_InfeedA_Outlet5
40 # .1.3.6.1.4.1.1718.3.2.3.1.3.1.1.6 1643_AMS_Telekom_Umsetz.
41 # .1.3.6.1.4.1.1718.3.2.3.1.3.1.1.7 TowerA_InfeedA_Outlet7
42 # .1.3.6.1.4.1.1718.3.2.3.1.3.1.1.8 S2M_Optokoppler
43 # .1.3.6.1.4.1.1718.3.2.3.1.5.1.1.1 0
44 # .1.3.6.1.4.1.1718.3.2.3.1.5.1.1.2 1
45 # .1.3.6.1.4.1.1718.3.2.3.1.5.1.1.3 0
46 # .1.3.6.1.4.1.1718.3.2.3.1.5.1.1.4 0
47 # .1.3.6.1.4.1.1718.3.2.3.1.5.1.1.5 0
48 # .1.3.6.1.4.1.1718.3.2.3.1.5.1.1.6 1
49 # .1.3.6.1.4.1.1718.3.2.3.1.5.1.1.7 0
50 # .1.3.6.1.4.1.1718.3.2.3.1.5.1.1.8 1
52 # parsed = {
53 # 'AA1 TowerA_InfeedA_1' : 0,
54 # 'AA2 PRZ_FAB01_SW1_li' : 1,
55 # 'AA3 TowerA_InfeedA_3' : 0,
56 # 'AA4 TowerA_InfeedA_4' : 0,
57 # 'AA5 TowerA_InfeedA_5' : 0,
58 # 'AA6 1643_AMS_Telekom_Umsetz.': 1,
59 # 'AA7 TowerA_InfeedA_7' : 0,
60 # 'AA8 S2M_Optokoppler' : 1,
61 # }
64 def parse_sentry_pdu_outlets(info):
65 parsed = {}
66 for outlet_id, outlet_name, outlet_state_str in info:
67 outlet_name = outlet_name.replace('Outlet', '')
68 outlet_id_name = "%s %s" % (outlet_id, outlet_name)
69 parsed[outlet_id_name] = int(outlet_state_str)
70 return parsed
73 def inventory_sentry_pdu_outlets(parsed):
74 return [(key, None) for key in parsed]
77 def check_sentry_pdu_outlets(item, _no_params, parsed):
78 outlet_states = {
79 0: (0, "off"),
80 1: (0, "on"),
81 2: (1, "off wait"),
82 3: (1, "on wait"),
83 4: (2, "off error"),
84 5: (2, "on error"),
85 6: (2, "no comm"),
86 7: (2, "reading"),
87 8: (2, "off fuse"),
88 9: (2, "on fuse"),
91 if item in parsed:
92 outlet_state = parsed[item]
94 if outlet_state in outlet_states:
95 return outlet_states[outlet_state][0], \
96 "Status: %s" % outlet_states[outlet_state][1]
97 return 3, "Unhandled state: %d" % outlet_state
100 check_info['sentry_pdu_outlets'] = {
101 'parse_function': parse_sentry_pdu_outlets,
102 'inventory_function': inventory_sentry_pdu_outlets,
103 'check_function': check_sentry_pdu_outlets,
104 'service_description': 'Outlet %s',
105 'snmp_info': (".1.3.6.1.4.1.1718.3.2.3.1", ["2", "3", "5"]),
106 'snmp_scan_function': lambda oid: oid(".1.3.6.1.2.1.1.2.0") == ".1.3.6.1.4.1.1718.3",
107 'includes': ['elphase.include'],