Cleanup config.nodes_of
[check_mk.git] / checks / fortinet_controller_aps
blob6618e8c10b8e896fc6a3784f1fc8b09c5f8a1f4e
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.15983.1.1.4.2.1.1.2.1 AP1
28 # .1.3.6.1.4.1.15983.1.1.4.2.1.1.4.1 1
29 # .1.3.6.1.4.1.15983.1.1.4.2.1.1.8.1
30 # .1.3.6.1.4.1.15983.1.1.4.2.1.1.17.1 990625700
31 # .1.3.6.1.4.1.15983.1.1.4.2.1.1.26.1 1
32 # .1.3.6.1.4.1.15983.1.1.4.2.1.1.27.1 3
33 # .1.3.6.1.4.1.15983.1.1.3.1.7.1.3.1 "00 0C E6 XX XX XX "
34 # .1.3.6.1.4.1.15983.1.1.3.1.7.1.5.1 1
35 # .1.3.6.1.4.1.15983.1.1.3.1.7.1.9.1 1
38 def parse_fortinet_controller_aps(info):
39 map_oper_state = {
40 '0': 'unknown',
41 '1': 'enabled',
42 '2': 'disabled',
43 '3': 'no license',
44 '4': 'enabled WN license',
45 '5': 'power down',
48 map_availability = {
49 '1': 'power off',
50 '2': 'offline',
51 '3': 'online',
52 '4': 'failed',
53 '5': 'in test',
54 '6': 'not installed',
57 parsed = {}
58 ap_table, client_table = info
59 for descr, id_, location, uptime_str, oper_state, availability in ap_table:
60 try:
61 uptime = int(uptime_str)
62 except ValueError:
63 uptime = None
64 parsed.setdefault(
65 id_, {
66 "descr": descr,
67 "location": location,
68 "uptime": uptime,
69 "operational": map_oper_state[oper_state],
70 "availability": map_availability[availability],
71 "clients_count_24": 0,
72 "clients_count_5": 0,
75 for client, id_ in client_table:
76 inst = parsed.get(id_)
77 if inst is None:
78 continue
79 if client == '1':
80 inst["clients_count_24"] += 1
81 elif client == '2':
82 inst["clients_count_5"] += 1
83 return parsed
86 def inventory_fortinet_controller_aps(parsed):
87 for key, values in parsed.iteritems():
88 if values["availability"] != "not installed":
89 yield key, {}
92 def check_fortinet_controller_aps(item, params, parsed):
93 data = parsed.get(item)
94 if data is None:
95 return
97 oper_state = data["operational"]
98 state = 0
99 if oper_state == 'unknown':
100 state = 3
101 elif oper_state in ['disabled', 'no license', 'power down']:
102 state = 1
103 yield state, "[%s] Operational: %s" % (data["descr"], oper_state)
105 avail_state = data["availability"]
106 state = 0
107 if avail_state == 'failed':
108 state = 2
109 elif avail_state in ['power off', 'offline', 'in test', 'not installed']:
110 state = 1
111 yield state, "Availability: %s" % avail_state
113 client_count_24 = data["clients_count_24"]
114 client_count_5 = data["clients_count_5"]
115 yield 0, "Connected clients (2,4 ghz/5 ghz): %s/%s"\
116 % (client_count_24, client_count_5),\
117 [('5ghz_clients', client_count_5),
118 ('24ghz_clients', client_count_24)]
120 uptime = data['uptime']
121 if uptime:
122 yield 0, "Up since %s" % get_timestamp_human_readable(uptime),\
123 [('uptime', uptime)]
125 location = data.get('location')
126 if location:
127 yield 0, "Located at %s" % location
130 check_info['fortinet_controller_aps'] = {
131 'parse_function': parse_fortinet_controller_aps,
132 'inventory_function': inventory_fortinet_controller_aps,
133 'check_function': check_fortinet_controller_aps,
134 'service_description': 'AP %s',
135 'has_perfdata': True,
136 'snmp_info': [
138 '.1.3.6.1.4.1.15983.1.1.4.2.1.1',
140 '2', # MERU-CONFIG-AP-MIB::mwApDescr
141 '4', # MERU-CONFIG-AP-MIB::mwApID
142 '8', # MERU-CONFIG-AP-MIB::mwApLocation
143 '17', # MERU-CONFIG-AP-MIB::mwApUpTime
144 '26', # MERU-CONFIG-AP-MIB::mwApOperationalState
145 '27' # MERU-CONFIG-AP-MIB::mwApAvailabilityStatus
148 '.1.3.6.1.4.1.15983.1.1.3.1.7.1',
150 '5', # MERU-GLOBAL-STATISTICS-MIB::mwApStationStatsIfIndex
151 '9', # MERU-GLOBAL-STATISTICS-MIB::mwApStationStatsNmsApNodeId
154 'snmp_scan_function': lambda oid: '.1.3.6.1.4.1.15983' in oid('.1.3.6.1.2.1.1.2.0').lower(),