router multi ping TCL

From CCIE networking & linux
Jump to: navigation, search

How to ping multiple devices at the same time? With one command? The answer is again TCL scripting.

foreach address {
x.x.x.x
x.x.x.x
x.x.x.x
x.x.x.x} { ping $address
}

for example:

Router#tclsh
Router(tcl)#foreach address {
+>(tcl)#10.12.23.2
+>(tcl)#10.12.23.3
+>(tcl)#10.12.23.4
+>(tcl)#10.12.23.6
+>(tcl)#10.12.23.7
+>(tcl)#} { ping $address re 10 si 1500
+>(tcl)#}
Type escape sequence to abort.
Sending 10, 1500-byte ICMP Echos to 10.12.23.2, timeout is 2 seconds:
!!!!!!!!!!
Success rate is 100 percent (10/10), round-trip min/avg/max = 4/4/4 ms
Type escape sequence to abort.
Sending 10, 1500-byte ICMP Echos to 10.12.23.3, timeout is 2 seconds:
!!!!!!!!!!
Success rate is 100 percent (10/10), round-trip min/avg/max = 4/4/4 ms
Type escape sequence to abort.
Sending 10, 1500-byte ICMP Echos to 10.12.23.4, timeout is 2 seconds:
……….
Success rate is 0 percent (0/10)
Type escape sequence to abort.
Sending 10, 1500-byte ICMP Echos to 10.12.23.6, timeout is 2 seconds:
!!!!!!!!!!
Success rate is 100 percent (10/10), round-trip min/avg/max = 1/1/4 ms
Type escape sequence to abort.
Sending 10, 1500-byte ICMP Echos to 10.12.23.7, timeout is 2 seconds:
!!!!!!!!!!
Success rate is 100 percent (10/10), round-trip min/avg/max = 1/3/4 ms
R1(tcl)#tclquit


Type “tclsh” to enter the Tcl shell. You can see that you can add extended commands to the ping command (repeat 10 size 1500 in this case). I included IP address 172.12.23.4 to show the output when a ping is not successful.

Be sure to type “tclquit” after the script has run. Usually you will see the “(tcl)” at the command prompt, but I have seen that disappear even though you are STILL in the Tcl shell. This has happened to me when I go into config mode from Tcl shell. After [cntrl + z] I exit out to the command prompt, but the “(tcl)” does not show:

   r1#tclsh
   r1(tcl)#conf t
   Enter configuration commands, one per line.  End with CNTL/Z.
   r1(config)#^Z
   r1# <- still in Tcl shell!!!

I generally keep a copy of the Tcl script in a text file so that I can just paste it into the router to test connectivity at any time. The extra time it takes to create/modify the text file is much less than the time it would take to type “ping x.x.x.x” for each device. You are also less likely to forget a device.

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox
Offer
Martin Satara