Last active
August 29, 2015 14:00
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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