2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
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_ocprot_current_default_levels
= (14.0, 15.0)
30 # [[[u'1.1.1', u'4', u'0'],
31 # [u'1.1.15', u'1', u'0'],
32 # [u'1.2.1', u'4', u'0'],
33 # [u'1.2.15', u'1', u'0'],
34 # [u'1.3.1', u'4', u'70'],
35 # [u'1.3.15', u'1', u'0'],
36 # [u'1.4.1', u'4', u'0'],
37 # [u'1.4.15', u'1', u'0'],
38 # [u'1.5.1', u'4', u'0'],
39 # [u'1.5.15', u'1', u'0'],
40 # [u'1.6.1', u'4', u'0'],
41 # [u'1.6.15', u'1', u'0']],
54 # Raritan implements a strange way of indexing here. The two last components
55 # of the OID should really be swapped!
58 def parse_raritan_pdu_ocprot(info
):
59 flattened_info
= [[end_oid
, state
, value
, scale
]
60 for (end_oid
, state
, value
), (scale
,) in zip(info
[0], info
[1])]
62 for end_oid
, state
, value
, scale
in flattened_info
:
63 protector_id
= "C" + end_oid
.split(".")[1] # 1.5.1 --> Item will be "C5"
65 if end_oid
.endswith(".15"):
66 parsed
.setdefault(protector_id
, {})["state"] = state
67 elif end_oid
.endswith(".1"):
68 parsed
.setdefault(protector_id
, {})["current"] = float(value
) / pow(10, int(scale
))
72 def inventory_raritan_pdu_ocprot(parsed
):
73 for protector_id
in parsed
:
74 yield protector_id
, "raritan_pdu_ocprot_current_default_levels"
77 def check_raritan_pdu_ocprot(item
, params
, parsed
):
79 "-1": (3, "Overcurrent protector information is unavailable"),
80 "0": (2, "Overcurrent protector is open"),
81 "1": (0, "Overcurrent protector is closed"),
85 yield states
[parsed
[item
]["state"]]
87 current
= parsed
[item
]["current"]
90 infotext
= "Current: %.1f A" % current
91 levelstext
= " (warn/crit at %.1f/%.1f A)" % (warn
, crit
)
95 infotext
+= levelstext
98 infotext
+= levelstext
102 perfdata
= [("current", current
, warn
, crit
)]
103 yield status
, infotext
, perfdata
106 check_info
["raritan_pdu_ocprot"] = {
107 "parse_function": parse_raritan_pdu_ocprot
,
108 "inventory_function": inventory_raritan_pdu_ocprot
,
109 "check_function": check_raritan_pdu_ocprot
,
110 "has_perfdata": True,
111 "service_description": "Overcurrent Protector %s",
112 "group": "ocprot_current",
113 "snmp_info": [(".1.3.6.1.4.1.13742.6.5.3.3.1", [
117 ]), (".1.3.6.1.4.1.13742.6.3.4.4.1", ["7"])],
118 "snmp_scan_function": lambda oid
: "13742" in oid(".1.3.6.1.2.1.1.2.0"),