Plugin for spanning tree on cisco switches


#1

Hi all,

I am searching a plugin for Cisco spanning tree. It should eg. give me the possibility to check, if the switch is the root brdige for a given VLAN (and if not give a warn/crit).
Does anybody know sth. useful for this?

Regards,
Marcus


(Dmytro Prokhorenkov) #2

I think there is no ready solution for this task. How about use default snmp script with STP community and check for output status?


(Isma399) #3

If you can SSH your switch since Icinga, you could test this Python script:

#!/usr/bin/python
# coding: utf-8

import sys
import re
from optparse import OptionParser
import subprocess


argv = (sys.argv[1:])
parser = OptionParser()
parser.add_option("-u", "--user",
                  dest="user",
                  help="Enabled user.")
parser.add_option("-H", "--hostname",
                  dest="switch",
                  help="The switch checked for root brige.")
parser.add_option("-n", "--vlan_number",
                  dest="vlan",
                  help="The vlan number which the switch is root bridge.")
(options, args) = parser.parse_args()

switch = options.switch
vlan = options.vlan
user = options.user 

cmd = 'ssh ' + user + '@' + switch + ' -C show spanning-tree vlan ' + vlan
ps = subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
result = ps.communicate()[0]

if  re.search('This bridge is the root', result):
    print 'OK. ' + switch + ' is root bridge for vlan ' + vlan
    sys.exit(0)
else:
    print 'ALERT! ' + switch + ' is NOT root bridge for vlan ' + vlan
    sys.exit(2)