Refactoring: Changed all check parameters starting with an 'o' to the new rulespec...
[check_mk.git] / checks / cisco_asa_failover
blobc5dbc4d08045787981bce2edb95c4d3ed8a93e75
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 # .1.3.6.1.4.1.9.9.147.1.2.1.1.1.2.4 "Failover LAN Interface"
28 # .1.3.6.1.4.1.9.9.147.1.2.1.1.1.2.6 "Primary unit (this device)"
29 # .1.3.6.1.4.1.9.9.147.1.2.1.1.1.2.7 "Secondary unit"
30 # .1.3.6.1.4.1.9.9.147.1.2.1.1.1.3.4 2
31 # .1.3.6.1.4.1.9.9.147.1.2.1.1.1.3.6 9 < These two values flip during
32 # .1.3.6.1.4.1.9.9.147.1.2.1.1.1.3.7 10 < failover
33 # .1.3.6.1.4.1.9.9.147.1.2.1.1.1.4.4 "LAN_FO GigabitEthernet0/0.777"
34 # .1.3.6.1.4.1.9.9.147.1.2.1.1.1.4.6 "Active unit"
35 # .1.3.6.1.4.1.9.9.147.1.2.1.1.1.4.7 "Standby unit"
37 # [['Failover LAN Interface', '2', 'LAN_FO GigabitEthernet0/0.777'],
38 # ['Primary unit', '9', 'Active unit'],
39 # ['Secondary unit (this device)', '10', 'Standby unit']]
41 factory_settings["cisco_asa_failover_default_levels"] = {
42 "primary": "active",
43 "secondary": "standby",
44 "failover_state": 1,
48 def parse_cisco_asa_failover(info):
49 def parse_line(line):
50 role = line[0].split(" ")[0].lower()
51 data = [role, line[1], line[2].lower()]
52 return data
54 parsed = {}
55 for line in info:
56 if "this device" in line[0].lower():
57 parsed["local"] = parse_line(line)
58 elif "failover" in line[0].lower():
59 parsed["failover"] = line
60 else:
61 parsed["remote"] = parse_line(line)
62 return parsed
65 def inventory_cisco_asa_failover(parsed):
66 if not "failover off" in parsed["local"][2]:
67 yield (None, {})
70 def check_cisco_asa_failover(_no_item, params, parsed):
71 asa_state_names = {
72 "1": "other",
73 "2": "up",
74 "3": "down",
75 "4": "error",
76 "5": "overTemp",
77 "6": "busy",
78 "7": "noMedia",
79 "8": "backup",
80 "9": "active",
81 "10": "standby",
84 role = parsed["local"][0]
85 status = parsed["local"][1]
86 status_readable = asa_state_names[status]
87 status_detail = parsed["local"][2]
89 yield 0, "Device (%s) is the %s" % (role, status_detail)
91 if not params[role] == status_readable:
92 yield params["failover_state"], \
93 "(The %s device should be %s)" % (role, params[role])
95 if not status in ["9", "10"]:
96 yield 1, "Unhandled state %s reported" % status_readable
99 check_info["cisco_asa_failover"] = {
100 "parse_function" : parse_cisco_asa_failover,
101 "inventory_function" : inventory_cisco_asa_failover,
102 "check_function" : check_cisco_asa_failover,
103 "service_description" : "Cluster Status",
104 "snmp_scan_function" : lambda oid: oid(".1.3.6.1.2.1.1.1.0").lower().startswith("cisco adaptive security") \
105 or "cisco pix security" in oid(".1.3.6.1.2.1.1.1.0").lower(),
106 "snmp_info" : (".1.3.6.1.4.1.9.9.147.1.2.1.1.1", [
107 "2", # CISCO-FIREWALL-MIB::cfwHardwareInformation
108 "3", # CISCO-FIREWALL-MIB::cfwHardwareStatusValue
109 "4", # CISCO-FIREWALL-MIB::cfwHardwareStatusDetail
111 "group" : "cisco_asa_failover",
112 "default_levels_variable" : "cisco_asa_failover_default_levels",