2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
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------------------------------------------------------.
35 # | | |__ _ __ ___ __ _| | _____ _ __ ___| |_ __ _| |_ _ _ ___ |
36 # | | '_ \| '__/ _ \/ _` | |/ / _ \ '__| / __| __/ _` | __| | | / __| |
37 # | | |_) | | | __/ (_| | < __/ | \__ \ || (_| | |_| |_| \__ \ |
38 # | |_.__/|_| \___|\__,_|_|\_\___|_| |___/\__\__,_|\__|\__,_|___/ |
40 # +----------------------------------------------------------------------+
42 # '----------------------------------------------------------------------'
45 def parse_eltek_battery(info
):
46 voltage
, current
, temp
, breaker_status
= info
[0]
50 'voltage': float(voltage
) / 100,
51 'current': float(current
),
55 'breaker': breaker_status
,
59 def inventory_eltek_battery(parsed
):
60 if "breaker" in parsed
:
64 def check_eltek_battery(_no_item
, _no_params
, parsed
):
65 if "breaker" in parsed
:
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',
80 ".1.3.6.1.4.1.12148.9.3",
85 "5", # batteryBreakerStatus
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---------------------------------------------------------.
94 # | | |_ ___ _ __ ___ _ __ ___ _ __ __ _| |_ _ _ _ __ ___ |
95 # | | __/ _ \ '_ ` _ \| '_ \ / _ \ '__/ _` | __| | | | '__/ _ \ |
96 # | | || __/ | | | | | |_) | __/ | | (_| | |_| |_| | | | __/ |
97 # | \__\___|_| |_| |_| .__/ \___|_| \__,_|\__|\__,_|_| \___| |
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
):
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
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---------------------------------------------------------------.
130 # | _ __ | |__ __ _ ___ ___ |
131 # | | '_ \| '_ \ / _` / __|/ _ \ |
132 # | | |_) | | | | (_| \__ \ __/ |
133 # | | .__/|_| |_|\__,_|___/\___| |
135 # '----------------------------------------------------------------------'
137 # suggested by customer
138 factory_settings
['eltek_battery_phase_default_variables'] = {
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',