Refactoring: Moved check parameters from unsorted.py to dedicated modules (CMK-1393)
[check_mk.git] / checks / poseidon_temp
blob79e8344766bd10f06c8014604ae5cdb377f2b436
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
4 factory_settings["poseidon_temp_default_levels"] = {}
7 def parse_poseidon_temp(info):
8 parsed = {}
9 if not info:
10 return
11 for name, state, value_string in info:
12 try:
13 temp = float(value_string.replace('C', ''))
14 except ValueError:
15 temp = None
16 parsed[name] = {'temp': temp, 'status': state}
17 return parsed
20 @get_parsed_item_data
21 def check_poseidon_temp(item, params, data):
22 sensor_states = {
23 '0': "invalid",
24 '1': "normal",
25 '2': "alarmstate",
26 '3': "alarm",
28 sensor_state_value = data.get('status')
29 sensor_state_txt = sensor_states.get(sensor_state_value)
30 mk_status = 0
31 if sensor_state_value != '1':
32 mk_status = 2
33 yield mk_status, "Sensor %s, State %s" % (item, sensor_state_txt)
35 temp = data.get('temp')
36 if temp:
37 yield check_temperature(temp, params, "poseidon_temp_%s" % item.replace(" ", "_"))
38 else:
39 yield 3, "No data for Sensor %s found" % item
42 check_info["poseidon_temp"] = {
43 "parse_function": parse_poseidon_temp,
44 "check_function": check_poseidon_temp,
45 "inventory_function": discover(),
46 "service_description": "Temperatur: %s",
47 "has_perfdata": True,
48 "group": "temperature",
49 "snmp_scan_function": lambda oid: oid(".1.3.6.1.2.1.1.2.0").startswith('.1.3.6.1.4.1.21796.3'),
50 "snmp_info": (".1.3.6.1.4.1.21796.3.3.3.1", ['2', '4', '5']),
51 "includes": ["temperature.include"],
52 "default_levels_variable": "poseidon_temp_default_levels",