Cleanup config.nodes_of
[check_mk.git] / checks / elasticsearch_nodes
blob6d35931a8a7b7c699bd93d6c01c52101bb292acd
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.
27 # <<<elasticsearch_nodes>>>
28 # mynode1 open_file_descriptors 434
29 # mynode1 max_file_descriptors 4096
30 # mynode1 cpu_percent 0
31 # mynode1 cpu_total_in_millis 167010
32 # mynode1 mem_total_virtual_in_bytes 7126290432
33 # mynode2 open_file_descriptors 430
34 # mynode2 max_file_descriptors 4096
35 # mynode2 cpu_percent 0
36 # mynode2 cpu_total_in_millis 151810
37 # mynode2 mem_total_virtual_in_bytes 7107313664
39 nodes_info = {
40 'open_file_descriptors': 'Open file descriptors',
41 'max_file_descriptors': 'Max file descriptors',
42 'cpu_percent': 'CPU used',
43 'cpu_total_in_millis': 'CPU total in ms',
44 'mem_total_virtual_in_bytes': 'Total virtual memory'
48 def parse_elasticsearch_nodes(info):
49 parsed = {}
51 for name, desc, value_str in info:
52 try:
53 if desc == 'cpu_percent':
54 value = float(value_str)
55 else:
56 value = int(value_str)
58 parsed.setdefault(name, {}).setdefault(desc, (value, nodes_info[desc]))
60 except (IndexError, ValueError):
61 pass
63 return parsed
66 factory_settings["elasticsearch_nodes"] = {"cpu_levels": (75.0, 90.0)}
69 @get_parsed_item_data
70 def check_elasticsearch_nodes(item, params, item_data):
71 for key, hr_func in [
72 ('cpu_percent', get_percent_human_readable),
73 ('cpu_total_in_millis', int),
74 ('mem_total_virtual_in_bytes', get_bytes_human_readable),
75 ('open_file_descriptors', int),
76 ('max_file_descriptors', int),
78 value, infotext = item_data[key]
80 yield check_levels(
81 value, key, params.get(key), human_readable_func=hr_func, infoname=infotext)
84 check_info["elasticsearch_nodes"] = {
85 "parse_function": parse_elasticsearch_nodes,
86 "check_function": check_elasticsearch_nodes,
87 "inventory_function": discover(),
88 "default_levels_variable": "elasticsearch_nodes",
89 "service_description": "Elasticsearch Node %s",
90 "has_perfdata": True,
91 "group": "elasticsearch_nodes",
92 "includes": ["cpu_util.include"],