Create a Post
cancel
Showing results for 
Search instead for 
Did you mean: 
Petr_Hantak
Advisor
Advisor

Show bgp peers across VSX in CLI

I need to check quite often during maintenance windows how it looks with BGP peers before and after change steps. Especially on VSX is useful to get a quick way how to check something across all virtual systems. Following command list you all BGP peers across virtual systems. It works on non-vsx as well. 

BGP peers output

Command:

echo -e "\e[36m+++++++++++++++++++++++++++\n++    BGP peers status   ++\n+++++++++++++++++++++++++++\n";for i in /proc/vrf/*; do i=${i#*vrf/}; echo -n -e "\e[93m"; vsenv $i | grep  -e "Contex" | sed 's/^Context is set to Virtual Device //' | sed 's/ID/Context/'; echo -n -e "\e[0m"; echo "set virtual-system" $i > /tmp/clishcmd; echo "show bgp peers" >> /tmp/clishcmd; clish -i -f /tmp/clishcmd | grep -vi -e "contex" -e "show" -e "done" -e "flag" -e"^$"; echo; done

Original command idea how to list across contexts is not my own. I got is as advice during TAC case some years ago. You can basically use it to list anything (blue area) in case you are fine with little messy output. It is just simple setup of cmd file for clish:

for i in /proc/vrf/*; do i=${i#*vrf/};  vsenv $i; echo "set virtual-system" $i > /tmp/clishcmd; echo "show bgp peers" >> /tmp/clishcmd; clish -i -f /tmp/clishcmd; done

Hope you'll enjoy it.

4 Replies
HeikoAnkenbrand
Champion Champion
Champion

I am like oneliner. Smiley Happy

From me 1oo points!

Regards

Heiko

➜ CCSM Elite, CCME, CCTE
Petr_Hantak
Advisor
Advisor

Thank you! I'm glad you like it.

Danny
Champion Champion
Champion

Maybe you could use column to show the rows more nicely formatted?

0 Kudos
Parminder_Singh
Explorer

Hi Peter

I want to do the same thing but that script only works for the old kernel VSX, it would need to be updated for the new kernel (specifically the “for i in /proc/vrf/*; do i=${i#*vrf/}” part because they use namespace now instead of vrf.

0 Kudos

Leaderboard

Epsum factorial non deposit quid pro quo hic escorol.

Upcoming Events

    CheckMates Events