/usr/share/check_mk/checks/brocade is in check-mk-server 1.2.6p12-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | #!/usr/bin/python
# -*- encoding: utf-8; py-indent-offset: 4 -*-
# +------------------------------------------------------------------+
# | ____ _ _ __ __ _ __ |
# | / ___| |__ ___ ___| | __ | \/ | |/ / |
# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
# | | |___| | | | __/ (__| < | | | | . \ |
# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
# | |
# | Copyright Mathias Kettner 2014 mk@mathias-kettner.de |
# +------------------------------------------------------------------+
#
# This file is part of Check_MK.
# The official homepage is at http://mathias-kettner.de/check_mk.
#
# check_mk is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation in version 2. check_mk is distributed
# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more de-
# ails. You should have received a copy of the GNU General Public
# License along with GNU Make; see the file COPYING. If not, write
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
# Example output from agent:
# [['1', '24', 'SLOT #0: TEMP #1'],
# ['2', '12', 'SLOT #0: TEMP #2'],
# ['3', '12', 'SLOT #0: TEMP #3'],
# ['4', '4687', 'FAN #1'],
# ['5', '4560', 'FAN #2'],
# ['6', '4821', 'FAN #3'],
# ['7', '1', 'Power Supply #1'],
# ['8', '1', 'Power Supply #2']]
def brocade_sensor_convert(info, what):
return_list = []
for presence, state, name in info:
if name.startswith(what) and presence != "6" and (saveint(state) > 0 or what == "Power"):
sensor_id = name.split('#')[-1]
return_list.append([sensor_id, name, state])
return return_list
def brocade_scan(oid):
return oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.1588.2.1.1") or \
oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.24.1.1588.2.1.1") or \
oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.1588.2.2.1") or \
oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.1588.3.3.1")
brocade_info = ('.1.3.6.1.4.1.1588.2.1.1.1.1.22.1', [
3, # swSensorStatus, 6 = absent
4, # swSensorValue, -2147483648 = unknown
5, # swSensorInfo
])
brocade_fan_default_levels = { "lower": (3000 , 2800 ) }
def inventory_brocade_fan(info):
converted = brocade_sensor_convert(info, "FAN")
return [ (x[0], 'brocade_fan_default_levels') for x in converted ]
def check_brocade_fan(item, params, info):
converted = brocade_sensor_convert(info, "FAN")
if type(params) is tuple: # old format
warn, crit = params
else: # new format
warn, crit = params.get("lower")
if params.get("upper"):
upperwarn, uppercrit = params["upper"]
else:
upperwarn, uppercrit = ( None, None )
for snmp_item, name, value in converted:
if item == snmp_item:
state = 0
label = ""
value = saveint(value)
perf = [ ('fan', value, warn, crit) ]
if value <= crit:
state = 2
label = "(Levels below: %d/%d)" % (warn, crit)
elif value <= warn:
state = 1
label = "(Levels below: %d/%d)" % (warn, crit)
elif uppercrit and value >= uppercrit:
state = 2
label = "(Levels above: %d/%d)" % (upperwarn, uppercrit)
elif upperwarn and value >= upperwarn:
state = 1
label = "(Levels above: %d/%d)" % (upperwarn, uppercrit)
return state, "Fans at %drpm %s " % (value, label), perf
return 3, "FAN not found"
check_info["brocade.fan"] = {
"check_function" : check_brocade_fan,
"inventory_function" : inventory_brocade_fan,
"service_description" : "FAN %s",
"has_perfdata" : True,
"group" : "hw_fans",
"snmp_info" : brocade_info,
'snmp_scan_function' : brocade_scan,
}
def inventory_brocade_power(info):
converted = brocade_sensor_convert(info, "Power")
return [ (x[0], None) for x in converted ]
def check_brocade_power(item, _no_params, info):
converted = brocade_sensor_convert(info, "Power")
for snmp_item, name, value in converted:
if item == snmp_item:
value = saveint(value)
if value != 1:
return 2, "Error on supply %s" % name
return 0, "No problems found"
return 3, "Supply not found"
check_info["brocade.power"] = {
"check_function" : check_brocade_power,
"inventory_function" : inventory_brocade_power,
"service_description" : "Power supply %s",
"has_perfdata" : False,
"snmp_info" : brocade_info,
'snmp_scan_function' : brocade_scan,
}
brocade_temp_default_levels = ( 30, 40 )
def inventory_brocade_temp(info):
converted = brocade_sensor_convert(info, "SLOT")
return [ (x[0], 'brocade_temp_default_levels') for x in converted ]
def check_brocade_temp(item, params, info):
converted = brocade_sensor_convert(info, "SLOT")
for snmp_item, name, value in converted:
if item == snmp_item:
return check_temperature(int(value), params)
check_info["brocade.temp"] = {
"check_function" : check_brocade_temp,
"inventory_function" : inventory_brocade_temp,
"service_description" : "Temperature %s",
"has_perfdata" : True,
"group" : "hw_temperature",
"snmp_info" : brocade_info,
'snmp_scan_function' : brocade_scan,
"includes" : [ "temperature.include" ],
}
|