output in /dev/shm/spanning-tree-check.sh.out and git
[dell-switch] / spanning-tree-check.sh
1 #!/bin/sh -e
2
3 # check for files older than day
4
5 find log -name '*active*' -ctime +1  | cut -d_ -f2 | while read sw ; do
6         ./dell-switch.pl $sw 'show spanning-tree active'
7         echo -n '.'
8 done
9
10 (
11
12 #git -C out grep STP | grep -v RSTP | grep 'spanning-tree active' | sed -e 's/_/ /g'  | awk '{ print $2" .*"$6 }' > /tmp/st.1.patt
13
14 echo "# active roots"
15 git -C out grep -B 2 root '*active*'
16
17 echo "# root bridge"
18 (
19 git -C ../mikrotik-switch/out grep root-bridge-id | cut -d. -f 1,3 | sed 's/\./ /'
20 git -C out grep -A 4 'Root ID' '*active*' | grep Address | sed 's/_/ /g' | awk '{ print $2 " " $7 }'
21 ) | sort -k 2 | column -t
22
23 echo "# STP only (RSTP ignored) -- should be empty if OK"
24 git -C out grep STP | grep -v RSTP | grep 'spanning-tree active' | tee /tmp/st.2.full | sed -e 's/_/ /g'  | awk '{ print $6"\t"$2"[ \t$]" }' > /tmp/st.2.patt
25 grep -f /tmp/st.2.patt /dev/shm/neighbors.tab | column -t
26
27 ) | tee /dev/shm/$( basename $0 ).out
28 git commit -m "$( date +%Y-%m-%d ) $( basename $0 )" /dev/shm/$( basename $0 ).out