track spanning tree topology changes
authorDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 19 Jun 2018 14:50:16 +0000 (16:50 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 19 Jun 2018 14:50:16 +0000 (16:50 +0200)
syslog-count-link.pl

index 26963cf..d33c477 100755 (executable)
@@ -14,6 +14,8 @@ use Data::Dump qw(dump);
 use POSIX qw(strftime);
 
 my $timeout = $ENV{TIMEOUT} || 60; # forget switch after sec
+# timeout should be smaller than stp refresh inverval or
+# stp messages will accumulate forever
 
 my $name = $0;
 $name =~ s/.*\/([^\/]+)$/$1/;
@@ -39,7 +41,7 @@ sub print_stats {
                                delete $stat->{$host}->{$port};
                                next;
                        }
-                       my $out = sprintf "%-12s %-4s %-2d %s\n", $host, $port, $dt, $stat->{$host}->{$port}->[1];
+                       my $out = sprintf "%-12s %-8s %-2d %s\n", $host, $port, $dt, $stat->{$host}->{$port}->[1];
                        print $out;
                        print $fh $out;
                }
@@ -116,6 +118,11 @@ while(<>) {
                stat_host_port( $host, $port, substr($state,0,1) );
 
 
+       } elsif ( m/($host_re) TRAPMGR.* %% Spanning Tree Topology Change: (\d+)/ ) {
+               my ( $host, $state ) = ( $1, $2 );
+               stat_host_port( $host, 'STP', $2 );
+
+
        } elsif ( m'==> /var/log/' ) {
                # ignore tail output
                next;