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.
28 def parse_raritan_emx(info
):
31 '1': ('temp', 'Water'),
32 '2': ('fanspeed', ''),
37 for rack_id
, rack_name
, sensor_number
, value_text
, unit
, sensor_state
in info
:
38 rack_type
, rack_type_readable
= raritan_map_type
[sensor_number
]
41 if rack_type_readable
!= '':
42 extra_name
+= " " + rack_type_readable
44 rack_name
= ("Rack %s%s %s" % (rack_id
, extra_name
, rack_name
)).replace("DC", "").strip()
46 if rack_type
in ['binary', '']:
49 if rack_type
== "temp":
50 rack_value
= float(value_text
) / 10
52 rack_value
= int(value_text
)
55 "rack_type": rack_type
,
56 "rack_unit": raritan_map_unit
[unit
],
57 "rack_value": rack_value
,
58 "state": raritan_map_state
[sensor_state
],
64 def inventory_raritan_emx(parsed
, rack_type
):
65 for rack_name
, values
in parsed
.items():
66 if values
["rack_type"] == rack_type
:
70 # .--temperature---------------------------------------------------------.
72 # | | |_ ___ _ __ ___ _ __ ___ _ __ __ _| |_ _ _ _ __ ___ |
73 # | | __/ _ \ '_ ` _ \| '_ \ / _ \ '__/ _` | __| | | | '__/ _ \ |
74 # | | || __/ | | | | | |_) | __/ | | (_| | |_| |_| | | | __/ |
75 # | \__\___|_| |_| |_| .__/ \___|_| \__,_|\__|\__,_|_| \___| |
77 # +----------------------------------------------------------------------+
79 # '----------------------------------------------------------------------'
82 def inventory_raritan_emx_temp(parsed
):
83 for rack_name
, values
in parsed
.items():
84 if values
["rack_type"] == "temp":
88 def check_raritan_emx_temp(item
, params
, parsed
):
89 if "Temperature" in item
:
90 # old style (pre 1.2.8) item name, convert
91 item
= "Rack " + item
.replace(" Temperature", "")
92 elif "Fan Speed" in item
:
93 item
= "Rack " + item
.replace(" Fan Speed", "")
94 return check_raritan_emx_fan(item
, params
, parsed
)
95 elif "Door Contact" in item
:
96 item
= "Rack " + item
.replace(" Door Contact DC", "")
97 return check_raritan_sensors_binary(item
, params
, parsed
)
100 rack_value
= parsed
[item
]["rack_value"]
101 rack_unit
= parsed
[item
]["rack_unit"]
102 state
, state_readable
= parsed
[item
]["state"]
103 return check_temperature(
109 dev_status_name
=state_readable
)
112 check_info
['raritan_emx'] = {
113 "parse_function": parse_raritan_emx
,
114 "inventory_function": inventory_raritan_emx_temp
,
115 "check_function": check_raritan_emx_temp
,
116 "service_description": "Temperature %s",
117 "has_perfdata": True,
119 ".1.3.6.1.4.1.13742.9",
121 "1.4.1.1.1", # Rack ID
123 "1.4.1.1.2", # Sensor
128 "snmp_scan_function": lambda oid
: oid(".1.3.6.1.2.1.1.2.0") in [".1.3.6.1.4.1.13742.8"],
129 "group": "temperature",
130 "includes": ["temperature.include", "raritan.include"],
134 # .--fan-----------------------------------------------------------------.
137 # | | |_ / _` | '_ \ |
138 # | | _| (_| | | | | |
139 # | |_| \__,_|_| |_| |
141 # '----------------------------------------------------------------------'
144 def check_raritan_emx_fan(item
, _no_params
, parsed
):
146 fan_speed
= parsed
[item
]["rack_value"]
147 fan_unit
= parsed
[item
]["rack_unit"]
148 state
, state_readable
= parsed
[item
]["state"]
149 return state
, "Speed: %d%s, status: %s" % (fan_speed
, fan_unit
, state_readable
)
152 check_info
['raritan_emx.fan'] = {
153 "inventory_function": lambda parsed
: inventory_raritan_emx(parsed
, "fanspeed"),
154 "check_function": check_raritan_emx_fan
,
155 "service_description": "Fan %s",
159 # .--binary--------------------------------------------------------------.
161 # | | |__ (_)_ __ __ _ _ __ _ _ |
162 # | | '_ \| | '_ \ / _` | '__| | | | |
163 # | | |_) | | | | | (_| | | | |_| | |
164 # | |_.__/|_|_| |_|\__,_|_| \__, | |
166 # '----------------------------------------------------------------------'
168 check_info
['raritan_emx.binary'] = {
169 "inventory_function": lambda parsed
: inventory_raritan_emx(parsed
, "binary"),
170 "check_function": check_raritan_sensors_binary
,
171 "service_description": "Door %s",