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
))
73 def check_raritan_pdu_ocprot(item
, params
, data
):
75 "-1": (3, "Overcurrent protector information is unavailable"),
76 "0": (2, "Overcurrent protector is open"),
77 "1": (0, "Overcurrent protector is closed"),
80 yield states
[data
["state"]]
83 yield check_levels(data
["current"], "current", params
, unit
="A", infoname
="Current")
86 check_info
["raritan_pdu_ocprot"] = {
87 "parse_function": parse_raritan_pdu_ocprot
,
88 "inventory_function": discover(
89 lambda key
, value
: True, default_params
="raritan_pdu_ocprot_current_default_levels"),
90 "check_function": check_raritan_pdu_ocprot
,
92 "service_description": "Overcurrent Protector %s",
93 "group": "ocprot_current",
94 "snmp_info": [(".1.3.6.1.4.1.13742.6.5.3.3.1", [
98 ]), (".1.3.6.1.4.1.13742.6.3.4.4.1", ["7"])],
99 "snmp_scan_function": lambda oid
: "13742" in oid(".1.3.6.1.2.1.1.2.0"),