GUI CSS: Removed snapin styles from py modules and added a _snapins.scss for the...
[check_mk.git] / checks / apc_ats_output
blob64cee7197bd626e9bda8021389f7ad4b8a1587b3
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2014 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 apc_ats_output_default_levels = {"output_voltage_max": (240, 250), "load_perc_max": (85, 95)}
30 def inventory_apc_ats_output(info):
31 return [(x[0], "apc_ats_output_default_levels") for x in info]
34 def check_apc_ats_output(item, params, info):
35 for line in info:
36 if line[0] == item:
37 vac, watt, ampere, load_perc = map(int, line[1:])
38 ampere = ampere / 10
39 state = 0
40 messages = []
41 perf = []
43 # Output Voltage Max
44 warn, crit = params.get('output_voltage_max', (None, None))
45 perf.append(('volt', vac, warn, crit))
46 base_msg = "%d Volt" % vac
47 if warn and crit:
48 levels = " its to high (Warning/Critical %d/%d)" % (warn, crit)
49 else:
50 levels = ""
51 if crit and vac > crit:
52 state = 2
53 base_msg += levels + "(!!)"
54 elif warn and vac > warn:
55 state = 1
56 base_msg += levels + "(!)"
58 # Output Voltage Min
59 warn, crit = params.get('output_voltage_min', (None, None))
60 if warn and crit:
61 levels = " its to low (warn/crit %d/%d)" % (warn, crit)
62 else:
63 levels = ""
64 if crit and vac < crit:
65 state = 2
66 base_msg += levels + "(!!)"
67 elif warn and vac < warn:
68 state = max(state, 1)
69 base_msg += levels + "(!)"
71 messages.append(base_msg)
73 # Watt
74 perf.append(('watt', watt))
75 messages.append("%d Watt" % watt)
77 # Ampere and Percent Load
78 perf.append(("ampere", ampere))
79 messages.append("%d Ampere" % ampere)
81 warn, crit = params.get('load_perc_max', (None, None))
82 if warn and crit:
83 levels = " its to high (warn/crit %d/%d) " % (warn, crit)
84 else:
85 levels = ""
86 base_msg = "Load: %d%%" % load_perc
87 if crit and load_perc > crit:
88 state = 2
89 base_msg += " " + levels + "(!!)"
90 elif warn and load_perc > warn:
91 state = max(state, 1)
92 base_msg += " " + levels + "(!)"
93 warn, crit = params.get('load_perc_min', (None, None))
94 if warn and crit:
95 levels = " its to low (warn/crit %d/%d) " % (warn, crit)
96 else:
97 levels = ""
98 if crit and load_perc < crit:
99 state = 2
100 base_msg += " " + levels + "(!!)"
101 elif warn and load_perc < warn:
102 state = max(state, 1)
103 base_msg += " " + levels + "(!)"
104 perf.append(("load_perc", load_perc, warn, crit))
105 messages.append(base_msg)
107 return state, "Running with: " + ", ".join(messages), perf
108 return 3, "Power phase not found"
111 check_info["apc_ats_output"] = {
112 "check_function": check_apc_ats_output,
113 "group": "apc_ats_output",
114 "inventory_function": inventory_apc_ats_output,
115 "service_description": "Phase %s output",
116 "has_perfdata": True,
117 "snmp_scan_function": lambda oid: ".1.3.6.1.4.1.318.1.3.11" in oid(".1.3.6.1.2.1.1.2.0"),
118 "snmp_info": (
119 ".1.3.6.1.4.1.318.1.1.8.5.4.3.1",
121 "1", # atsOutputPhaseTableIndex
122 #"2", # atsOutputPhaseIndex 1-3 = Phase 1-3, 4 = Neutral
123 "3", # atsOutputVoltage (VAC)
124 "13", # atsOutputPower (Watt)
125 "4", # atsOutputCurrent (0.1 AMPERE)
126 "10", # atsOutputPercentLoad