Cleanup config.nodes_of
[check_mk.git] / checks / sap_hana_proc
blob8b9bb1c7feb55d0f196efcb8400ea916a6f8d8f3
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_proc(info):
29 parsed = {}
30 for (sid_instance, node), lines in parse_sap_hana(info).iteritems():
31 for line in lines:
32 if len(line) < 2:
33 continue
35 inst = parsed.setdefault(
36 ("%s %s" % (sid_instance, line[1]), node), {
37 "port": line[0],
38 "pid": line[2],
39 "detail": line[3],
40 "acting": line[4],
41 "coordin": line[6],
43 try:
44 inst["sql_port"] = int(line[5])
45 except ValueError:
46 inst["sql_port"] = None
47 return parsed
50 def inventory_sap_hana_proc(parsed):
51 for (sid_instance, _node), data in parsed.iteritems():
52 yield sid_instance, {'coordin': data['coordin']}
55 def check_sap_hana_proc(item, params, parsed):
56 for (sid_instance, node), data in parsed.iteritems():
57 if item != sid_instance:
58 continue
60 if node:
61 yield 0, 'On node: %s' % node
63 yield 0, 'Port: %s, PID: %s' % (data['port'], data['pid'])
65 p_coordin = params['coordin']
66 coordin = data['coordin']
67 if p_coordin != coordin:
68 yield 1, "Role: changed from %s to %s" % (p_coordin, coordin)
69 elif coordin.lower() != 'none':
70 yield 0, "Role: %s" % coordin
72 sql_port = data['sql_port']
73 if sql_port:
74 yield 0, "SQL-Port: %s" % sql_port
75 if data['acting'].lower() != 'yes':
76 yield 2, "not acting"
79 check_info['sap_hana_proc'] = {
80 'parse_function': parse_sap_hana_proc,
81 'inventory_function': inventory_sap_hana_proc,
82 'check_function': check_sap_hana_proc,
83 'service_description': 'SAP HANA Process %s',
84 'includes': ['sap_hana.include'],
85 "node_info": True,