|No such thing as a small change|
Hash of Hashes, referencing, dereferencing and Net::SNMPby smullis (Pilgrim)
|on Oct 06, 2004 at 10:58 UTC||Need Help??|
smullis has asked for the
wisdom of the Perl Monks concerning the following question:
We have around 3000 routers and a configuration database with entries created when the devices are commissioned. In order to ensure the integrity and accuracy of the recorded data I have a bash shell script that grabs the list of all devices and a few config variables (such as community strings, device type, line speed etc) and then double checks the validity of the config against the live device settings.
I am in the process of converting to Perl (from the original, and very slow bash script).
(Obviously, "perl -w" and "use strict" are used!)
So, I grab the list using LWP:
I then populate a HoH:
At this point I set up non-blocking Net::SNMP sessions and use callback to launch a subfunction to, in this example, add the mib2 sysobjid to the HoH:
Now, close the for loop and get the ball rolling:
Now, it has taken me a little while to get the referencing / dereferencing syntax working correctly but this seems OK now.
1. When I use Data::Dumper to get the contents of \$results_table the sysbojid and snmp_status variables seem to have zapped the rest of the data on the HoH for that site out of existence. Is the syntax incorrect? If I remove the sysobjid => unknown code then any site that is down (i.e. has its snmp allowed managers configured incorrectly) retains the line_speed / mgmt_ip data correctly.
2. Is using a HoH an appropriate approach? My thoughts were to use a HoH so that when I have all of the data I can chuck out all of the relevant HTML pages quite easily.
FYI - Using non-blocking Net::SNMP has reduced the runtime of this from around 20-30 minutes for the shell script (which ran serially) to around 24 seconds (WoooHooo!)
Any comments / suggestions / criticisms are more than welcome.
I am here to learn.