Cleanup config.nodes_of
[check_mk.git] / checks / apc_ats_status
blobc76ee5a9ca4e38da099c3d17677d39d00041b28d
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.
28 def inventory_apc_ats_status(info):
29 if len(info) == 1:
30 return [(None, saveint(info[0][1]))]
31 return []
34 def check_apc_ats_status(_no_item, source, info):
35 comstatus, selected_source, redundancy, overcurrent, ps5, ps24 = map(saveint, info[0])
36 state = 0
37 messages = []
39 #current source of power
40 sources = {1: "A", 2: "B"}
41 if source != selected_source:
42 state = 2
43 messages.append("Power source Changed from %s to %s(!!)" % \
44 (sources[source], sources[selected_source]))
45 else:
46 messages.append("Power source %s selected" % sources[source])
48 #current communication status of the Automatic Transfer Switch.
49 if comstatus == 1:
50 state = max(1, state)
51 messages.append("Communication Status: never Discovered(!)")
52 elif comstatus == 3:
53 state = 2
54 messages.append("Communication Status: lost(!!)")
56 # current redundancy state of the ATS.
57 # Lost(1) indicates that the ATS is unable to switch over to the alternate power source
58 # if the current source fails. Redundant(2) indicates that the ATS will switch
59 # over to the alternate power source if the current source fails.
60 if redundancy != 2:
61 state = 2
62 messages.append("redundancy lost(!!)")
63 else:
64 messages.append("Device fully redundant")
66 # current state of the ATS. atsOverCurrent(1) indicates that the ATS has i
67 # exceeded the output current threshold and will not allow a switch
68 # over to the alternate power source if the current source fails.
69 # atsCurrentOK(2) indicates that the output current is below the output current threshold.
70 if overcurrent == 1:
71 state = 2
72 messages.append("exceedet ouput current threshold(!!)")
74 # 5Volt power supply
75 if ps5 != 2:
76 state = 2
77 messages.append("5V power supply failed(!!)")
79 # 24Volt power supply
80 if ps24 != 2:
81 state = 2
82 messages.append("24V power suppy failed(!!)")
84 return state, ", ".join(messages)
87 check_info["apc_ats_status"] = {
88 "check_function": check_apc_ats_status,
89 "inventory_function": inventory_apc_ats_status,
90 "service_description": "ATS Status",
91 "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"),
92 "snmp_info": (
93 ".1.3.6.1.4.1.318.1.1.8.5.1",
95 "1.0", # atsStatusCommStatus
96 "2.0", # atsStatusSelectedSource
97 "3.0", # atsStatusRedundancyState
98 "4.0", # atsStatusOverCurrentState
99 "5.0", # atsStatus5VPowerSupply
100 "6.0", # atsStatus24VPowerSupply