Cleanup config.nodes_of
[check_mk.git] / checks / informix_tabextents
blobe3820fadb06785792157319896c31bef52bc1841
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 #TODO WATORule
28 factory_settings['informix_tabextents_default_levels'] = {
29 'levels': (40, 70),
33 def parse_informix_tabextents(info):
34 parsed = {}
35 instance = None
36 entry = None
37 for line in info:
38 if instance is not None and line == ["(constant)", "TABEXTENTS"]:
39 entry = {}
40 parsed.setdefault(instance, [])
41 parsed[instance].append(entry)
43 elif line[0].startswith("[[[") and line[0].endswith("]]]"):
44 instance = line[0][3:-3]
46 elif entry is not None:
47 entry.setdefault(line[0], line[1])
49 return parsed
52 def inventory_informix_tabextents(parsed):
53 return [(instance, {}) for instance in parsed]
56 def check_informix_tabextents(item, params, parsed):
57 if item in parsed:
58 max_extents = -1
59 long_output = []
60 for entry in parsed[item]:
61 extents = int(entry['extents'])
62 if extents >= max_extents:
63 max_extents = extents
64 long_output.append("[%s/%s] Extents: %s, Rows: %s" % \
65 (entry['db'], entry["tab"], entry['extents'], entry['nrows']))
67 warn, crit = params['levels']
68 state = 0
69 infotext = "Maximal extents: %s" % max_extents
70 if max_extents >= crit:
71 state = 2
72 elif max_extents >= warn:
73 state = 1
74 if state:
75 infotext += " (warn/crit at %s/%s)" % (warn, crit)
76 return state, "%s\n%s" % (infotext, "\n".join(long_output)),\
77 [('max_extents', max_extents)]
80 check_info['informix_tabextents'] = {
81 'parse_function': parse_informix_tabextents,
82 'inventory_function': inventory_informix_tabextents,
83 'check_function': check_informix_tabextents,
84 'has_perfdata': True,
85 'service_description': 'Informix Table Extents %s',
86 'default_levels_variable': 'informix_tabextents_default_levels',