Show bgp peers across VSX in CLI

Document created by Petr Hantak on Jul 10, 2018
Version 1Show Document
  • View in full screen mode

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



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.

3 people found this helpful