Skip to content

Commit 48dcdb0

Browse files
committed
collect dot1dStpRootPort and show crow edge for it
1 parent ab3d00d commit 48dcdb0

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

sbw-parse.pl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ sub sw_name_mac_port {
8484
open(my $f, '<', $file);
8585
while(<$f>) {
8686
chomp;
87-
if ( m/::(sysName|sysLocation|ipDefaultTTL|dot1dStpPriority|dot1dStpTopChanges|dot1dStpDesignatedRoot|dot1dStpRootCost|dot1dStpRootPort|dot1qNumVlans|dot1dBaseBridgeAddress)\./ ) {
87+
if ( m/::(sysName|sysLocation|ipDefaultTTL|dot1dStpPriority|dot1dStpTopChanges|dot1dStpDesignatedRoot|dot1dStpRootCost|dot1dStpRootPort|dot1qNumVlans|dot1dBaseBridgeAddress|dot1dStpRootCost|dot1dStpRootPort)\./ ) {
8888
my $n = $1;
8989
my ( undef, $v ) = split(/ = \S+: /,$_,2);
9090

@@ -98,6 +98,7 @@ sub sw_name_mac_port {
9898
}
9999

100100
$sw->{$name}->{_}->{$n} = $v;
101+
101102
} elsif ( m/::(ifMtu|ifHighSpeed|ifSpeed)\[(\d\d?)\] = (?:INTEGER|Gauge32): (\d+)/ ) {
102103
$sw->{$name}->{$1}->[$2] = $3;
103104
# Dell PowerConnect 5548 doeesn't have ifHighSpeed
@@ -311,7 +312,15 @@ sub fake_gv {
311312
if ( $e->[3] == 0 ) {
312313
#print $dot_fh sprintf qq{ "%s":%d -> "%s"\n}, $e->[0], $e->[2], $e->[1];
313314
} else {
314-
print $dot_fh sprintf qq{ "%s":%d -> "%s":%d\n}, $e->[0], $e->[2], $e->[1], $e->[3];
315+
my $attr;
316+
if ( $e->[2] == $sw->{$e->[0]}->{_}->{dot1dStpRootPort} ) {
317+
$attr = "arrowtail=crow";
318+
} elsif ( $e->[3] == $sw->{ $e->[1] }->{_}->{dot1dStpRootPort} ) {
319+
$attr = "arrowhead=crow";
320+
}
321+
$attr = " [ $attr ]" if $attr;
322+
323+
print $dot_fh sprintf qq{ "%s":%d -> "%s":%d%s\n}, $e->[0], $e->[2], $e->[1], $e->[3], $attr;
315324
}
316325
}
317326

0 commit comments

Comments
 (0)