Cleanup config.nodes_of
[check_mk.git] / checks / netscaler_mem
blobbcf2cc29375c71b6402cb27a058400138cba9fdf
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.
27 # Example Output:
28 # .1.3.6.1.4.1.5951.4.1.1.41.2.0 13
29 # .1.3.6.1.4.1.5951.4.1.1.41.4.0 7902
31 netscaler_mem_default_levels = (80.0, 90.0)
34 def inventory_netscaler_mem(info):
35 if info:
36 return [(None, 'netscaler_mem_default_levels')]
39 def check_netscaler_mem(_no_item, params, info):
40 used_mem_perc, total_mem_mb = map(float, info[0])
41 warn_perc, crit_perc = params
42 total_mem = total_mem_mb * 1024 * 1024
43 warn, crit, used_mem = [s * total_mem / 100.0 for s in params + (used_mem_perc,)]
44 infotext = "%s (%d%%) of %s" % (get_bytes_human_readable(used_mem), used_mem_perc,
45 get_bytes_human_readable(total_mem))
46 perfdata = [("mem", used_mem, warn, crit, 0, total_mem)]
48 state = 0
49 if used_mem >= crit:
50 state = 2
51 elif used_mem >= warn:
52 state = 1
53 if state > 0:
54 infotext += " (warn/crit at %.1f%%/%.1f%%)" % (warn_perc, crit_perc)
56 return state, infotext, perfdata
59 check_info["netscaler_mem"] = {
60 "check_function": check_netscaler_mem,
61 "inventory_function": inventory_netscaler_mem,
62 "service_description": "Memory used",
63 "has_perfdata": True,
64 "group": "netscaler_mem",
65 "snmp_info": (
66 ".1.3.6.1.4.1.5951.4.1.1.41",
67 [ # nsResourceGroup
68 2, # resMemUsage
69 4, # memSizeMB
70 ]),
71 "snmp_scan_function": lambda oid: oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.5951.1"),