Refactoring: Moved check parameters from unsorted.py to dedicated modules (CMK-1393)
[check_mk.git] / checks / infoblox.include
blobff134e87f970fadcb2b941ff789d2ea0d756e3bf
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2016 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 scan_infoblox(oid):
29 return "infoblox" in oid(".1.3.6.1.2.1.1.1.0").lower() or \
30 oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.7779.1")
33 # .--services------------------------------------------------------------.
34 # | _ |
35 # | ___ ___ _ ____ _(_) ___ ___ ___ |
36 # | / __|/ _ \ '__\ \ / / |/ __/ _ \/ __| |
37 # | \__ \ __/ | \ V /| | (_| __/\__ \ |
38 # | |___/\___|_| \_/ |_|\___\___||___/ |
39 # | |
40 # '----------------------------------------------------------------------'
43 def parse_infoblox_services(info):
44 map_service_ids = {
45 "1": "dhcp",
46 "2": "dns",
47 "3": "ntp",
48 "4": "tftp",
49 "5": "http-file-dist",
50 "6": "ftp",
51 "7": "bloxtools-move",
52 "8": "bloxtools",
53 "9": "node-status",
54 "10": "disk-usage",
55 "11": "enet-lan",
56 "12": "enet-lan2",
57 "13": "enet-ha",
58 "14": "enet-mgmt",
59 "15": "lcd",
60 "16": "memory",
61 "17": "replication",
62 "18": "db-object",
63 "19": "raid-summary",
64 "20": "raid-disk1",
65 "21": "raid-disk2",
66 "22": "raid-disk3",
67 "23": "raid-disk4",
68 "24": "raid-disk5",
69 "25": "raid-disk6",
70 "26": "raid-disk7",
71 "27": "raid-disk8",
72 "28": "fan1",
73 "29": "fan2",
74 "30": "fan3",
75 "31": "fan4",
76 "32": "fan5",
77 "33": "fan6",
78 "34": "fan7",
79 "35": "fan8",
80 "36": "power-supply1",
81 "37": "power-supply2",
82 "38": "ntp-sync",
83 "39": "cpu1-temp",
84 "40": "cpu2-temp",
85 "41": "sys-temp",
86 "42": "raid-battery",
87 "43": "cpu-usage",
88 "44": "ospf",
89 "45": "bgp",
90 "46": "mgm-service",
91 "47": "subgrid-conn",
92 "48": "network-capacity",
93 "49": "reporting",
94 "50": "dns-cache-acceleration",
95 "51": "ospf6",
96 "52": "swap-usage",
97 "53": "discovery-consolidator",
98 "54": "discovery-collector",
99 "55": "discovery-capacity",
100 "56": "threat-protection",
101 "57": "cloud-api",
102 "58": "threat-analytics",
103 "59": "taxii",
106 map_status_id = {
107 "1": "working",
108 "2": "warning",
109 "3": "failed",
110 "4": "inactive",
111 "5": "unknown",
114 parsed = {}
115 for _node, service_id, status_id, description in info:
116 status = map_status_id.get(status_id, "unexpected")
117 if status in ["inactive", "unknown"]:
118 continue
120 service_name = map_service_ids[service_id]
121 service_nodes = parsed.setdefault(service_name, [])
122 service_nodes.append((status, description))
124 return parsed
127 def inventory_infoblox_services(parsed):
128 for service_name in parsed:
129 yield service_name, None
132 def check_infoblox_services(item, _no_params, parsed):
133 if item in parsed:
134 map_status = {
135 "working": 0,
136 "warning": 1,
137 "failed": 2,
138 "unexpected": 3,
140 node_data = parsed[item]
142 # For a clustered service the best state is used
143 min_status, min_descr = node_data[0]
144 min_state = map_status[min_status]
146 for status, descr in node_data[1:]:
147 state = map_status[status]
148 if state < min_state:
149 min_state, min_status, min_descr = state, status, descr
151 infotext = "Status: %s" % min_status
152 if min_descr:
153 infotext += " (%s)" % min_descr
155 return min_state, infotext
159 # .--statistics----------------------------------------------------------.
160 # | _ _ _ _ _ |
161 # | ___| |_ __ _| |_(_)___| |_(_) ___ ___ |
162 # | / __| __/ _` | __| / __| __| |/ __/ __| |
163 # | \__ \ || (_| | |_| \__ \ |_| | (__\__ \ |
164 # | |___/\__\__,_|\__|_|___/\__|_|\___|___/ |
165 # | |
166 # '----------------------------------------------------------------------'
169 def inventory_infoblox_statistics(info):
170 return [(None, None)]
173 def check_infoblox_statistics(ty, stats):
174 texts = {}
175 perfdata = []
176 for what, what_val, what_textfield, what_info in stats:
177 texts.setdefault(what_textfield, [])
178 texts[what_textfield].append("%d %s" % (what_val, what_info))
179 perfdata.append(("%s_%s" % (ty, what), what_val))
181 infotexts = []
182 for what, entries in texts.items():
183 infotexts.append("%s: %s" % (what, ", ".join(entries)))
185 return 0, " - ".join(infotexts), perfdata