Cleanup config.nodes_of
[check_mk.git] / checks / informix_status
blob89efdb7dc9af72763725f80c0cbf93225ffaa607
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.
28 def parse_informix_status(info):
29 parsed = {}
30 instance = None
31 for line in info:
32 if line[0].startswith("[[[") and line[0].endswith("]]]"):
33 instance = line[0][3:-3]
35 elif instance is not None and len(line) >= 2:
36 stripped_line = [x.strip() for x in line]
37 parsed.setdefault(instance, {})
38 parsed[instance].setdefault(stripped_line[0], " ".join(stripped_line[1:]))
40 return parsed
43 def inventory_informix_status(parsed):
44 return [(instance, {}) for instance in parsed]
47 def check_informix_status(item, params, parsed):
48 map_states = {
49 "0": (0, "initialization"),
50 "1": (1, "quiescent"),
51 "2": (1, "recovery"),
52 "3": (1, "backup"),
53 "4": (2, "shutdown"),
54 "5": (0, "online"),
55 "6": (1, "abort"),
56 "7": (1, "single user"),
57 "-1": (2, "offline"),
58 "255": (2, "offline"),
61 if item in parsed:
62 data = parsed[item]
63 state, state_readable = map_states[data["Status"]]
64 infotext = "Status: %s" % state_readable
65 if "Server Version" in data:
66 infotext += ", Version: %s" % data["Server Version"]
67 if "PORT" in data:
68 infotext += ", Port: %s" % data["PORT"].split(" ")[1]
69 return state, infotext
72 check_info['informix_status'] = {
73 'parse_function': parse_informix_status,
74 'inventory_function': inventory_informix_status,
75 'check_function': check_informix_status,
76 'service_description': 'Informix Instance %s',