Refactoring: Moved check parameters from unsorted.py to dedicated modules (CMK-1393)
[check_mk.git] / checks / cisco_vss
blobdaa2103b00d4adf1e0545c802c67bfcd8f2539b6
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 # Example SNMP walk (extract)
28 # All names OIDs are prefixed with CISCO-VIRTUAL-SWITCH-MIB::
29 # All numeric OIDs are prefixed with .1.3.6.1.4.1.9.9.388
31 # cvsDomain.0 .1.1.1.0 10
32 # cvsSwitchID.0 .1.1.2.0 1
33 # cvsSwitchCapability.0 .1.1.3.0 "C0 "
34 # cvsSwitchMode.0 .1.1.4.0 2
35 # cvsSwitchConvertingStatus.0 .1.1.5.0 2
36 # cvsVSLChangeNotifEnable.0 .1.1.6.0 2
37 # cvsCoreSwitchPriority.1 .1.2.1.1.2.1 100
38 # cvsCoreSwitchPriority.2 .1.2.1.1.2.2 100
39 # cvsCoreSwitchPreempt.1 .1.2.1.1.3.1 2
40 # cvsCoreSwitchPreempt.2 .1.2.1.1.3.2 2
41 # cvsCoreSwitchLocation.1 .1.2.1.1.4.1
42 # cvsCoreSwitchLocation.2 .1.2.1.1.4.2
43 # cvsChassisSwitchID.2 .1.2.2.1.1.2 1
44 # cvsChassisSwitchID.500 .1.2.2.1.1.500 2
45 # cvsChassisRole.2 .1.2.2.1.2.2 2
46 # cvsChassisRole.500 .1.2.2.1.2.500 3
47 # cvsChassisUpTime.2 .1.2.2.1.3.2 184371004
48 # cvsChassisUpTime.500 .1.2.2.1.3.500 184371004
49 # cvsVSLCoreSwitchID.41 .1.3.1.1.2.41 1
50 # cvsVSLCoreSwitchID.42 .1.3.1.1.2.42 2
51 # cvsVSLConnectOperStatus.41 .1.3.1.1.3.41 1
52 # cvsVSLConnectOperStatus.42 .1.3.1.1.3.42 1
53 # cvsVSLLastConnectionStateChange.41 .1.3.1.1.4.41 "07 DE 07 18 01 12 22 00 "
54 # cvsVSLLastConnectionStateChange.42 .1.3.1.1.4.42 "07 DE 07 18 01 12 22 00 "
55 # cvsVSLConfiguredPortCount.41 .1.3.1.1.5.41 2
56 # cvsVSLConfiguredPortCount.42 .1.3.1.1.5.42 2
57 # cvsVSLOperationalPortCount.41 .1.3.1.1.6.41 2
58 # cvsVSLOperationalPortCount.42 .1.3.1.1.6.42 2
59 # cvsVSLConnectionRowStatus.41 .1.3.1.1.7.41 1
60 # cvsVSLConnectionRowStatus.42 .1.3.1.1.7.42 1
61 # cvsModuleVSSupported.1000 .1.4.1.1.1.1000 1
62 # cvsModuleVSSupported.11000 .1.4.1.1.1.11000 1
63 # cvsModuleVSLCapable.1000 .1.4.1.1.2.1000 1
64 # cvsModuleVSLCapable.11000 .1.4.1.1.2.11000 1
65 # cvsModuleSlotNumber.1000 .1.4.1.1.3.1000 1
66 # cvsModuleSlotNumber.11000 .1.4.1.1.3.11000 11
67 # cvsModuleRprWarm.1000 .1.4.1.1.4.1000 1
68 # cvsModuleRprWarm.11000 .1.4.1.1.4.11000 1
69 # cvsDualActiveDetectionNotifEnable.0 .1.5.1.0 2
71 cisco_vss_role_names = {
72 '1': 'standalone',
73 '2': 'active',
74 '3': 'standby',
77 cisco_vss_operstatus_names = {
78 '1': 'up',
79 '2': 'down',
83 def inventory_cisco_vss(info):
84 for _switch_id, chassis_role in info[0]:
85 if chassis_role in ['2', '3']: # active, standby
86 return [(None, None)]
89 def check_cisco_vss(item, params, info):
90 chassis, ports = info
91 for switch_id, chassis_role in chassis:
92 if chassis_role == '1':
93 state = 2
94 else:
95 state = 0
96 yield state, "chassis %s: %s" % (switch_id, cisco_vss_role_names[chassis_role])
98 yield 0, "%d VSL connections configured" % len(ports)
100 for core_switch_id, operstatus, conf_portcount, op_portcount in ports:
101 if operstatus == '1':
102 state = 0
103 else:
104 state = 2
105 yield state, "core switch %s: VSL %s" % (core_switch_id,
106 cisco_vss_operstatus_names[operstatus])
108 if conf_portcount == op_portcount:
109 state = 0
110 else:
111 state = 2
112 yield state, "%s/%s ports operational" % (op_portcount, conf_portcount)
115 check_info["cisco_vss"] = {
116 "check_function" : check_cisco_vss,
117 "inventory_function" : inventory_cisco_vss,
118 "service_description": "VSS Status",
119 "snmp_scan_function" : lambda oid: (
120 "Catalyst 45" in oid(".1.3.6.1.2.1.1.1.0") or
121 "Catalyst 65" in oid(".1.3.6.1.2.1.1.1.0") or
122 "s72033_rp" in oid(".1.3.6.1.2.1.1.1.0")) and \
123 oid(".1.3.6.1.4.1.9.9.388.1.1.1.0"),
124 "snmp_info" : [
125 ( ".1.3.6.1.4.1.9.9.388.1.2.2.1",
127 1, # cvsChassisSwitchID
128 2, # cvsChassisRole: standalone(1), active(2), standby(3)
131 ( ".1.3.6.1.4.1.9.9.388.1.3.1.1",
133 2, # cvsVSLCoreSwitchID
134 3, # cvsVSLConnectOperStatus: up(1), down(2)
135 5, # cvsVSLConfiguredPortCount
136 6, # cvsVSLOperationalPortCount