Cleanup config.nodes_of
[check_mk.git] / checks / arris_cmts_cpu
blobb976293dd513db96ff86fe0ee9f7f44ae6218f41
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 arris_cmts_cpu_default_levels = (90, 95)
30 def inventory_arris_cmts_cpu(info):
31 for oid_id, cpu_id, _cpu_idle_util in info:
32 # Sadly the cpu_id seams empty. Referring to
33 # the MIB, its slot id
34 if cpu_id:
35 yield cpu_id, 'arris_cmts_cpu_default_levels'
36 else:
37 # Fallback to the oid end
38 item = int(oid_id) - 1
39 yield item, 'arris_cmts_cpu_default_levels'
42 def check_arris_cmts_cpu(item, params, info):
43 if isinstance(params, tuple):
44 params = {"levels": params}
46 for oid_id, cpu_id, cpu_idle_util in info:
47 # see inventory function
48 if cpu_id:
49 citem = cpu_id
50 else:
51 citem = int(oid_id) - 1
53 if citem == item:
54 # We get the IDLE percentage, but need the usage
55 cpu_util = 100 - int(cpu_idle_util)
56 warn, crit = params['levels']
58 infotext = "Current utilization is: %d %% " % cpu_util
59 levels = " (warn/crit at %.1f/%.1f %%)" % (warn, crit)
60 perfdata = [("util", cpu_util, warn, crit)]
61 if cpu_util >= crit:
62 yield 2, infotext + levels, perfdata
63 elif cpu_util >= warn:
64 yield 1, infotext + levels, perfdata
65 else:
66 yield 0, infotext, perfdata
67 return
68 yield 3, "CPU information not found"
71 check_info["arris_cmts_cpu"] = {
72 "check_function": check_arris_cmts_cpu,
73 "inventory_function": inventory_arris_cmts_cpu,
74 "service_description": "CPU utilization Module %s",
75 "has_perfdata": True,
76 "snmp_scan_function": arris_cmts_scan_function,
77 "snmp_info": (
78 ".1.3.6.1.4.1.4998.1.1.5.3.1.1.1",
80 OID_END,
81 1, # cadCpuCardId
82 8, # cadIdleCpuRecentPercent
83 ]),
84 "group": "cpu_utilization_multiitem",
85 "includes": ["arris_cmts.include"]