GUI CSS: Removed snapin styles from py modules and added a _snapins.scss for the...
[check_mk.git] / checks / eltek_battery
blob80e1f68a736c63f8c5a8ff67d67fb4a740f43835
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2016 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 # .1.3.6.1.4.1.12148.9.3.1.0 --> ELTEK-DISTRIBUTED-MIB::batteryName.0
28 # .1.3.6.1.4.1.12148.9.3.2.0 5485 --> ELTEK-DISTRIBUTED-MIB::batteryVoltage.0
29 # .1.3.6.1.4.1.12148.9.3.3.0 0 --> ELTEK-DISTRIBUTED-MIB::batteryCurrent.0
30 # .1.3.6.1.4.1.12148.9.3.4.0 19 --> ELTEK-DISTRIBUTED-MIB::batteryTemp.0
31 # .1.3.6.1.4.1.12148.9.3.5.0 0 --> ELTEK-DISTRIBUTED-MIB::batteryBreakerStatus.0
33 # .--breaker status------------------------------------------------------.
34 # | _ _ _ _ |
35 # | | |__ _ __ ___ __ _| | _____ _ __ ___| |_ __ _| |_ _ _ ___ |
36 # | | '_ \| '__/ _ \/ _` | |/ / _ \ '__| / __| __/ _` | __| | | / __| |
37 # | | |_) | | | __/ (_| | < __/ | \__ \ || (_| | |_| |_| \__ \ |
38 # | |_.__/|_| \___|\__,_|_|\_\___|_| |___/\__\__,_|\__|\__,_|___/ |
39 # | |
40 # +----------------------------------------------------------------------+
41 # | main check |
42 # '----------------------------------------------------------------------'
45 def parse_eltek_battery(info):
46 voltage, current, temp, breaker_status = info[0]
47 return {
48 'supply': {
49 "Supply": {
50 'voltage': float(voltage) / 100,
51 'current': float(current),
54 'temp': float(temp),
55 'breaker': breaker_status,
59 def inventory_eltek_battery(parsed):
60 if "breaker" in parsed:
61 return [(None, None)]
64 def check_eltek_battery(_no_item, _no_params, parsed):
65 if "breaker" in parsed:
66 map_status = {
67 "0": (0, "normal"),
68 "1": (2, "alarm"),
70 state, state_readable = map_status[parsed["breaker"]]
71 return state, "Status: %s" % state_readable
74 check_info['eltek_battery'] = {
75 'parse_function': parse_eltek_battery,
76 'inventory_function': inventory_eltek_battery,
77 'check_function': check_eltek_battery,
78 'service_description': 'Battery Breaker Status',
79 'snmp_info': (
80 ".1.3.6.1.4.1.12148.9.3",
82 "2", # batteryVoltage
83 "3", # batteryCurrent
84 "4", # batteryTemp
85 "5", # batteryBreakerStatus
86 ]),
87 'snmp_scan_function': lambda oid: oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.12148.9"),
88 'includes': ['elphase.include', 'temperature.include'],
92 # .--temperature---------------------------------------------------------.
93 # | _ _ |
94 # | | |_ ___ _ __ ___ _ __ ___ _ __ __ _| |_ _ _ _ __ ___ |
95 # | | __/ _ \ '_ ` _ \| '_ \ / _ \ '__/ _` | __| | | | '__/ _ \ |
96 # | | || __/ | | | | | |_) | __/ | | (_| | |_| |_| | | | __/ |
97 # | \__\___|_| |_| |_| .__/ \___|_| \__,_|\__|\__,_|_| \___| |
98 # | |_| |
99 # '----------------------------------------------------------------------'
101 # suggested by customer
102 factory_settings['eltek_battery_temp_default_variables'] = {
103 'levels': (27.0, 35.0),
107 def inventory_eltek_battery_temp(parsed):
108 if 'temp' in parsed:
109 return [("Battery", {})]
112 def check_eltek_battery_temp(item, params, parsed):
113 # For temp checks we need an item but we have only one
114 if 'temp' in parsed:
115 return check_temperature(parsed['temp'], params, "eltek_battery_temp_Battery")
118 check_info['eltek_battery.temp'] = {
119 'inventory_function': inventory_eltek_battery_temp,
120 'check_function': check_eltek_battery_temp,
121 'service_description': 'Temperature %s',
122 'has_perfdata': True,
123 'group': 'temperature',
124 'default_levels_variable': 'eltek_battery_temp_default_variables',
128 # .--phase---------------------------------------------------------------.
129 # | _ |
130 # | _ __ | |__ __ _ ___ ___ |
131 # | | '_ \| '_ \ / _` / __|/ _ \ |
132 # | | |_) | | | | (_| \__ \ __/ |
133 # | | .__/|_| |_|\__,_|___/\___| |
134 # | |_| |
135 # '----------------------------------------------------------------------'
137 # suggested by customer
138 factory_settings['eltek_battery_phase_default_variables'] = {
139 'voltage': (52, 48),
140 'current': (50, 76),
143 check_info['eltek_battery.supply'] = {
144 'inventory_function': lambda parsed: inventory_elphase(parsed["supply"]),
145 'check_function': lambda item, params, parsed: check_elphase(item, params, parsed["supply"]),
146 'service_description': 'Battery %s',
147 'has_perfdata': True,
148 'group': 'el_inphase',
149 'default_levels_variable': 'eltek_battery_temp_phase_variables',