A big, ugly, hairy, monotonous task recently fell in my lap at work. I had to update a couple configuration settings in approximately 900 menu-driven network devices. Each device had an independent authentication method with four or five possible username/password combos, and different menu options depending on firmware version. Completing one box would take about 2-3 minutes. Multiply that by 900 and you're looking at a solid week of nothing but menu navigation and data entry.
This ranked very high on my "List-of-things-that-make-me-want-to-stab-my-eyes-out".
The disparity of versions and lack of a single configuration standard rendered my usual methods of scripting useless. A dark little rain cloud settled over my cube.
Then my boss made the comment, "These things have SNMP, right?"
I heard, "These things have SNMP write?"
I immediately started researching and sure enough, I could use the "snmpset" command to script the updates for me!
WIN!
Here is a copy of the '
bulk_snmpset.sh' script that I used to do the updates:
#!/bin/bash
while read HOST RWSTR; do
snmpset -v 2c -c $RWSTR $HOST <snmp_oid_here> a "192.168.100.100"
done < $1
I fed this script a flat text file (
hosts_to_update.txt) with the 900 host names and their respective SNMP read/write string that looked like this:
10.10.10.1 SNMPrwSTRING1
10.10.10.2 SNMPrwSTRING2
10.10.10.3 snmpRWstring3
...
Actually making it worked, looked like this:
me@ubuntu:~/scripts $./bulk_snmpset.sh hosts_to_update.txt
All that remained was to capture the ones that failed and either adjust the script accordingly or take care of them manually