stpgraph - a grapher for ethernetworks utilizing the spanning tree protocol
stpgraph [ -hvV ] [-c string] [ <-s filename> [-b filename] [-p n|-P] | <-r> ] [-g type [-W width] [-H height] [<-u|U> [-O] [-X regexp]] args [...]
stpgraph is a tool used to discover and graph ethernet spanning-tree topologies.
Usually this is a two-step process:
-s
option.
-g
option.
The resulting graphs have these characteristics (parenthesized terms are graph-theory/graphviz terminology):
stpgraph has the following options:
-h
mnemonic: 'h'elp
-v
mnemonic: 'v'erbose
-V
mnemonic: 'V'ery verbose
-c
stringmnemonic: 'c'ommunity
-g
typemnemonic: 'g'raph type
-W
widthwhen generating a graph, use the specified value as the graph width, in pages
-H
heightmnemonic: 'H'eight
-u
mnemonic: 'u'nknown
-U
mnemonic: all 'U'nknown
-O
mnemonic: if'O'perStatus
-X
regexpmnemonic: e'X'clude
-s
filenameWith this option, args should be the bridge names or IP addresses.
mnemonic: 's'tore
-p
nmnemonic: 'p'arallelize
-P
mnemonic: 'P'arallelize
-r
-s
(store).
mnemonic: 'r'etrieve
-b
filenameThis option is especially useful when some of the nodes are Cisco Catalyst 4000 series switches running IOS, which has a bug which causes them to report an incorrect dot1dBaseBridgeAddress when queried via SNMP.
Instead, you can use the ``show spanning-tree [vlan n]'' command to determine the correct bridge address.
mnemonic: 'b'ridge addresses
Discover the spanning-tree information for vlan 1 (using Cisco's vlan-based community string indexing with per-VLAN spanning tree), and store the information as Storable objects in files with names with the suffix ``_stp1.obj'' corresponding to each host:
$ stpgraph -c public@1 -s %s_stp1.obj host1 host2 host3
Graph the spanning-tree for vlan 1, based on the information discovered and stored previously, to a PostScript output file:
$ stpgraph -g ps -r host[123]_stp1.obj > stp1.ps
Graph the spanning-tree for vlan 1, based on the information discovered and stored previously, to an xfig output file:
$ stpgraph -g fig -r host[123]_stp1.obj > stp1.fig
Graph the spanning-tree for vlan 1 showing unknown nodes, unless they would be linked to a node with a name ending in ``-access'':
$ stpgraph -g ps -u -X access -r host[123]_stp1.obj > stp1.ps
This Cisco Catalyst 4000 series switches running IOS (as of 12.1(20)EW1) have a bug which causes them to report an incorrect bridge address when queried via SNMP.
Instead, you can use the ``show spanning-tree [vlan n]'' command to determine
the correct bridge address and use the -b
option to cause the correct
bridge addresses to be preloaded, rather than discovered via SNMP.
The SNMP MIB object definitions used by stpgraph can be found in these files:
ftp://ftp.cisco.com/pub/mibs/v1/BRIDGE-MIB.my ftp://ftp.cisco.com/pub/mibs/oid/BRIDGE-MIB.oid
ftp://ftp.cisco.com/pub/mibs/v2/IF-MIB.my ftp://ftp.cisco.com/pub/mibs/oid/IF-MIB.oid
stpgraph uses only the IEEE 802.1d spanning-tree information and should not require a modern implementation such as as 802.1w (Rapid Reconfiguration). However, stpgraph has been demonstrated to work using dot1q vlans on Cisco gear running Cisco's PVST+ or PVRST+ (Per-Vlan [Rapid] Spanning Tree) because Cisco uses a clever tecnique of using the SNMP community string as an index (by appending an ``@n'' suffix, where `n' is the desired dot1q vlan number) enabling the user to select which vlan's bridge objects will be accessed. Community Strings Indexing is supported on a number of Cisco products including the Catalyst 3550, 5000, and 6000 as documented here:
ftp://ftp.cisco.com/pub/mibs/supportlists/wsc5000/wsc5000-communityIndexing.html ftp://ftp.cisco.com/pub/mibs/supportlists/wsc6000/wsc6000-communityIndexing.html
To be determined...
Dave Plonka <plonka@doit.wisc.edu>
Copyright (C) 2004, 2005 Dave Plonka. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
perl(1), SNMP_Session, SNMP_util, GraphViz, Storable, Data::Dumper.