Refactoring: Changed all check parameters starting with an 'o' to the new rulespec...
[check_mk.git] / checks / orion_system
blob48cdd0a900002d7a52987f81ce7af8ccf537c5d2
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2018 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.
28 def parse_orion_system(info):
29 map_charge_states = {
30 '1': (0, 'float charging'),
31 '2': (0, 'discharge'),
32 '3': (0, 'equalize'),
33 '4': (0, 'boost'),
34 '5': (0, 'battery test'),
35 '6': (0, 'recharge'),
36 '7': (0, 'separate charge'),
37 '8': (0, 'event control charge'),
40 system_voltage, load_current, battery_current, battery_temp,\
41 charge_state, _battery_current_limit, rectifier_current,\
42 system_power = info[0]
44 parsed = {
45 'charging': {
46 'Battery': map_charge_states.get(charge_state, (3, "unknown[%s]" % charge_state))
48 'temperature': {},
49 'electrical': {},
52 if battery_temp != "2147483647":
53 # From MIB: The max. value 2147483647 is used to indicate an invalid value."
54 parsed['temperature']['Battery'] = int(battery_temp) * 0.1
56 for what, value, factor in [
57 ('voltage', system_voltage, 0.01),
58 ('current', load_current, 0.1),
59 ('power', system_power, 0.1),
61 if value != "2147483647":
62 # From MIB: The max. value 2147483647 is used to indicate an invalid value."
63 system_data = parsed['electrical'].setdefault('System', {})
64 system_data[what] = int(value) * factor
66 for item, value in [
67 ('Battery', battery_current),
68 ('Rectifier', rectifier_current),
70 if value != "2147483647":
71 # From MIB: The max. value 2147483647 is used to indicate an invalid value."
72 item_data = parsed['electrical'].setdefault(item, {})
73 item_data['current'] = int(battery_temp) * 0.1
75 return parsed
78 def inventory_orion_system_temp(parsed):
79 for entity in parsed["temperature"]:
80 yield entity, {}
83 def check_orion_system_temp(item, params, parsed):
84 if item in parsed["temperature"]:
85 return check_temperature(parsed['temperature'][item], params, 'orion_system_temp.%s' % item)
88 check_info['orion_system'] = {
89 'parse_function': parse_orion_system,
90 'inventory_function': inventory_orion_system_temp,
91 'check_function': check_orion_system_temp,
92 'service_description': 'Temperature %s',
93 'snmp_info': (
94 '.1.3.6.1.4.1.20246.2.3.1.1.1.2.3',
96 '1', # ORION-BASE-MIB::dcSystemVoltage
97 '2', # ORION-BASE-MIB::dcLoadCurrent
98 '3', # ORION-BASE-MIB::dcBatteryCurrent
99 '4', # ORION-BASE-MIB::dcBatteryTemperature
100 '5', # ORION-BASE-MIB::dcChargeState
101 '6', # ORION-BASE-MIB::dcCurrentLimit
102 '7', # ORION-BASE-MIB::dcRectifierCurrent
103 '8', # ORION-BASE-MIB::dcSystemPower
105 'snmp_scan_function': lambda oid: oid('.1.3.6.1.2.1.1.2.0').startswith('.1.3.6.1.4.1.20246'),
106 'has_perfdata': True,
107 'group': 'temperature',
108 'includes': ['temperature.include'],
112 def inventory_orion_system_charging(parsed):
113 for entity in parsed["charging"]:
114 yield entity, {}
117 def check_orion_system_charging(item, params, parsed):
118 if item in parsed["charging"]:
119 state, state_readable = parsed["charging"][item]
120 return state, "Status: %s" % state_readable
123 check_info['orion_system.charging'] = {
124 'inventory_function': inventory_orion_system_charging,
125 'check_function': check_orion_system_charging,
126 'service_description': 'Charge %s',
130 def inventory_orion_system_electrical(parsed):
131 return inventory_elphase(parsed["electrical"])
134 def check_orion_system_electrical(item, params, parsed):
135 return check_elphase(item, params, parsed["electrical"])
138 check_info['orion_system.dc'] = {
139 'inventory_function': inventory_orion_system_electrical,
140 'check_function': check_orion_system_electrical,
141 'service_description': 'Direct Current %s',
142 'has_perfdata': True,
143 'group': 'ups_outphase',
144 'includes': ['elphase.include'],