Cleanup config.nodes_of
[check_mk.git] / checks / icom_repeater
blob40c0dbdaa74f9f53e959286cfc1be4b197a9591d
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2015 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 # .--Parse function------------------------------------------------------.
28 # | ____ __ _ _ |
29 # | | _ \ __ _ _ __ ___ ___ / _|_ _ _ __ ___| |_(_) ___ _ __ |
30 # | | |_) / _` | '__/ __|/ _ \ | |_| | | | '_ \ / __| __| |/ _ \| '_ \ |
31 # | | __/ (_| | | \__ \ __/ | _| |_| | | | | (__| |_| | (_) | | | | |
32 # | |_| \__,_|_| |___/\___| |_| \__,_|_| |_|\___|\__|_|\___/|_| |_| |
33 # | |
34 # +----------------------------------------------------------------------+
35 # | |
36 # '----------------------------------------------------------------------'
39 def parse_icom_repeater(info):
40 parsed = {}
41 for line in info:
42 if line[1] == "Temperature":
43 parsed["temp"] = float(line[2][:-1])
44 parsed["temp_devunit"] = line[2][-1].lower()
46 elif line[1] == "ESN number":
47 parsed["esnno"] = line[2]
49 elif line[1] == "Repeater operation":
50 parsed["repop"] = line[2].lower()
52 elif line[1] == "Abnormal temperature detection":
53 if line[2] == "Not detected":
54 parsed["temp_devstatus"] = 0
55 else:
56 parsed["temp_devstatus"] = 2
58 elif line[1] == "Power-supply voltage":
59 parsed["ps_voltage"] = float(line[2][:-1])
61 elif line[1] == "Abnormal power-supply voltage detection":
62 if line[2] == "Not detected":
63 parsed["ps_volt_devstatus"] = 0
64 else:
65 parsed["ps_volt_devstatus"] = 2
67 elif line[1] == "TX PLL lock voltage":
68 try:
69 parsed["tx_pll_lock_voltage"] = float(line[2][:-1])
70 except:
71 pass
73 elif line[1] == "RX PLL lock voltage":
74 try:
75 parsed["rx_pll_lock_voltage"] = float(line[2][:-1])
76 except:
77 pass
79 elif line[1] == "Repeater frequency":
80 parsed["repeater_frequency"] = dict([(b.split(":")[0].lower(), int(b.split(":")[1]))
81 for b in [a.lstrip() for a in line[2].split(",")]])
83 return parsed
87 # .--Power Supply Voltage------------------------------------------------.
88 # | ____ ____ _ |
89 # | | _ \ _____ _____ _ __ / ___| _ _ _ __ _ __ | |_ _ |
90 # | | |_) / _ \ \ /\ / / _ \ '__| \___ \| | | | '_ \| '_ \| | | | | |
91 # | | __/ (_) \ V V / __/ | ___) | |_| | |_) | |_) | | |_| | |
92 # | |_| \___/ \_/\_/ \___|_| |____/ \__,_| .__/| .__/|_|\__, | |
93 # | |_| |_| |___/ |
94 # | __ __ _ _ |
95 # | \ \ / /__ | | |_ __ _ __ _ ___ |
96 # | \ \ / / _ \| | __/ _` |/ _` |/ _ \ |
97 # | \ V / (_) | | || (_| | (_| | __/ |
98 # | \_/ \___/|_|\__\__,_|\__, |\___| |
99 # | |___/ |
100 # +----------------------------------------------------------------------+
101 # | |
102 # '----------------------------------------------------------------------'
104 icom_ps_volt_default_levels = (13.5, 13.2, 14.1, 14.4)
107 def inventory_icom_repeater_ps_volt(parsed):
108 if "ps_voltage" in parsed:
109 return [(None, "icom_ps_volt_default_levels")]
112 def check_icom_repeater_ps_volt(_no_item, params, parsed):
113 volt = parsed["ps_voltage"]
114 warn_lower, crit_lower, warn, crit = params
116 perfdata = [("voltage", volt, warn, crit, warn_lower, crit_lower)]
117 levelstext = " (warn/crit below %.1f/%.1f V and at or above %.1f/%.1f V)" % \
118 (warn_lower, crit_lower, warn, crit)
119 infotext = "%.1f V" % volt
121 if volt < crit_lower or volt >= crit:
122 status = 2
123 elif volt < warn_lower or volt >= warn:
124 status = 1
125 else:
126 status = 0
128 if status:
129 infotext += levelstext
131 return status, infotext, perfdata
134 check_info["icom_repeater.ps_volt"] = {
135 "inventory_function": inventory_icom_repeater_ps_volt,
136 "check_function": check_icom_repeater_ps_volt,
137 "service_description": "Power Supply Voltage",
138 "has_perfdata": True,
139 "group": "ps_voltage",
143 # .--PLL Voltage---------------------------------------------------------.
144 # | ____ _ _ __ __ _ _ |
145 # | | _ \| | | | \ \ / /__ | | |_ __ _ __ _ ___ |
146 # | | |_) | | | | \ \ / / _ \| | __/ _` |/ _` |/ _ \ |
147 # | | __/| |___| |___ \ V / (_) | | || (_| | (_| | __/ |
148 # | |_| |_____|_____| \_/ \___/|_|\__\__,_|\__, |\___| |
149 # | |___/ |
150 # +----------------------------------------------------------------------+
151 # | |
152 # '----------------------------------------------------------------------'
155 def inventory_icom_repeater_pll_volt(parsed):
156 if "rx_pll_lock_voltage" in parsed:
157 yield "RX", {}
158 if "tx_pll_lock_voltage" in parsed:
159 yield "TX", {}
162 def check_icom_repeater_pll_volt(item, params, parsed):
163 voltage = parsed[item.lower() + "_pll_lock_voltage"]
164 freq = parsed["repeater_frequency"][item.lower()]
165 paramlist = params.get(item.lower(), None)
167 if not paramlist:
168 perfdata = [("voltage", voltage)]
169 return 1, "Please specify parameters for PLL voltage", perfdata
171 i = 0
172 while i < len(paramlist):
173 if paramlist[i][0] >= freq:
174 warn_lower, crit_lower, warn, crit = paramlist[i - 1][1:]
176 infotext = "%.1f V" % voltage
177 levelstext = " (warn/crit below %.1f/%.1f V and at or above %.1f/%.1f V)" % \
178 (warn_lower, crit_lower, warn, crit)
179 if voltage < crit_lower or voltage >= crit:
180 status = 2
181 elif voltage < warn_lower or voltage >= warn:
182 status = 1
183 else:
184 status = 0
185 if status:
186 infotext += levelstext
188 perfdata = [("voltage", voltage, warn, crit, warn_lower, crit_lower)]
190 return status, infotext, perfdata
193 check_info["icom_repeater.pll_volt"] = {
194 "inventory_function": inventory_icom_repeater_pll_volt,
195 "check_function": check_icom_repeater_pll_volt,
196 "service_description": "%s PLL Lock Voltage",
197 "has_perfdata": True,
198 "group": "pll_lock_voltage",
202 # .--Temperature---------------------------------------------------------.
203 # | _____ _ |
204 # | |_ _|__ _ __ ___ _ __ ___ _ __ __ _| |_ _ _ _ __ ___ |
205 # | | |/ _ \ '_ ` _ \| '_ \ / _ \ '__/ _` | __| | | | '__/ _ \ |
206 # | | | __/ | | | | | |_) | __/ | | (_| | |_| |_| | | | __/ |
207 # | |_|\___|_| |_| |_| .__/ \___|_| \__,_|\__|\__,_|_| \___| |
208 # | |_| |
209 # +----------------------------------------------------------------------+
210 # | |
211 # '----------------------------------------------------------------------'
213 factory_settings["icom_repeater_temp_default_levels"] = {
214 "levels": (50, 55),
215 "levels_lower": (-20, -25),
219 def inventory_icom_repeater_temp(parsed):
220 if "temp" in parsed:
221 return [("System", {})]
224 def check_icom_repeater_temp(_no_item, params, parsed):
225 return check_temperature(
226 parsed["temp"],
227 params,
228 "icom_repeater_temp",
229 dev_unit=parsed["temp_devunit"],
230 dev_status=parsed["temp_devstatus"])
233 check_info["icom_repeater.temp"] = {
234 "inventory_function": inventory_icom_repeater_temp,
235 "default_levels_variable": "icom_repeater_temp_default_levels",
236 "check_function": check_icom_repeater_temp,
237 "service_description": "Temperature %s",
238 "has_perfdata": True,
239 "group": "temperature",
240 "includes": ["temperature.include"],
244 # .--Repeater Info-------------------------------------------------------.
245 # | ____ _ ___ __ |
246 # | | _ \ ___ _ __ ___ __ _| |_ ___ _ __ |_ _|_ __ / _| ___ |
247 # | | |_) / _ \ '_ \ / _ \/ _` | __/ _ \ '__| | || '_ \| |_ / _ \ |
248 # | | _ < __/ |_) | __/ (_| | || __/ | | || | | | _| (_) | |
249 # | |_| \_\___| .__/ \___|\__,_|\__\___|_| |___|_| |_|_| \___/ |
250 # | |_| |
251 # +----------------------------------------------------------------------+
252 # | |
253 # '----------------------------------------------------------------------'
256 def inventory_icom_repeater(parsed):
257 if parsed:
258 return [(None, None)]
259 return []
262 def check_icom_repeater(_no_item, _no_params, parsed):
263 yield 0, "ESN Number: %s" % parsed["esnno"]
265 infotext = "Repeater operation status: %s" % parsed["repop"]
266 if parsed["repop"] == "off":
267 yield 2, infotext
268 elif parsed["repop"] == "on":
269 yield 0, infotext
270 else:
271 yield 3, "Repeater operation status unknown"
274 check_info["icom_repeater"] = {
275 "parse_function": parse_icom_repeater,
276 "inventory_function": inventory_icom_repeater,
277 "check_function": check_icom_repeater,
278 "service_description": "Repeater Info",
279 "snmp_scan_function": lambda oid: "fr5000" in oid(".1.3.6.1.2.1.1.1.0").lower(),
280 "snmp_info": (
281 ".1.3.6.1.4.1.2021.8.1",
283 "1", # Index Number
284 "2", # SNMP item name
285 "101",
286 ]), # SNMP item value