使用snmp,是為了自動化,不用一臺一臺的telnet上去后,運行copy running-config 命令了。
#!/bin/bash
device=x.x.x.x
random_number=$RANDOM
let "random_number %= 100"
server=x.x.x.x
d=`date +%Y%m%d-%H_%M_%S`
community=private
while getopts "d:c::s::" opt;do
case $opt in
d) device=$OPTARG;;
c) community=$OPTARG;;
s) server=$OPTARG;;
esac
done
log=sw_cisco_${device}_$d.log
echo Ready to backup $device config to $server use snmp community $community
snmpset -v 1 -c $community $device .1.3.6.1.4.1.9.9.96.1.1.1.1.2.$random_number i 1
snmpset -v 1 -c $community $device .1.3.6.1.4.1.9.9.96.1.1.1.1.3.$random_number i 4
snmpset -v 1 -c $community $device .1.3.6.1.4.1.9.9.96.1.1.1.1.4.$random_number i 1
snmpset -v 1 -c $community $device .1.3.6.1.4.1.9.9.96.1.1.1.1.5.$random_number a "$server"
snmpset -v 1 -c $community $device .1.3.6.1.4.1.9.9.96.1.1.1.1.6.$random_number string "$log"
snmpset -v 1 -c $community $device .1.3.6.1.4.1.9.9.96.1.1.1.1.14.$random_number i 1
device=x.x.x.x
random_number=$RANDOM
let "random_number %= 100"
server=x.x.x.x
d=`date +%Y%m%d-%H_%M_%S`
community=private
while getopts "d:c::s::" opt;do
case $opt in
d) device=$OPTARG;;
c) community=$OPTARG;;
s) server=$OPTARG;;
esac
done
log=sw_cisco_${device}_$d.log
echo Ready to backup $device config to $server use snmp community $community
snmpset -v 1 -c $community $device .1.3.6.1.4.1.9.9.96.1.1.1.1.2.$random_number i 1
snmpset -v 1 -c $community $device .1.3.6.1.4.1.9.9.96.1.1.1.1.3.$random_number i 4
snmpset -v 1 -c $community $device .1.3.6.1.4.1.9.9.96.1.1.1.1.4.$random_number i 1
snmpset -v 1 -c $community $device .1.3.6.1.4.1.9.9.96.1.1.1.1.5.$random_number a "$server"
snmpset -v 1 -c $community $device .1.3.6.1.4.1.9.9.96.1.1.1.1.6.$random_number string "$log"
snmpset -v 1 -c $community $device .1.3.6.1.4.1.9.9.96.1.1.1.1.14.$random_number i 1