Cleanup config.nodes_of
[check_mk.git] / checks / netscaler_cpu
blobfbd33ec4b46440e251454ef65cfda75ea441a366
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.6.1.1.8.77.103.109.116.32.67.80.85 "Mgmt CPU"
29 # .1.3.6.1.4.1.5951.4.1.1.41.6.1.1.12.80.97.99.107.101.116.32.67.80.85.32.48 "Packet CPU 0"
30 # .1.3.6.1.4.1.5951.4.1.1.41.6.1.2.8.77.103.109.116.32.67.80.85 0
31 # .1.3.6.1.4.1.5951.4.1.1.41.6.1.2.12.80.97.99.107.101.116.32.67.80.85.32.48 0
33 factory_settings["netscaler_cpu_default_levels"] = {"levels": (90.0, 95.0)}
36 def inventory_netscaler_cpu(info):
37 for cpu_name, _cpu_usage in info:
38 yield cpu_name, {}
41 def check_netscaler_cpu(item, params, info):
42 warn, crit = params.get("levels")
43 for cpu_name, cpu_usage in info:
44 if cpu_name == item:
45 cpu_usage = int(cpu_usage)
47 infotext = "%d%%" % cpu_usage
48 perfdata = [("load", cpu_usage, warn, crit, 0)]
50 state = 0
51 if cpu_usage >= crit:
52 state = 2
53 elif cpu_usage >= warn:
54 state = 1
55 if state > 0:
56 infotext += " (warn/crit at %d/%d)" % (warn, crit)
58 return state, infotext, perfdata
61 check_info["netscaler_cpu"] = {
62 "check_function": check_netscaler_cpu,
63 "inventory_function": inventory_netscaler_cpu,
64 "default_levels_variable": "netscaler_cpu_default_levels",
65 "service_description": "CPU Utilization %s",
66 "has_perfdata": True,
67 "group": "cpu_utilization_multiitem",
68 "snmp_info": (
69 ".1.3.6.1.4.1.5951.4.1.1.41.6.1",
71 1, # nsCPUname
72 2, # nsCPUusage
73 ]),
74 "snmp_scan_function": lambda oid: oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.5951.1"),