Refactoring: Moved check parameters from unsorted.py to dedicated modules (CMK-1393)
[check_mk.git] / checks / cisco_asa_conn
blobb39a13090f7b05044a5932cb4184f1211e815a08
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2017 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 # example output
30 def parse_cisco_asa_conn(info):
31 parsed = {}
32 for line in info[0]:
33 parsed[line[0]] = [line[1]]
34 for line in info[2]:
35 parsed[line[0]].append(line[1])
36 parsed[line[0]].append(line[2])
37 for line in info[1]:
38 parsed[line[0]].append(line[1])
40 # Example:
41 # parsed = { u'4': [u'outside-adsl', u'1', u'1', u'8.8.8.8'] }
42 return parsed
45 def inventory_cisco_asa_conn(parsed):
46 for key, values in parsed.iteritems():
47 if values[1] == "1" and len(values) == 4:
48 yield (key, None)
51 def check_cisco_asa_conn(item, _no_params, parsed):
52 translate_status = {
53 "1": (0, "up"),
54 "2": (2, "down"),
55 "3": (3, "testing"),
56 "4": (3, "unknown"),
57 "5": (2, "dormant"),
58 "6": (2, "not present"),
59 "7": (2, "lower layer down"),
62 for key, values in parsed.iteritems():
63 if item == key:
64 yield 0, "Name: %s" % values[0]
66 if not values[3] == "":
67 yield 0, "IP: %s" % values[3]
68 else: # CRIT if no IP is assigned
69 yield 2, "IP: Not found!"
71 state, state_readable = translate_status[values[2]]
72 yield state, "Status: %s" % state_readable
75 check_info['cisco_asa_conn'] = {
76 'parse_function' : parse_cisco_asa_conn,
77 'inventory_function' : inventory_cisco_asa_conn,
78 'check_function' : check_cisco_asa_conn,
79 'service_description' : 'Connection %s',
80 'snmp_info' : [('.1.3.6.1.2.1.31.1.1.1', [
81 OID_END, # Index
82 "1", # IF-MIB::ifName
83 ]),
84 ('.1.3.6.1.2.1.4.20.1', [
85 "2", # IP-MIB::ipAdEntIfIndex
86 "1", # IP-MIB::ipAdEntAddr
87 ]),
88 ('.1.3.6.1.2.1.2.2.1', [
89 OID_END, # Index
90 "7", # IF-MIB::ifAdminStatus
91 "8", # IF-MIB::ifOperStatus
92 ])],
93 'snmp_scan_function' : lambda oid: oid(".1.3.6.1.2.1.1.1.0").lower().startswith("cisco adaptive security") \
94 or "cisco pix security" in oid(".1.3.6.1.2.1.1.1.0").lower(),