summaryrefslogtreecommitdiff
path: root/other_scripts/bgpreport.sh
blob: ae82b0cfcdfe68033050693c70b1d8aa66e9864a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/bash
echo "<table><tr><th>Peer</th><th>type</th><th>state</th></tr>";

/usr/sbin/birdcl -r s p | while read -r line; do
        outp=$(echo "$line" | /usr/bin/awk -v print_info=0 -v pref='^p_' -f /root/bird2.awk)
        if [[ -z "$outp" ]]; then
		continue
	fi
	echo "$outp"
        protocol=$(echo "$line" | awk -e '{ print $1; }')
        outp=$(birdcl -r "show route where bgp_large_community ~ [(CLEARNET_ASN, LC_FILTERED, *)] protocol ${protocol} table t_myas_unfiltered count" | grep t_myas_unfiltered | grep -E -o "[1-9][0-9]* of [0-9]+ routes")
        if [[ -n "$outp" ]]; then
                echo "<tr><td></td><td colspan='2'>filtered ${outp}</td></tr>"
	else
                echo "<tr><td></td><td colspan='2'>no filtered routes</td></tr>"
        fi
done

echo "</table>"