diff options
Diffstat (limited to 'other_scripts/birdroutes.awk')
-rw-r--r-- | other_scripts/birdroutes.awk | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/other_scripts/birdroutes.awk b/other_scripts/birdroutes.awk new file mode 100644 index 0000000..615917a --- /dev/null +++ b/other_scripts/birdroutes.awk @@ -0,0 +1,48 @@ +# Intended purpose: Pipe birdc s p all into this script + +# initialize variable +BEGIN { + if (!pref) { + pref="^p_"; + } + if (print_info=="") { + print_info=0; + } + + proto=""; + print "<table><tr><th>Peer</th><th>type</th><th>state</th>"; + if (print_info == 1) { + print "<th>Info</th>"; + } + print "</tr>"; + #rowspan='2' +# print "<tr><th>imported</th><th>exported</th><th>preferred</th></tr>"; +} +END { + print "</table>"; +} + + +# default output for birdc, filter +$1=="BIRD" || $1=="Name" { + next +} + +# if line begins with dn and is a BGP line +$0 ~ pref && $2=="BGP" { + proto=$1 + print "<tr><td>" $1 "</td><td>" $2 "</td><td>" $4 "</td>"; + if (print_info == 1) { + print "<td>" $6 "</td>"; + } + print "</tr>"; + #rowspan='2' + next +} + +# for every other line "starting" a protocol +/^[a-zA-Z]/ { + # reset proto + proto="" + next +} |