inventory.sh #!/bin/sh # # inventory.sh -- a script to extract valuable information # from a list of routers. (Name, Type, IOS version) # # # Set behaviour public="ORARO" workingdir="/home/cisco" # LOG=$workingdir/RESULT.csv infile=$workingdir/RTR_LIST snmp="/usr/local/bin/snmpget -v1 -c $public" # while read device do $snmp $device sysName.0 > /dev/null if [ "$?" = "0" ] ; then rtr=`$snmp $device .1.3.6.1.4.1.9.2.1.3.0 | cut -f2 -d\" ` type2=`$snmp $device .1.3.6.1.4.1.9.9.25.1.1.1.2.3 | cut -f2 -d$ ` ios=`$snmp $device .1.3.6.1.4.1.9.9.25.1.1.1.2.5 | cut -f2 -d$ ` prot=`$snmp $device .1.3.6.1.4.1.9.9.25.1.1.1.2.4 | cut -f2 -d$ ` echo "$device, $rtr, $type2, $ios, $prot" >> $LOG fi done < $infile