Cleanup config.nodes_of
[check_mk.git] / checks / casa_cpu_mem
blobd40b16272e2666cd16ab3a49bf666fcdca41a8dc
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2014 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_casa_cpu_mem(info):
29 entity_names = {int(k): v for k, v in (x for x in info[0])}
30 data = {}
31 for idx, entry in enumerate(info[1]):
32 entry_nr = int(entry[0])
33 data[entity_names[entry_nr]] = {
34 "mem_total": int(info[1][idx][1]),
35 "mem_used": int(info[2][idx][1]),
37 return data
40 def inventory_casa_cpu_mem(parsed):
41 inventory = []
42 for k, v in parsed.iteritems():
43 if v.get("mem_total"):
44 inventory.append((k, {}))
45 return inventory
48 def check_casa_cpu_mem(item, params, parsed):
49 if item not in parsed:
50 return 3, '%s not found in agent output' % item
51 return check_memory_multiitem(params, parsed[item], base=1000)
54 check_info["casa_cpu_mem"] = {
55 "parse_function": parse_casa_cpu_mem,
56 "inventory_function": inventory_casa_cpu_mem,
57 "check_function": check_casa_cpu_mem,
58 "service_description": "Memory %s",
59 "has_perfdata": True,
60 "group": "memory_multiitem",
61 "snmp_scan_function": lambda oid: oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.20858.2."),
62 "snmp_info": [
63 (".1.3.6.1.2.1.47.1.1.1.1.2", [OID_END, '']), # Entity descriptions, quite long...
64 (".1.3.6.1.4.1.20858.10.13.1.1.1.1", [OID_END, '']), # Total mem
65 (".1.3.6.1.4.1.20858.10.13.1.1.1.2", [OID_END, '']), # Total allocated mem
66 (".1.3.6.1.4.1.20858.10.36.1.1.1.1", [OID_END, '']), # Installed slot
68 "includes": ["memory.include"],