Refactoring: Changed all check parameters starting with an 'o' to the new rulespec...
[check_mk.git] / checks / cisco_cpu_multiitem
blobd5c344c724201f00612e868e2db0a848fbaf0f32
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 factory_settings['cisco_cpu_multiitem_default_levels'] = {
28 'levels': (80.0, 90.0),
32 def parse_cisco_cpu_multiitem(info):
33 ph_idx_to_desc = {}
34 parsed = {}
35 for idx, desc in info[1]:
36 if desc.lower().startswith("cpu "):
37 desc = desc[4:]
38 ph_idx_to_desc[idx] = desc
40 for idx, util in info[0]:
41 if idx in ph_idx_to_desc:
42 name = ph_idx_to_desc[idx]
43 else:
44 name = idx
45 parsed[name] = {
46 'util': float(util),
48 return parsed
51 def inventory_cisco_cpu_multiitem(parsed):
52 for name in parsed:
53 yield name, {}
56 def check_cisco_cpu_multiitem(item, params, parsed):
57 warn, crit = params['levels']
58 if item in parsed:
59 util = parsed[item]['util']
61 state = 0
62 if util >= crit:
63 state = 2
64 elif util >= warn:
65 state = 1
67 infotext = "%s%% utilization in the last 5 minutes" % util
68 if state > 0:
69 infotext += " (warn/crit at %s%%/%s%%)" % (warn, crit)
71 yield state, infotext, [("util", util, warn, crit, 0, 100)]
73 else:
74 yield 3, "No information about the CPU utilization available"
76 check_info["cisco_cpu_multiitem"] = {
77 'parse_function' : parse_cisco_cpu_multiitem,
78 'check_function' : check_cisco_cpu_multiitem,
79 'inventory_function' : inventory_cisco_cpu_multiitem,
80 "group" : "cpu_utilization_multiitem",
81 "default_levels_variable" : "cisco_cpu_multiitem_default_levels",
82 'service_description' : 'CPU utilization %s',
83 'has_perfdata' : True,
84 'snmp_info' : [('.1.3.6.1.4.1.9.9.109.1.1.1', [
85 '1.2', # cpmCPUTotalPhysicalIndex
86 '1.8', # cpmCPUTotal5minRev
87 ]),
88 ('.1.3.6.1.2.1.47.1.1.1', [
89 OID_END, #OID index
90 '1.7', # entPhysicalName
91 ])],
92 'snmp_scan_function' : lambda oid: 'cisco' in oid('.1.3.6.1.2.1.1.1.0').lower() and \
93 oid('.1.3.6.1.4.1.9.9.109.1.1.1.*') is None,