Cleanup config.nodes_of
[check_mk.git] / checks / raritan_pdu_plugs
blob5b75b2a163f3ebb14b97f90209da98e5c3bc8fce
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2014 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 raritan_pdu_plugs_default = '"on"' # only to be downwards compatible and can be removed any decade now.
30 def inventory_raritan_pdu_plugs(parsed):
31 for key, value in parsed.iteritems():
32 yield key, value["state_int"]
35 def parse_raritan_pdu_plugs(info):
36 parsed = {}
38 for outlet_label, outlet_name, outlet_state in info:
39 try:
40 state_int = int(outlet_state)
41 except ValueError:
42 state_int = None
43 parsed[outlet_label] = {
44 "state": raritan_map_state.get(outlet_state, (None, None)),
45 "state_int": state_int,
46 "outlet_name": outlet_name,
48 return parsed
51 @get_parsed_item_data
52 def check_raritan_pdu_plugs(_no_item, params, data):
53 if data.get("outlet_name"):
54 yield 0, data["outlet_name"]
55 required_state = params
56 state, state_info = data["state"]
57 outlet_state = data["state_int"]
58 state = 0
59 if isinstance(required_state, int):
60 if outlet_state != required_state:
61 state = 2
62 elif state_info != required_state:
63 state = 2
64 yield state, "Status: %s" % state_info
67 check_info['raritan_pdu_plugs'] = {
68 "inventory_function" : inventory_raritan_pdu_plugs,
69 "parse_function": parse_raritan_pdu_plugs,
70 "check_function" : check_raritan_pdu_plugs,
71 "service_description" : "Plug %s",
72 "group" : "plugs",
73 "snmp_info" : ( ".1.3.6.1.4.1.13742.6", [
74 "3.5.3.1.2", # Outlet-Label (Index) (PDU identifier of the outlet)
75 "3.5.3.1.3", # OutletName (eigene vergebene Bezeichnung für den Ausgang)
76 "4.1.2.1.3", # Outlet state at present (sh.o. outlet_state_info im check)
77 ]),
78 "snmp_scan_function" : lambda oid: oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.13742.6") and \
79 (oid(".1.3.6.1.4.1.13742.6.3.2.1.1.3.1").startswith("PX2-2") or \
80 oid(".1.3.6.1.4.1.13742.6.3.2.1.1.3.1").startswith("PX3")),
81 "includes" : [ "raritan.include" ],