Refactoring: Moved check parameters from unsorted.py to dedicated modules (CMK-1393)
[check_mk.git] / checks / blade_blowers
blob851114fd1dbc9941c38ddd493d1ff1f0e87624ce
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 # The BLADE-MIB is somewhat goofy redarding the blower
28 # information. The blowers are listed sequentially
29 # below the same subtrees:
31 # BLADE-MIB::blower1speed.0 = STRING: "50% of maximum"
32 # BLADE-MIB::blower2speed.0 = STRING: "50% of maximum"
33 # BLADE-MIB::blower1State.0 = INTEGER: good(1)
34 # BLADE-MIB::blower2State.0 = INTEGER: good(1)
35 # BLADE-MIB::blowers.20.0 = STRING: "1712"
36 # BLADE-MIB::blowers.21.0 = STRING: "1696"
37 # BLADE-MIB::blowers.30.0 = INTEGER: 0
38 # BLADE-MIB::blowers.31.0 = INTEGER: 0
40 # The same with -On:
41 # .1.3.6.1.4.1.2.3.51.2.2.3.1.0 = STRING: "49% of maximum"
42 # .1.3.6.1.4.1.2.3.51.2.2.3.2.0 = STRING: "No Blower"
43 # .1.3.6.1.4.1.2.3.51.2.2.3.10.0 = INTEGER: good(1)
44 # .1.3.6.1.4.1.2.3.51.2.2.3.11.0 = INTEGER: unknown(0)
45 # .1.3.6.1.4.1.2.3.51.2.2.3.20.0 = STRING: "1696"
46 # .1.3.6.1.4.1.2.3.51.2.2.3.21.0 = STRING: "No Blower"
47 # .1.3.6.1.4.1.2.3.51.2.2.3.30.0 = INTEGER: 0
48 # .1.3.6.1.4.1.2.3.51.2.2.3.31.0 = INTEGER: 2
50 # How can we safely determine the number of blowers without
51 # assuming that each blower has four entries?
54 # We assume that all blowers are in state OK (used for
55 # inventory only)
56 def number_of_blowers(info):
57 n = 0
58 while len(info) > n and len(info[n][0]) > 1: # state lines
59 n += 1
60 return n
63 def inventory_blade_blowers(info):
64 inventory = []
65 n = number_of_blowers(info)
66 for i in range(0, n):
67 if info[i + n][0] != "0": # skip unknown blowers
68 inventory.append(("%d/%d" % (i + 1, n), None, None))
69 return inventory
72 def check_blade_blowers(item, _no_params, info):
73 blower, num_blowers = map(int, item.split("/"))
74 text = info[blower - 1][0]
75 perfdata = []
76 output = ''
78 state = info[blower - 1 + num_blowers][0]
80 try:
81 rpm = int(info[blower - 1 + 2 * num_blowers][0])
82 perfdata += [("rpm", rpm)]
83 output += 'Speed at %d RMP' % rpm
84 except:
85 pass
87 try:
88 perc = int(text.split("%")[0])
89 perfdata += [("perc", perc, None, None, 0, 100)]
90 if output == '':
91 output += 'Speed is at %d%% of max' % perc
92 else:
93 output += ' (%d%% of max)' % perc
94 except:
95 pass
97 if state == "1":
98 return (0, output, perfdata)
99 return (2, output, perfdata)
104 check_info["blade_blowers"] = {
105 'check_function': check_blade_blowers,
106 'inventory_function': inventory_blade_blowers,
107 'service_description': 'Blower %s',
108 'has_perfdata': True,
109 'snmp_info': ('.1.3.6.1.4.1.2.3.51.2.2', [3]),
110 'snmp_scan_function':
111 lambda oid: re.match('(BladeCenter|BladeCenter Advanced|IBM Flex Chassis|Lenovo Flex Chassis) Management Module', oid(".1.3.6.1.2.1.1.1.0")) is not None,