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 qlogic_sanbox_status_map
= [
36 # .--temp----------------------------------------------------------------.
38 # | | |_ ___ _ __ ___ _ __ |
39 # | | __/ _ \ '_ ` _ \| '_ \ |
40 # | | || __/ | | | | | |_) | |
41 # | \__\___|_| |_| |_| .__/ |
43 # '----------------------------------------------------------------------'
46 def inventory_qlogic_sanbox_temp(info
):
48 for sensor_name
, _sensor_status
, _sensor_message
, sensor_type
, \
49 sensor_characteristic
, sensor_id
in info
:
50 sensor_id
= sensor_id
.replace("16.0.0.192.221.48.", "").replace(".0.0.0.0.0.0.0.0", "")
51 if sensor_type
== "8" and sensor_characteristic
== "3" and \
52 sensor_name
!= "Temperature Status":
53 inventory
.append((sensor_id
, None))
57 def check_qlogic_sanbox_temp(item
, _no_params
, info
):
58 for _sensor_name
, sensor_status
, sensor_message
, _sensor_type
, \
59 _sensor_characteristic
, sensor_id
in info
:
60 sensor_id
= sensor_id
.replace("16.0.0.192.221.48.", "").replace(".0.0.0.0.0.0.0.0", "")
62 sensor_status
= int(sensor_status
)
63 if sensor_status
< 0 or sensor_status
>= len(qlogic_sanbox_status_map
):
64 sensor_status_descr
= sensor_status
66 sensor_status_descr
= qlogic_sanbox_status_map
[int(sensor_status
)]
68 if sensor_status
== 3:
70 elif sensor_status
== 4:
72 elif sensor_status
== 5:
77 if sensor_message
.endswith(" degrees C"):
78 temp
= int(sensor_message
.replace(" degrees C", ""))
79 perfdata
= [('temp', str(temp
) + 'C')]
83 return status
, "Sensor %s is at %s and reports status %s" % \
84 (sensor_id
, sensor_message
, sensor_status_descr
), perfdata
85 return 3, "No sensor %s found" % item
87 check_info
["qlogic_sanbox.temp"] = {
88 "check_function" : check_qlogic_sanbox_temp
,
89 "inventory_function" : inventory_qlogic_sanbox_temp
,
90 "service_description" : "Temperature Sensor %s",
91 "has_perfdata" : True,
92 "snmp_info" : (".1.3.6.1.3.94.1.8.1", [3, # connUnitSensorName
93 4, # connUnitSensorStatus
94 6, # connUnitSensorMessage
95 7, # connUnitSensorType
96 8, # connUnitSensorCharacteristic
98 # .1.3.6.1.4.1.3873.1.14 Qlogic-Switch
99 # .1.3.6.1.4.1.3873.1.8 Qlogic-4Gb SAN Switch Module for IBM BladeCenter
100 'snmp_scan_function' : lambda oid
: \
101 oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.3873.1.14") \
102 or oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.3873.1.8"),
106 # .--power supplies------------------------------------------------------.
108 # | _ __ _____ _____ _ __ ___ _ _ _ __ _ __ | (_) ___ ___ |
109 # || '_ \ / _ \ \ /\ / / _ \ '__| / __| | | | '_ \| '_ \| | |/ _ \/ __| |
110 # || |_) | (_) \ V V / __/ | \__ \ |_| | |_) | |_) | | | __/\__ \ |
111 # || .__/ \___/ \_/\_/ \___|_| |___/\__,_| .__/| .__/|_|_|\___||___/ |
114 # '----------------------------------------------------------------------'
117 def inventory_qlogic_sanbox_psu(info
):
119 for _sensor_name
, _sensor_status
, _sensor_message
, sensor_type
, \
120 _sensor_characteristic
, sensor_id
in info
:
121 sensor_id
= sensor_id
.replace("16.0.0.192.221.48.", "").replace(".0.0.0.0.0.0.0.0", "")
122 if sensor_type
== "5":
123 inventory
.append((sensor_id
, None))
127 def check_qlogic_sanbox_psu(item
, _no_params
, info
):
128 for _sensor_name
, sensor_status
, _sensor_message
, _sensor_type
, \
129 _sensor_characteristic
, sensor_id
in info
:
130 sensor_id
= sensor_id
.replace("16.0.0.192.221.48.", "").replace(".0.0.0.0.0.0.0.0", "")
131 if sensor_id
== item
:
132 sensor_status
= int(sensor_status
)
133 if sensor_status
< 0 or sensor_status
>= len(qlogic_sanbox_status_map
):
134 sensor_status_descr
= sensor_status
136 sensor_status_descr
= qlogic_sanbox_status_map
[int(sensor_status
)]
138 if sensor_status
== 3:
140 elif sensor_status
== 4:
142 elif sensor_status
== 5:
147 return status
, "Power Supply %s reports status %s" % (sensor_id
, sensor_status_descr
)
148 return 3, "No sensor %s found" % item
150 check_info
["qlogic_sanbox.psu"] = {
151 "check_function" : check_qlogic_sanbox_psu
,
152 "inventory_function" : inventory_qlogic_sanbox_psu
,
153 "service_description" : "PSU %s",
154 "snmp_info" : (".1.3.6.1.3.94.1.8.1", [3, # connUnitSensorName
155 4, # connUnitSensorStatus
156 6, # connUnitSensorMessage
157 7, # connUnitSensorType
158 8, # connUnitSensorCharacteristic
160 # .1.3.6.1.4.1.3873.1.14 Qlogic-Switch
161 # .1.3.6.1.4.1.3873.1.8 Qlogic-4Gb SAN Switch Module for IBM BladeCenter
162 'snmp_scan_function' : lambda oid
: \
163 oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.3873.1.14") \
164 or oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.3873.1.8"),