Create a Post
cancel
Showing results for 
Search instead for 
Did you mean: 
Kaspars_Zibarts
Employee Employee
Employee

Adding VS name to wrp links in routing table (netstat)

Not too sure if there were better means to see your next hop actual name rather than just wrpXXX or wrpjXXX, especially if you have large routing tables in VSX

So I wrote a small script that adds VS name to netstat -nr output

image.png

Probably the easiest is to place it in one of predefined paths i.e. /usr/bin. I called it vnetstat for simplicity and so I can remember

 

#!/bin/bash
hn=`hostname`
oldIFS=$IFS
IFS=''
netstat -nr | while read line; do
  vsname=""
  name=`echo "$line" |awk '{print $8}'`
  if [ `echo "$name" | grep -c wrp` -gt 0 ]; then
        if [ `echo "$name" | grep -c wrpj` -gt 0 ]; then
           name=`echo "$name" | sed 's/wrpj/wrp/g'`
        else
           name=`echo "$name" | sed 's/wrp/wrpj/g'`
        fi
        instance=`grep $name /config/active | grep ^interface |awk '/instance/{print "instance:"$2":name"}'`
        vsname=`grep "$instance" /config/active  | sed "s/${hn}_//" | awk '{print $2}'`
  fi

  echo -e -n $line
  echo -e " \t$vsname"
done
IFS=$oldIFS

 

 

tested it with R80.30 both 2.6 and 3.10 kernels as well as R76SP50 - seems to work

1 Reply
PhoneBoy
Admin
Admin

Nice one 😁
0 Kudos

Leaderboard

Epsum factorial non deposit quid pro quo hic escorol.

Upcoming Events

    CheckMates Events