Refactoring: Changed all check parameters starting with an 'o' to the new rulespec...
[check_mk.git] / checks / cisco_stackpower
blobe417724fe2ba152170dbfa68e6e95076df71ce9e
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2015 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 # .1.3.6.1.4.1.9.9.500.1.3.2.1.2.1001.0 1
28 # .1.3.6.1.4.1.9.9.500.1.3.2.1.2.1001.1 1
29 # .1.3.6.1.4.1.9.9.500.1.3.2.1.2.2001.0 1
30 # .1.3.6.1.4.1.9.9.500.1.3.2.1.2.2001.1 1
31 # .1.3.6.1.4.1.9.9.500.1.3.2.1.2.3001.0 1
32 # .1.3.6.1.4.1.9.9.500.1.3.2.1.2.3001.1 1
33 # .1.3.6.1.4.1.9.9.500.1.3.2.1.3.1001.0 "00 00 00 00 00 00 "
34 # .1.3.6.1.4.1.9.9.500.1.3.2.1.3.1001.1 "00 00 00 00 00 00 "
35 # .1.3.6.1.4.1.9.9.500.1.3.2.1.3.2001.0 "00 00 00 00 00 00 "
36 # .1.3.6.1.4.1.9.9.500.1.3.2.1.3.2001.1 "00 00 00 00 00 00 "
37 # .1.3.6.1.4.1.9.9.500.1.3.2.1.3.3001.0 "00 00 00 00 00 00 "
38 # .1.3.6.1.4.1.9.9.500.1.3.2.1.3.3001.1 "00 00 00 00 00 00 "
39 # .1.3.6.1.4.1.9.9.500.1.3.2.1.4.1001.0 0
40 # .1.3.6.1.4.1.9.9.500.1.3.2.1.4.1001.1 0
41 # .1.3.6.1.4.1.9.9.500.1.3.2.1.4.2001.0 0
42 # .1.3.6.1.4.1.9.9.500.1.3.2.1.4.2001.1 0
43 # .1.3.6.1.4.1.9.9.500.1.3.2.1.4.3001.0 0
44 # .1.3.6.1.4.1.9.9.500.1.3.2.1.4.3001.1 0
45 # .1.3.6.1.4.1.9.9.500.1.3.2.1.5.1001.0 1
46 # .1.3.6.1.4.1.9.9.500.1.3.2.1.5.1001.1 1
47 # .1.3.6.1.4.1.9.9.500.1.3.2.1.5.2001.0 1
48 # .1.3.6.1.4.1.9.9.500.1.3.2.1.5.2001.1 1
49 # .1.3.6.1.4.1.9.9.500.1.3.2.1.5.3001.0 1
50 # .1.3.6.1.4.1.9.9.500.1.3.2.1.5.3001.1 1
51 # .1.3.6.1.4.1.9.9.500.1.3.2.1.6.1001.0 40
52 # .1.3.6.1.4.1.9.9.500.1.3.2.1.6.1001.1 40
53 # .1.3.6.1.4.1.9.9.500.1.3.2.1.6.2001.0 40
54 # .1.3.6.1.4.1.9.9.500.1.3.2.1.6.2001.1 40
55 # .1.3.6.1.4.1.9.9.500.1.3.2.1.6.3001.0 40
56 # .1.3.6.1.4.1.9.9.500.1.3.2.1.6.3001.1 40
57 # .1.3.6.1.4.1.9.9.500.1.3.2.1.7.1001.0 "Port 1"
58 # .1.3.6.1.4.1.9.9.500.1.3.2.1.7.1001.1 "Port 2"
59 # .1.3.6.1.4.1.9.9.500.1.3.2.1.7.2001.0 "Port 1"
60 # .1.3.6.1.4.1.9.9.500.1.3.2.1.7.2001.1 "Port 2"
61 # .1.3.6.1.4.1.9.9.500.1.3.2.1.7.3001.0 "Port 1"
62 # .1.3.6.1.4.1.9.9.500.1.3.2.1.7.3001.1 "Port 2"
65 def inventory_cisco_stackpower(info):
66 return [("%s %s" % (oid.split(".")[0], port_name), None)
67 for oid, port_oper_status, _port_link_status, port_name in info
68 if port_oper_status == '1']
71 def check_cisco_stackpower(item, params, info):
72 map_oper_status = {
73 '1': (0, 'Port enabled'),
74 '2': (2, 'Port disabled'),
77 map_status = {
78 '1': (0, 'Status: connected and operational'),
79 '2': (2, 'Status: forced down or not connected'),
82 for oid, port_oper_status, port_link_status, port_name in info:
83 if item == '%s %s' % (oid.split(".")[0], port_name):
84 yield map_oper_status[port_oper_status]
85 yield map_status[port_link_status]
88 check_info['cisco_stackpower'] = {
89 'inventory_function': inventory_cisco_stackpower,
90 'check_function': check_cisco_stackpower,
91 'service_description': 'Stackpower Interface %s',
92 'snmp_info': (
93 '.1.3.6.1.4.1.9.9.500.1.3.2.1',
95 OID_END,
96 '2', # cswStackPowerPortOperStatus
97 '5', # cswStackPowerPortLinkStatus
98 '7', # cswStackPowerPortName
99 ]),
100 'snmp_scan_function': lambda oid: oid('.1.3.6.1.2.1.1.2.0').startswith('.1.3.6.1.4.1.9.1.516'),