Skip to content

Instantly share code, notes, and snippets.

@olanystrom
Last active August 29, 2015 14:00
Show Gist options
  • Save olanystrom/11216106 to your computer and use it in GitHub Desktop.
Save olanystrom/11216106 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# Written by Ola Nyström <olanys@gmail.com>
#
# Fetches Interface information and puts in a textfile, use with alias or the like to
# get information from descriptionfields and vlan id on cisco switches and routers
#
# Example in bash function
# function office() { grep "$@" /var/rancid/switchports-office;}
#
#
#
switches=( switch01 switch02 router01 router02 )
outfile="/var/rancid/switchports-office"
echo > $outfile
nr=${#switches[@]}
count=0
for i in "${switches[@]}"
do
count=`echo $count+1 | bc`
p=`echo $count*100/$nr | bc`
echo -n "Fetching: "
echo -n $i
echo -n -e \\t
clogin -c "show int status" $i | egrep '^(Gi|Eth|Fa|Po)' | sed "s/\(.*\)/$i:\1/" >> $outfile
echo -n $p
echo "%"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment