GUI CSS: Deployed view styles for layouts (CMK-1171)
[check_mk.git] / checks / sap_hana_replication_status
blobb01412fe371914c18077cbc56179207787b98150
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2019 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 tmpl 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 tmpl for more de-
22 # tails. You should have received a copy of the GNU General Public
23 # tmpl 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_sap_hana_replication_status(info):
29 parsed = {}
30 for (sid_instance, node), lines in parse_sap_hana(info).iteritems():
31 inst = {}
32 for line in lines:
33 if line[0] == "mode:":
34 inst["mode"] = line[1]
35 elif line[0] == "systemReplicationStatus:":
36 inst["sys_repl_status"] = line[1]
37 if inst:
38 parsed.setdefault((sid_instance, node), inst)
39 return parsed
42 SAP_HANA_REPL_STATUS_MAP = {
43 "0": (3, "unknown status from replication script"),
44 "10": (2, "no system replication"),
45 "11": (2, "error"),
46 "12": (2, "unknown"),
47 "13": (1, "initializing"),
48 "14": (0, "syncing"),
49 "15": (0, "active"),
53 def inventory_sap_hana_replication_status(parsed):
54 for (sid_instance, _node), data in parsed.iteritems():
55 if data["sys_repl_status"] != "10" and data.get("mode", "").lower() == "primary":
56 yield sid_instance, {}
59 def check_sap_hana_replication_status(item, params, parsed):
60 for (sid_instance, node), data in parsed.iteritems():
61 if item != sid_instance:
62 continue
64 if node:
65 yield 0, 'On node: %s' % node
67 sys_repl_status = data["sys_repl_status"]
68 state, state_readable = SAP_HANA_REPL_STATUS_MAP.get(sys_repl_status,
69 (3, "unknown[%s]" % sys_repl_status))
70 yield state, "System replication: %s" % state_readable
72 yield 0, "Mode: %s" % data["mode"]
75 check_info['sap_hana_replication_status'] = {
76 'parse_function': parse_sap_hana_replication_status,
77 'inventory_function': inventory_sap_hana_replication_status,
78 'check_function': check_sap_hana_replication_status,
79 'service_description': 'SAP HANA Replication Status %s',
80 'includes': ['sap_hana.include'],
81 "node_info": True,