#!/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 saving to the working directory using # a filename based on the switch name used to call the script. # # Language: Expect # # Author: Michael McNamara (http://blog.michaelfmcnamara.com) # # Date: May 6, 2003 # # License: # Copyright (C) 2002 Michael McNamara (mfm@michaelfmcnamara.com) # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see # # Changes: # # Sept 29, 2006: cleaned up script/updated documenation # Dec 30, 2005: added command line arguements 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 # # 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" # # Set Default Variables # set USERNAME "Manager" set PASSWD "nortel" # # 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 \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/logs/$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" # # date # show sys topo # show tech # show config # date # ####################### # REQUESTED BY NORTEL ####################### # config cli more false # show ports error show-all # show ports stats stg # show ports info stg main # show ip ospf stats # 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 "\:.\#|> " # CONFIG CLI MORE FALSE send -- "config cli more false\r" expect -re "\:.\#|> " # SHOW send -- "date;show sys perf\r" expect -re "\:.\#|> " sleep 2 # SHOW send -- "date;show sys perf\r" expect -re "\:.\#|> " sleep 2 # SHOW send -- "date;show sys perf\r" expect -re "\:.\#|> " # SHOW send -- "show config\r" expect -re "\:.\#|> " # SHOW send -- "show tech\r" expect -re "\:.\#|> " # SHOW send -- "show mlt info\r" expect -re "\:.\#|> " # SHOW send -- "show mlt ist st\r" expect -re "\:.\#|> " # SHOW send -- "show sys topology\r" expect -re "\:.\#|> " # SHOW send -- "show sys record-reservation\r" expect -re "\:.\#|> " # SHOW send -- "show port info int\r" expect -re "\:.\#|> " # SHOW send -- "show port info config\r" expect -re "\:.\#|> " # SHOW send -- "show port stats interface extended\r" expect -re "\:.\#|> " # SHOW send -- "show port stats interface extended\r" expect -re "\:.\#|> " # SHOW send -- "show port error main\r" expect -re "\:.\#|> " # SHOW send -- "show port error main\r" expect -re "\:.\#|> " # SHOW send -- "show port stats bridging\r" expect -re "\:.\#|> " # SHOW send -- "show port stats bridging\r" expect -re "\:.\#|> " # SHOW send -- "show port stats egress-queues\r" expect -re "\:.\#|> " # SHOW send -- "show port stats egress-queues\r" expect -re "\:.\#|> " # SHOW send -- "clear port stats\r" expect -re "\:.\#|> " # SHOW send -- "show sys perf\r" expect -re "\:.\#|> " # SHOW send -- "show sys top\r" expect -re "\:.\#|> " # SHOW send -- "show ip pim show-all\r" expect -re "\:.\#|> " # SHOW send -- "show ip ospf show-all\r" expect -re "\:.\#|> " # SHOW send -- "show ip igmp show-all\r" expect -re "\:.\#|> " # SHOW send -- "show ip mroute route\r" expect -re "\:.\#|> " # SHOW send -- "show ip mroute next-hop\r" expect -re "\:.\#|> " # DATE send -- "date\r" expect -re "\:.\#|> " send -- "logout\r" expect eof ####################################################################### # E N D P R O G R A M #######################################################################