I wrote a Perl script a long time ago to backup the binary configuration files for all our Nortel Ethernet and Ethernet Routing Switches (including BayStack 350 and 450s, Ethernet Switch 460 and 470s, Ethernet Routing Switch 4500s and Ethernet Routing Switch 5500s, Ethernet Routing Switch 1600 and 8600s along with Motoroal WS5100 and RFS7000s and HP GbE2s). The Perl script was very simple and straightforward. The problem was that the Nortel configuraiton files were binary files that we as engineers were unable to review or analyze. There were no tools (at least not that I’m aware of) that could allow us to review those configurations. If we had a question about the configuration stored in the binary file we had to restore the configuration to a mock up switch(s) in our testlab in order to be able to review the actually configuration. It seems that Nortel finally heard our cries for help and added a new feature in v3.7.x (ES460/ES470) and v5.1.x (ERS5500) software that would allow us to TFTP upload the ASCII configuration from the ACG.
There was one problem though… the SNMP OID has yet to be documented in the Nortel SNMP MIBS. I had to run a packet trace against Nortel’s Device Manager to determine the OID that Device Manager was using to initiate the manual config upload. I found that the OID was ”
1.3.6.1.4.1.45.1.6.4.4.19.0″
I took my existing script and created a new subroutine and had everything working within about 30 minutes.
Here’s some of the code I wrote;
############################################################################
# Subroutine baystack_tftp_config_ascii
#
# Purpose: use SNMP to instruct BayStack switches to TFTP upload their
# ASCII configuration file to the central TFTP server
############################################################################
sub baystack_tftp_config_ascii {
#s5AgSysTftpServerAddress
#s5AgSysAsciiConfigFilename
#s5AgSysAsciiConfigManualUpload (NOT IN THE MIBS) USE 1.3.6.1.4.1.45.1.6.4.4.19.0
# snmpset -v2c -cprivate 10.1.1.100 1.3.6.1.4.1.45.1.6.4.4.19.0 i 4
# Declare Local Variables
my $setresult;
$filename = "ascii/".$filename;
my $sess = new SNMP::Session ( DestHost => $snmphost,
Community => $community,
Version => SNMPVER );
my $vars = new SNMP::VarList(
['s5AgSysTftpServerAddress', 0, "10.1.1.20",],
['s5AgSysAsciiConfigFilename', 0, $filename,] );
my $go = new SNMP::VarList(
['.1.3.6.1.4.1.45.1.6.4.4.19', 0, 4, 'INTEGER'] );
&check_filename($filename);
# Set TFTP source and destination strings
$setresult = $sess->set($vars);
if ( $sess->{ErrorStr} ) {
print "ERROR: {BayStack} problem setting the TFTP parameters (TFTP IP, FILENAME) for $snmphost\n";
print "ERROR: {BayStack} sess->{ErrorStr} = $sess->{ErrorStr}\n";
}
# Start TFTP copy
$setresult = $sess->set($go);
if ( $sess->{ErrorStr} ) {
print "ERROR: {BayStack} problem setting the TFTP action bit for $snmphost\n";
print "ERROR: {BayStack} sess->{ErrorStr} = $sess->{ErrorStr}\n";
}
# Pause while the TFTP copy completes
sleep $PAUSE;
# Check to see if the TFTP copy completed
$setresult = $sess->get('.1.3.6.1.4.1.45.1.6.4.4.19.0');
if ( $sess->{ErrorStr} ) {
print "ERROR: problem checking the TFTP result for $snmphost\n";
print "ERROR: sess->{ErrorStr} = $sess->{ErrorStr}\n";
}
# If TFTP failed output error message
if ($setresult != 1) {
while ($setresult == 2) {
print "DEBUG: config upload status = $setresult (waiting)\n" if (DEBUG);
sleep $PAUSE;
$setresult = $sess->get('.1.3.6.1.4.1.45.1.6.4.4.19.0');
} #end while
} #end if $test ne "success"
# If the upload command failed let's try again
if ($setresult == 3) {
print "DEBUG: initial command returned $setresult\n" if (DEBUG);
print "DEBUG: lets try the upload command again\n" if (DEBUG);
# Let's pause here for a few seconds since the previous command failed
sleep $PAUSE;
# Start TFTP copy
$setresult = $sess->set($go);
if ( $sess->{ErrorStr} ) {
print "ERROR: problem setting the TFTP action bit for $snmphost\n";
print "ERROR: sess->{ErrorStr} = $sess->{ErrorStr}\n";
}
# Pause while the TFTP copy completes
sleep $PAUSE;
# Check to see if the TFTP copy completed
$setresult = $sess->get('.1.3.6.1.4.1.45.1.6.4.4.19.0');
if ( $sess->{ErrorStr} ) {
print "ERROR: problem checking the TFTP result for $snmphost\n";
print "ERROR: sess->{ErrorStr} = $sess->{ErrorStr}\n";
}
# If TFTP failed output error message
if ($setresult != 1) {
while ($setresult == 2) {
print "DEBUG: config upload status = $setresult (waiting)\n" if (DEBUG);
sleep $PAUSE;
$setresult = $sess->get('.1.3.6.1.4.1.45.1.6.4.4.19.0');
} #end while
} #end if
} #end if
if ($setresult != 1) {
print "DEBUG: $snmphost config upload *FAILED*!\n";
print SENDMAIL "ERROR:$snmphost ($sysObjectID) config (ASCII) upload *FAILED*!
\n";
} elsif ($setresult == 1) {
print SENDMAIL "$snmphost ($sysObjectID) was successful (ASCII)
\n";
print "DEBUG: $snmphost ($sysObjectID) was successful (ASCII)\n";
} else {
print "DEBUG: unknown error return = $setresult (ASCII)" if (DEBUG);
} #end if
print "DEBUG: upload config file results = $setresult (ASCII)\n" if (DEBUG);
return 1;
} #end sub baystack_tftp_config_ascii
Cheers!
Update: Friday April 10, 2009
I’ve discovered a small issue using the MIB “s5AgSysAsciiConfigFilename”. While the MIB says the value can be between 0..128 characters long I’ve actually found that the value can’t be an longer than 30 characters. If you try to use a filename that is greater than 30 characters you’ll get an SNMP set error. I actually had quite a few switches failing to backup properly because I was prepending “ascii/” to the filename. I tested this with software v3.7.2.x and v3.7.3.x on a Ethernet Switch 470.
s5AgSysAsciiConfigFilename OBJECT-TYPE SYNTAX DisplayString (SIZE (0..128)) MAX-ACCESS read-write STATUS current DESCRIPTION "Name of the ascii configuration file that will be downloaded/uploaded either at boot time when the s5AgSysAsciiConfigAutoDownload object is set to useConfig(3), or when the s5AgSysAsciiConfigDownloadStatus object is set to startDownload(4). When not used, the value is a zero length string." ::= { s5AgentSystem 6 }
Cheers!