2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
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
):
37 vac
, watt
, ampere
, load_perc
= map(int, line
[1:])
44 warn
, crit
= params
.get('output_voltage_max', (None, None))
45 perf
.append(('volt', vac
, warn
, crit
))
46 base_msg
= "%d Volt" % vac
48 levels
= " its to high (Warning/Critical %d/%d)" % (warn
, crit
)
51 if crit
and vac
> crit
:
53 base_msg
+= levels
+ "(!!)"
54 elif warn
and vac
> warn
:
56 base_msg
+= levels
+ "(!)"
59 warn
, crit
= params
.get('output_voltage_min', (None, None))
61 levels
= " its to low (warn/crit %d/%d)" % (warn
, crit
)
64 if crit
and vac
< crit
:
66 base_msg
+= levels
+ "(!!)"
67 elif warn
and vac
< warn
:
69 base_msg
+= levels
+ "(!)"
71 messages
.append(base_msg
)
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))
83 levels
= " its to high (warn/crit %d/%d) " % (warn
, crit
)
86 base_msg
= "Load: %d%%" % load_perc
87 if crit
and load_perc
> crit
:
89 base_msg
+= " " + levels
+ "(!!)"
90 elif warn
and load_perc
> warn
:
92 base_msg
+= " " + levels
+ "(!)"
93 warn
, crit
= params
.get('load_perc_min', (None, None))
95 levels
= " its to low (warn/crit %d/%d) " % (warn
, crit
)
98 if crit
and load_perc
< crit
:
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"),
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