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!
Swamy Goundar says
Thanks for script Michael. We have a few 5500’s in our labs and this new feature in 5.1 to download the configuration files in Ascii format is quite handy.
Do you know of any way to upload an ascii configuration file back up to the 5500 as sometimes we like to test out a config file across different firmware versions after modifying this by hand.
Its really limiting compared to the cisco ios.
Thanks,
Michael McNamara says
Hi Swamy,
I would agree with you that Cisco IOS is much more friendly in this (any many other) areas. There is a feature available to download an ASCII configuration file to the switch via TFTP.
Have another look at the screenshot of Device Manager I used in the article above and you’ll see the option called “AsciiConfigManualDownload“. There’s also a CLI equivalent;
5530-24TFD# copy tftp config filename address unit all
Thanks for the comment!
Curtis says
Don’t always depend on the ASCII config on a 55xx to be the same as the binary. I have found that there can be commands not included in the ASCII output. I have a CR that is supposed to be included in 5.1.3 for an OSPF cost command that does not get reflected in the ASCII config.
Michael McNamara says
Hi Curtis,
As usual you are very correct… this applies to all Ethernet Switch and Ethernet Routing Switches with the exception of the 1600 and 8600 switches.
Thanks for the comment!
Glen P says
Hi,
You might want to look at NetworkAuthority Inventory (http://inventory.alterpoint.com/) for this kind of thing.
It’s formerly ZipTie and it had a nice web interface and happily backs up the Nortel 8600/55xx/45xx L3 & L2 switches without a prob with a nice manageable interface written in flash.
Glen.
adogydearma says
Fantastic information. Hope to definitely visit soon
Joserra says
Hi,
I’d like to know which perl module do you use? Net::SNMP???
Thanks!!!
Regards,
Joserra.
Michael McNamara says
Hi Joserra,
Hmmm… I’m not exactly 100% certain but I do believe it is the Net:SNMP module. In the past you had to compile and install it by hand but I believe it was in yum the last time I installed it. Here are the packages that I generally install;
net-snmp : A collection of SNMP protocol tools and libraries.
net-snmp-devel : The development environment for the NET-SNMP project.
net-snmp-libs : The NET-SNMP runtime libraries.
net-snmp-perl : The perl NET-SNMP module and the mib2c tool.
net-snmp-utils : Network management utilities using SNMP, from the NET-SNMP project.
Hopefully that’s helpful. Good Luck!
Jean-Philippe Menil says
Hi,
your information are very helpfull.
However, for the ERS4500 series, it give me some errors, to employed the s5AgSysAsciiConfigFilename oid.
With a little search in the mib, i’m abble to backup the cascii config with the following command:
snmpset -v 2c -c $community -m S5-AGENT-MIB $ip s5AgAsciiConfigScriptSource.1 s tftp://$tftp/$filename s5AgAsciiConfigScriptManual.1 i 3
Thanks.
Regards.
Michael McNamara says
Thanks for the information Jean-Philippe!
Dominic Mathon says
Hi,
There is a way to convert this script to php ?
s5AgAsciiConfigScriptSource.1 don’t seem to work… anyone has a “snipset of code”. Thanx!
Michael McNamara says
Hi Dominic,
Jean-Philippe is utilizing an OID that is in the Avaya SNMP MIBs for the Ethernet Routing Switch product line. You would need to download the install the SNMP MIB on your system before it will work for you.
If you know the model and software release of switch you are working with you should be able to find a suitable MIB here. Or you could always visit Avaya’s website for the latest and greatest.
With respect to porting the code to PHP, it wouldn’t be very hard at all for anyone that knows PHP fairly well, you can search Google for examples. I personally like Perl so that’s what I use myself.
Cheers!