;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Copyright 2002 Routrek Networks,Inc. All rights reserved ; Juniper definition ; Version 0.2 ; $RCSfile: TargetJuniper.txt,v $ ; $Revision: 1.12 $ $Date: 2002/10/18 10:43:21 $ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; RMC configuration example: ; ; copy terminal running-config (then paste this file.) ; set port comN ; set target-type juniper ; set target-login-name ; set target-login-password ; set target-check ; set network-info-time ; set connect-log ; set spy comN tfl0 ml0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Note: ; To display JUNOS log messages on the console, use the following ; command: ; configure ; edit system syslog console ; commit ; See also "JUNOS Interface Software Configuration Guide" ; - Getting Started - System Log Messages Overview ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; set user-target-type juniper ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; set target-filter juniper tfl0 # All severity (emergency, alert, critical, error, warning, info, debug) # $Revision: 1.12 $ $Date: 2002/10/18 10:43:21 $ logtype == "show-log" { if($0 ~ /^\r*$/) { # end of logs in show tech-support logtype = "" next } if($0 ~ /[>#] /) { logtype = "" next } } /[>#] show log/ { # logs in "show log" logtype = "show-log" next } /[>#] show chassis alarm/ { # logs in "show chassis alarm" logtype = "show-log" next } /^\r*[A-Z][a-z][a-z] [0-9]+ [0-9:]+ +[^ ]+/ { print next } /^\r*login: [A-Z][a-z][a-z] [0-9]+ [0-9:]+ +[^ ]+/ { # Cut login prompt gsub(/^.*login: +/, "") print next } /^\r.+@.+[>#] [A-Z][a-z][a-z] [0-9]+ [0-9:]+ +[^ ]+/ { # Cut login prompt gsub(/^.+@.+[>#] +/, "") print next } ----END OF FILTER---- ; set target-filter juniper tfl1 # High severity (emergency, alert, critical) ----END OF FILTER---- ; set target-filter juniper tfl2 # Middle severity (error) ----END OF FILTER---- ; set target-filter juniper tfl3 # Low severity (warning, info, debug) ----END OF FILTER---- ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; set target-script juniper login # Login script for Juniper # $Revision: 1.12 $ $Date: 2002/10/18 10:43:21 $ # # Send [enter] and wait password prompt. send "" wait_prompt: expect { "> " exit 0 " # " goto wait_prompt "# " exit 0 "% " goto cli "login:" goto login "---More---" goto more "---(more" goto more timeout 10 goto error } # Send login name login: ! test "$TARGET_LOGIN_NAME" if $? = 0 send $(TARGET_LOGIN_NAME) if $? != 0 send "root" expect { "> " exit 0 "# " exit 0 "% " goto cli "assword:" goto password timeout 10 goto error } # cli mode cli: send "cli" expect { "> " exit 0 "# " exit 0 timeout 10 goto error } # Send password password: send $(TARGET_LOGIN_PASSWORD) expect { "> " exit 0 "# " exit 0 "% " goto cli "incorrect" goto password_error timeout 10 goto error } password_error: exit 3 # quit more prompt more: send "q\c" goto wait_prompt error: exit 1 ----END OF SCRIPT---- set target-script juniper command # command script for Juniper verbose off call login timeout 600 verbose on # Command loop loop: set r 1 # send a command one by one ! sendcmd if $? != 0 goto logout gosub wait_prompt goto loop wait_prompt: # login : To handle system restart command # [yes,no] .. : "Exit with uncommitted changes? [yes,no] (yes)" expect { "> " break " # " goto wait_prompt "# " break "---More---" goto more "---(more" goto more "? [yes, no] (yes)" goto confirm "? [yes, no] (no)" goto confirm "login: " exit 0 timeout 60 goto chk_response } # seems to be a prompt but check interval to confirm. wait_interval: expect { timeout 1 return } goto wait_interval chk_response: expect { timeout 10 goto no_response } set r 1 goto wait_prompt no_response: if r = 0 goto error dec r send "" goto wait_prompt # send 'N' to more prompt (display the output all at once) more: send "N\c" goto wait_prompt # send "yes" to confirm yes/no prompt confirm: send "yes" goto wait_prompt # send "no" to confirm yes/no prompt noconfirm: send "no" goto wait_prompt logout: verbose off # changes? (y/n) : config save confirmation while logout send "quit" logout_loop: expect { "login:" exit 0 "% " send "quit" "> " send "quit" "? [yes, no] (yes)" send "no" "? [yes, no] (no)" send "no" timeout 20 goto error } goto logout_loop error: exit 1 ----END OF SCRIPT---- set target-script juniper target-check # target-check script for Juniper # set target-script juniper target-check send "" expect { "> " exit 0 "# " exit 0 "% " exit 0 "login:" exit 0 "---More---" exit 0 "---(more" goto more timeout 20 exit 1 } ----END OF SCRIPT---- set target-script juniper network-info # command ('command' script is necessary) # Network information command for Juniper # Software version show version | no-more # show system software # Router up time show system uptime # Configuration show configuration | no-more # test configuration # User account information show system users | no-more # Network connection information # show system connections # Network Time Protocol # show ntp associations # show ntp status # Packet Forwarding Engine information show pfe terse | no-more # System software # show system buffers # show system processes # show system statistics # show system storage # show task show task memory | no-more # show system audit # Static interface information # show interfaces show interfaces terse | no-more # Chassis show chassis alarm | no-more show chassis environment | no-more show chassis hardware | no-more # Routing table information #show route # Forwarding table information # show route forwarding-table # IS-IS Adjacent routers # show isis adjacency # OSPF Adjacent routers show ospf neighbor | no-more # BGP Entries in the BGP neighbor database # show bgp neighbor show bgp summary | no-more # MPLS show mpls lsp | no-more # show route label-switched-path # RSVP # show rsvp interface # show rsvp session # show rsvp statistics # VRRP show vrrp summary | no-more # Firewall # show firewall filter show firewall log | no-more # Information for Custmer Support # request support information ----END OF SCRIPT----