GUI CSS: Deployed view styles for layouts (CMK-1171)
[check_mk.git] / checks / gude_powerbanks
blob1af07081eeb9e028f8b58c2326514c5870c1515e
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 # Knowledge from customer:
28 # Devices with OID_END=38 are 12 port power switches with two powerbanks.
29 # Means each powerbank has 6 outlets. Here we can use ChanStatus in order
30 # to find out if one powerbank is enabled/used.
32 # Device with OID_END=19 is a simple switch outlet: 1 Port and 1 powerbank
33 # Once it's plugged in, the state is "on". Thus we use PortState in
34 # discovering function.
36 factory_settings["gude_powerbank_default_levels"] = {
37 "voltage": (220, 210),
38 "current": (15, 16),
42 def parse_gude_powerbanks(info):
43 map_port_states = {
44 "0": (2, "off"),
45 "1": (0, "on"),
47 map_channel_states = {
48 "0": (2, "data not active"),
49 "1": (0, "data valid"),
52 ports = dict(info[0])
53 parsed = {}
54 for oid_idx, dev_state, energy_str, active_power_str, \
55 current_str, volt_str, freq_str, appower_str in info[1]:
57 oid, idx = oid_idx.split(".")
58 device_state = None
59 if oid in ["19"]:
60 device_state = map_port_states[ports[oid_idx]]
61 if oid in ["38"]:
62 device_state = map_channel_states[dev_state]
64 if device_state is None:
65 continue
67 parsed.setdefault(idx, {"device_state": device_state})
69 for what, key, factor in [
70 (energy_str, "energy", 1.0),
71 (active_power_str, "power", 1.0),
72 (current_str, "current", 0.001),
73 (volt_str, "voltage", 1.0),
74 (freq_str, "frequency", 0.01),
75 (appower_str, "appower", 1.0),
77 parsed[idx][key] = float(what) * factor
79 return parsed
82 def inventory_gude_powerbanks(parsed):
83 return [(powerbank, {})
84 for powerbank, attrs in parsed.items()
85 if attrs["device_state"][1] not in ["off", "data not active"]]
88 check_info['gude_powerbanks'] = {
89 'parse_function' : parse_gude_powerbanks,
90 'inventory_function' : inventory_gude_powerbanks,
91 'check_function' : check_elphase,
92 'service_description' : 'Powerbank %s',
93 'has_perfdata' : True,
94 'snmp_info' : [('.1.3.6.1.4.1.28507', ['19', '38'], [
95 OID_END,
96 "1.3.1.2.1.3", # GUDEADS=EPC****-MIB::epc****PortState
97 ]),
98 ('.1.3.6.1.4.1.28507', ['19', '38'], [
99 OID_END,
100 "1.5.1.2.1.2", # GUDEADS-EPC****-MIB::epc****ChanStatus
101 "1.5.1.2.1.3", # GUDEADS-EPC****-MIB::epc****AbsEnergyActive
102 "1.5.1.2.1.4", # GUDEADS-EPC****-MIB::epc****PowerActive
103 "1.5.1.2.1.5", # GUDEADS-EPC****-MIB::epc****Current
104 "1.5.1.2.1.6", # GUDEADS-EPC****-MIB::epc****Voltage
105 "1.5.1.2.1.7", # GUDEADS-EPC****-MIB::epc****Frequency
106 "1.5.1.2.1.10", # GUDEADS-EPC****-MIB::epc****PowerApparent
107 ])],
108 'snmp_scan_function' : lambda oid: oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.28507.19") or \
109 oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.28507.38"),
110 'default_levels_variable' : 'gude_powerbank_default_levels',
111 'group' : 'el_inphase',
112 'includes' : [ 'elphase.include' ],