Cleanup config.nodes_of
[check_mk.git] / checks / dell_powerconnect_cpu
blob93a57be998c26cc85405db0ca23e71de542f7613
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 # Relevant SNMP OIDs:
28 # .1.3.6.1.4.1.89.1.1.0 = INTEGER: 65535
29 # .1.3.6.1.4.1.89.1.2.0 = INTEGER: none(26)
30 # .1.3.6.1.4.1.89.1.4.0 = Hex-STRING: E0
31 # .1.3.6.1.4.1.89.1.5.0 = INTEGER: 1
32 # .1.3.6.1.4.1.89.1.6.0 = INTEGER: true(1)
33 # .1.3.6.1.4.1.89.1.7.0 = INTEGER: 91
34 # .1.3.6.1.4.1.89.1.8.0 = INTEGER: 10
35 # .1.3.6.1.4.1.89.1.9.0 = INTEGER: 4
37 # Default values for parameters that can be overriden.
38 dell_powerconnect_cpu_default_levels = (80, 90)
41 # Inventory of dell power connect CPU details.
42 def inventory_dell_powerconnect_cpu(checkname, info):
43 if info:
44 enabled, onesecondperc, _oneminuteperc, _fiveminutesperc = info[0]
45 if enabled == '1' and onesecondperc != '' and int(onesecondperc) >= 0:
46 return [(None, 'dell_powerconnect_cpu_default_levels')]
49 # Check of dell power connect CPU details.
50 def check_dell_powerconnect_cpu(item, params, info):
51 try:
52 enabled, onesecondperc, oneminuteperc, fiveminutesperc = map(int, info[0])
53 except ValueError:
54 raise MKCounterWrapped("Ignoring empty data from SNMP agent")
55 if int(enabled) == 1:
56 cpu_util = saveint(onesecondperc)
57 if cpu_util >= 0 <= 100:
58 status = 0
59 output = ''
60 if cpu_util >= params[1]:
61 status = 2
62 output = ' (Above %d%%)' % params[1]
63 elif cpu_util >= params[0]:
64 status = 1
65 output = ' (Above %d%%)' % params[0]
67 # Darn. It again happend. Someone mixed up load and utilization.
68 # We do *not* rename the performance variables here, in order not
69 # to mix up existing RRDs...
70 return (status, 'CPU utilization is %d%% %s' % (cpu_util, output), [
71 ('load', '%d%%' % cpu_util, params[0], params[1], 0, 100),
72 ('loadavg 60s', '%d%%' % saveint(oneminuteperc), params[0], params[1], 0, 100),
73 ('loadavg 5m', '%d%%' % saveint(fiveminutesperc), params[0], params[1], 0, 100),
76 return (3, "Invalid information in SNMP data")
79 check_info["dell_powerconnect_cpu"] = {
80 'check_function': check_dell_powerconnect_cpu,
81 'inventory_function': inventory_dell_powerconnect_cpu,
82 'service_description': 'CPU utilization',
83 'has_perfdata': True,
84 'snmp_info': ('.1.3.6.1.4.1.89.1', ['6', '7', '8', '9']),
85 'snmp_scan_function': lambda oid: ".1.3.6.1.4.1.674.10895" in oid(".1.3.6.1.2.1.1.2.0")