Cleanup config.nodes_of
[check_mk.git] / checks / sap_hana_events
blob36975071d433548171bdc0a4bc332709ba06c3e0
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 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_sap_hana_events(info):
29 parsed = {}
30 for (sid_instance, node), lines in parse_sap_hana(info).iteritems():
31 inst_data = {}
32 for line in lines:
33 if len(line) < 2:
34 continue
36 try:
37 inst_data[line[0]] = int(line[1])
38 except ValueError:
39 pass
40 if inst_data:
41 parsed.setdefault((sid_instance, node), inst_data)
42 return parsed
45 def inventory_sap_hana_events(parsed):
46 for (sid_instance, _node) in parsed.iterkeys():
47 yield sid_instance, {}
50 SAP_HANA_EVENTS_MAP = {
51 'open_events': (2, 'Unacknowledged events'),
52 'disabled_alerts': (1, 'Disabled alerts'),
53 'high_alerts': (2, 'High alerts'),
57 def check_sap_hana_events(item, params, parsed):
58 for (sid_instance, node), data in parsed.iteritems():
59 if item != sid_instance:
60 continue
62 if node:
63 yield 0, 'On node: %s' % node
65 for event_key, event_count in data.iteritems():
66 event_state, event_state_readable = SAP_HANA_EVENTS_MAP.get(
67 event_key, (3, "unknown[%s]" % event_key))
68 state = 0
69 if event_count > 0:
70 state = event_state
71 yield state, "%s: %s" % (event_state_readable, event_count), [("num_%s" % event_key,
72 event_count)]
75 check_info['sap_hana_events'] = {
76 'parse_function': parse_sap_hana_events,
77 'inventory_function': inventory_sap_hana_events,
78 'check_function': check_sap_hana_events,
79 'service_description': 'SAP HANA Events %s',
80 'includes': ['sap_hana.include'],
81 "has_perfdata": True,
82 "node_info": True,