Cleanup config.nodes_of
[check_mk.git] / checks / sap_hana_memrate
blobc69b609a8c14cd211c0e3bfcf005740f6b8af66f
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.
27 factory_settings["sap_hana_memrate_default_levels"] = {"levels": ('perc_used', (70.0, 80.0))}
30 def parse_sap_hana_memrate(info):
31 parsed = {}
32 for (sid_instance, node), lines in parse_sap_hana(info).iteritems():
33 inst_data = {}
34 for line in lines:
35 if len(line) < 3 or line[0] != 'mem_rate':
36 continue
38 for index, key in [(1, "used"), (2, "total")]:
39 try:
40 inst_data[key] = int(line[index])
41 except ValueError:
42 pass
43 if inst_data:
44 parsed.setdefault((sid_instance, node), inst_data)
45 return parsed
48 def inventory_sap_hana_memrate(parsed):
49 for (sid_instance, _node) in parsed.iterkeys():
50 yield sid_instance, {}
53 def check_sap_hana_memrate(item, params, parsed):
54 for (sid_instance, node), data in parsed.iteritems():
55 if item != sid_instance:
56 continue
58 if node:
59 yield 0, 'On node: %s' % node
61 yield check_memory_simple(data['used'], data['total'], params)
64 check_info['sap_hana_memrate'] = {
65 'parse_function': parse_sap_hana_memrate,
66 'inventory_function': inventory_sap_hana_memrate,
67 'check_function': check_sap_hana_memrate,
68 'service_description': 'SAP HANA Memory %s',
69 'includes': ['sap_hana.include', 'memory.include'],
70 "has_perfdata": True,
71 "node_info": True,
72 'group': 'sap_hana_memory',
73 'default_levels_variable': 'sap_hana_memrate_default_levels',