Whenever you contact Nortel, Cisco or Juniper support these days your going to need to spend some time and effort collecting a fair amount of information for the engineer assigned to your case.
I’ve written a very simple Expect script that will telnet into a Nortel Ethernet Routing Switch 8600 and issue a series of commands saving all the output so you can forward it to Nortel (or examine it yourself offline).
#!/usr/bin/expect -f # # Filename: /usr/local/etc/8600dump.exp # # Purpose: Dump technical information from Nortel Ethernet Routing Switch # via telneting to the device and issuing various "show" cmds. # The output will then be saved to the working directory using # a filename based on the switch name used to call the script. # # Language: Expect # # Author: Michael McNamara # # Date: May 6, 2003 # # Changes: # # Sept 29, 2006: cleaned up script/updated documentation # Dec 30, 2005: added command line arguments for portability # Mar 18, 2005: added file logging for troubleshooting and monitoring # May 20, 2003: fine tuned script removing a great many "expect" commands. # May 6, 2003: original Expect script generated from auto_expect # # Notes: # Command Line Reference; # ./8600dump.exp <switch> <username> <password> # # This Expect script was generated by autoexpect on Thu Aug 18 10:57:50 2005 # Expect and autoexpect were both written by Don Libes, NIST. # # set force_conservative 0 ;# set to 1 to force conservative mode even if ;# script wasn't run conservatively originally if {$force_conservative} { set send_slow {1 .1} proc send {ignore arg} { sleep .1 exp_send -s -- $arg } } # # Declare Global Variables # set PATH "/usr/local/etc/" set TELNET "/usr/bin/telnet" # # Assign Command Line Variablbes # set SWITCH [lindex $argv 0] set USERNAME [lindex $argv 1] set PASSWD [lindex $argv 2] # # Time Date Stamp # set TODAY [timestamp -format %y%m%d ] set WEEKDAY [timestamp -format %a ] set DATE [timestamp -format %c ] set send_human {.1 .3 1 .05 2} ###################################################################### # proc usage # # Purpose: display the usage information to the enduser. ###################################################################### proc usage {} { send_user "\n" send_user "ERROR: command line paramaters incorrect\n" send_user "\n" send_user "usage: 8600dump.exp <switch> <username> <password>\n" send_user "\n" send_user " switch the DNS or IP address of switch \n" send_user " username the username for login to the switch \n" send_user " password the password for username\n" send_user "\n" send_user "\n" exit } ####################################################################### ####################################################################### # M A I N P R O G R A M ####################################################################### if {[llength $argv]!=3} usage log_file $PATH/$SWITCH.dump.log log_user 0 # Disable logging to STDOUT #log_user 1 # Enable logging to STDOUT # Useful information out to logfile send_log "******************************************************************\r\n" send_log "* STARTING LOGFILE FOR $SWITCH ON $DATE \r\n" send_log "******************************************************************\r\n" set timeout -1 spawn $TELNET $SWITCH match_max 100000 expect "Connected to" expect "Login: " send -- "$USERNAME\r" expect "Password: " send -- "$PASSWD\r" expect -re "\:.\#|> " # DATE send -- "date\r" expect -re "\:.\#|> " #################################################### # YOU CAN ADD AND REMOVE COMMANDS AS YOU SEE FIT #################################################### # CONFIG CLI MORE FALSE send -- "config cli more false\r" expect -re "\:.\#|> " # SHOW TECH send -- "show tech\r" expect -re "\:.\#|> " # SHOW CONFIG send -- "show config\r" expect -re "\:.\#|> " # SHOW SYS TOPO send -- "show sys topo\r" expect -re "\:.\#|> " # SHOW send -- "show ports error show-all\r" expect -re "\:.\#|> " # SHOW PORT ERROR MAIN #send -- "show port error main\r" #expect -re "\:.\#|> " # SHOW PORT ERROR EXT #send -- "show port error ext\r" #expect -re "\:.\#|> " # SHOW IP ROUTE INFO ALTERNATIVE #send -- "show ip route info alternative\r" #expect -re "\:.\#|> " # SHOW IP BGP SHOW-ALL #send -- "show ip bgp show-all\r" #expect -re "\:.\#|> " # DATE send -- "date\r" expect -re "\:.\#|> " send -- "logout\r" expect eof ####################################################################### # E N D P R O G R A M #######################################################################
You can also download the complete Expect script from my website here.
Occasionally you might have multiple switches that you’ll need to interrogate and for that I’ve written a quick and dirty little Bash shell script to loop through the FQDN of the switches calling the Expect script above.
#!/bin/sh
#
# Filename: /usr/local/etc/8600dump.sh
#
# Purpose: Dump technical information from Nortel Ethernet Routing Switch
# via telneting to the device and issuing various "show" cmds.
# The output will then be saving to the working directory using
# a filename based on the switch name used to call the script.
#
# Language: Bash Script
#
# Author: Michael McNamara
#
# Date: May 6, 2003
#
# Changes:
#
# Sept 29, 2006: cleaned up script/updated documentation
# Dec 30, 2005: added command line arguments for portability
# Mar 18, 2005: added file logging for troubleshooting and monitoring
# May 20, 2003: fine tuned script removing a great many "expect" commands.
# May 6, 2003: original Expect script generated from auto_expect
#
# Notes:
# Command Line Reference;
# ./8600dump.sh
#
# There are system and network specific variables below. Obviously the "PATH"
# to the location of the Bash script and supporting Expect script. The location
# of MUTT if email is used and most importantly the username and password to the
# Nortel Ethernet Routing Switch 8600. I would highly suggest using the ro (ReadOnly)
# account for all scripting purposes that are "read-only" in nature. The last most
# obvious piece is the list of switches that you'd like the script run against.
#
# Global Variables
PATH_TO=/usr/local/etc/mlh
DUMP=8600dump.exp
MAIL_LIST=''
PAGER_LIST=''
ERROR_FLAG=0
MAILEXE='/usr/bin/mutt'
MAILTXT='/tmp/mutt.txt'
LOCKFILE=/tmp/trace.lck
USERNAME=ro
PASSWORD=
SWITCHES='switch1.domain switch2.domain'
#############################################################################
# B E G I N M A I N
#############################################################################
for SWITCH in $SWITCHES
do
$PATH_TO/$DUMP $SWITCH $USERNAME $PASSWORD
$MAILEXE -s "ALERT: Dump Report for $SWITCH" $MAIL_LIST -a $PATH_TO/$SWITCH.trace.log < $MAILTXT
done
exit
#############################################################################
# E N D M A I N
#############################################################################
You can also download the complete shell script here.
The use of Expect really helps save me a lot of time and it speeds up the troubleshooting process with the vendor.
Cheers!