Cleanup config.nodes_of
[check_mk.git] / checks / netscaler_health
blobcb84169437fe3841a902a648f2dd9d7c61e2da2f
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
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 # Based on contribution by Karsten Schöke <karsten.schoeke@geobasis-bb.de>
29 # Example Output:
30 # .1.3.6.1.4.1.5951.4.1.1.41.7.1.1.12.1 "CPUFan0Speed"
31 # .1.3.6.1.4.1.5951.4.1.1.41.7.1.1.12.2 "CPUFan1Speed"
32 # .1.3.6.1.4.1.5951.4.1.1.41.7.1.1.14.2 "SystemFanSpeed"
33 # .1.3.6.1.4.1.5951.4.1.1.41.7.1.1.14.3 "CPU0Temperature"
34 # .1.3.6.1.4.1.5951.4.1.1.41.7.1.1.14.4 "CPU1Temperature"
35 # .1.3.6.1.4.1.5951.4.1.1.41.7.1.1.19.3 "InternalTemperature"
36 # .1.3.6.1.4.1.5951.4.1.1.41.7.1.1.25.2 "PowerSupply1FailureStatus"
37 # .1.3.6.1.4.1.5951.4.1.1.41.7.1.1.25.7 "PowerSupply2FailureStatus"
38 # .1.3.6.1.4.1.5951.4.1.1.41.7.1.2.12.1 9975
39 # .1.3.6.1.4.1.5951.4.1.1.41.7.1.2.12.2 9750
40 # .1.3.6.1.4.1.5951.4.1.1.41.7.1.2.14.2 9825
41 # .1.3.6.1.4.1.5951.4.1.1.41.7.1.2.14.3 60
42 # .1.3.6.1.4.1.5951.4.1.1.41.7.1.2.14.4 72
43 # .1.3.6.1.4.1.5951.4.1.1.41.7.1.2.19.3 32
44 # .1.3.6.1.4.1.5951.4.1.1.41.7.1.2.25.2 0
45 # .1.3.6.1.4.1.5951.4.1.1.41.7.1.2.25.7 9900
47 netscaler_health_scan = lambda oid: oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.5951.1")
49 netscaler_health_info = (
50 ".1.3.6.1.4.1.5951.4.1.1.41.7.1",
51 [ # nsSysHealthTable
52 1, # sysHealthname
53 2, # sysHealthvalue
56 # .--fan-----------------------------------------------------------------.
57 # | __ |
58 # | / _| __ _ _ __ |
59 # | | |_ / _` | '_ \ |
60 # | | _| (_| | | | | |
61 # | |_| \__,_|_| |_| |
62 # | |
63 # +----------------------------------------------------------------------+
65 factory_settings["netscaler_health_fan_default_levels"] = {
66 "lower": (3500, 3000),
67 "upper": (None, None),
71 def inventory_netscaler_health_fan(info):
72 for name, value in info:
73 if name.endswith("Speed") and value != "0":
74 yield name[:-5], {}
77 def check_netscaler_health_fan(item, params, info):
78 for name, value in info:
79 if name[:-5] == item:
80 return check_fan(int(value), params)
83 check_info["netscaler_health.fan"] = {
84 "inventory_function": inventory_netscaler_health_fan,
85 "check_function": check_netscaler_health_fan,
86 "service_description": "FAN %s",
87 "snmp_info": netscaler_health_info,
88 "snmp_scan_function": netscaler_health_scan,
89 "has_perfdata": True,
90 "default_levels_variable": "netscaler_health_fan_default_levels",
91 "group": "hw_fans",
92 "includes": ["fan.include"],
95 # .--temp----------------------------------------------------------------.
96 # | _ |
97 # | | |_ ___ _ __ ___ _ __ |
98 # | | __/ _ \ '_ ` _ \| '_ \ |
99 # | | || __/ | | | | | |_) | |
100 # | \__\___|_| |_| |_| .__/ |
101 # | |_| |
102 # +----------------------------------------------------------------------+
104 factory_settings["netscaler_health_temp_default_levels"] = {
105 "levels": (80, 90),
109 def inventory_netscaler_health_temp(info):
110 for name, value in info:
111 if name.endswith("Temperature") and value != "0":
112 yield name[:-11], {}
115 def check_netscaler_health_temp(item, params, info):
116 for name, value in info:
117 if name[:-11] == item and name.endswith("Temperature"):
118 temp = int(value)
119 return check_temperature(temp, params, "netscaler_health_%s" % item)
122 check_info["netscaler_health.temp"] = {
123 "check_function": check_netscaler_health_temp,
124 "inventory_function": inventory_netscaler_health_temp,
125 "service_description": "Temperature %s",
126 "group": "temperature",
127 "has_perfdata": True,
128 "snmp_info": netscaler_health_info,
129 "snmp_scan_function": netscaler_health_scan,
130 "includes": ["temperature.include"],
131 "default_levels_variable": "netscaler_health_temp_default_levels",
135 # .--psu-----------------------------------------------------------------.
136 # | |
137 # | _ __ ___ _ _ |
138 # | | '_ \/ __| | | | |
139 # | | |_) \__ \ |_| | |
140 # | | .__/|___/\__,_| |
141 # | |_| |
142 # +----------------------------------------------------------------------+
145 def inventory_netscaler_health_psu(info):
146 for name, state in info:
147 r = regex(r'PowerSupply([\d])(Failure|)Status')
148 m = r.match(name)
149 if m:
150 if int(state) > 0:
151 yield m.group(1), None
154 def check_netscaler_health_psu(item, _no_params, info):
155 psu_status_map = (
156 (3, "not supported"), # 0
157 (2, "not present"), # 1
158 (2, "failed"), # 2
159 (0, "normal"), # 3
162 for name, state in info:
163 if name.startswith("PowerSupply" + item) and (name.endswith("Status") \
164 or name.endswith("FailureStatus")):
165 return psu_status_map[int(state)]
168 check_info["netscaler_health.psu"] = {
169 "check_function": check_netscaler_health_psu,
170 "inventory_function": inventory_netscaler_health_psu,
171 "service_description": "Power Supply %s",
172 "snmp_info": netscaler_health_info,
173 "snmp_scan_function": netscaler_health_scan,