cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
3896
Views
0
Helpful
6
Replies

Tcl Ping Script Help

Hello Community,

I'm currently getting assistance from Joseph and Mike on another ping script.

In the meantime, I have come across the attached Tcl Ping script that might help. However, each time I attempt to run the script from the command line as such

event manager run pingall5.tcl

I get the following error message

MX-IPS1#eve man run pingall5.tcl

invalid command name "ping"

    while executing

"ping $address"

    ("foreach" body line 1)

    invoked from within

"foreach address {

10.36.36.225

183.19.28.8

150.19.2.2

183.19.28.2

183.19.123.2} { ping $address

}"

    invoked from within

"$slave eval $Contents"

    (procedure "eval_script" line 7)

    invoked from within

"eval_script slave $scriptname"

    invoked from within

"if {$security_level == 1} {       #untrusted script

     interp create -safe slave

     interp share {} stdin slave

     interp share {} stdout slave

..."

    (file "tmpsys:/lib/tcl/base.tcl" line 50)

Tcl policy execute failed: invalid command name "ping"

So I tried another tcl script called pingall8, but it simply won't get applied to the router.

I have attached both scripts.

You're assistance will be greatly appreciated.

Cheers

Carlton

6 Replies 6

Dan Frey
Cisco Employee
Cisco Employee

If your going to log into the device to execute the EEM policy manually it may be easier to paste some commands into the tcl shell and not worry about changing/re-register/uploading the EEM script as IPs are added and removed.

C2811_LA#tclsh

C2811_LA(tcl)#foreach address {

+>10.36.36.225

+>183.19.28.8

+>150.19.2.2

+>183.19.28.2

+>183.19.123.2} { ping $address

+>}

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 10.36.36.225, timeout is 2 seconds:

.....

Success rate is 0 percent (0/5)

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 183.19.28.8, timeout is 2 seconds:

.....

Daniel,

Thanks for responding.

Its not my intention to log into each device and execute manually.

I'm new to Tcl. I thought I could create a tcl script using the above and execute script with the event manager run command.

Cheers

You can execute the policy with event manager run" command and that is running eem manually rather than having it trigger from some event.   Attached is a EEM policy that will ping each IP addresses and print it to the screen.

CISCO1941_WAASX#event manager run pinger.tcl

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.223.3, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/4 ms

CISCO1941_WAASX#

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.223.126, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms

CISCO1941_WAASX#

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.223.2, timeout is 2 seconds:

.....

Success rate is 0 percent (0/5)

CISCO1941_WAASX#

Thanks Daniel,

Checking it out now.

Cheers

Daniel,

It appears to be working, however when I run the script via solarwinds or any other program capable of running tcl only the first ip address is pinged.

Any thoughts why that is?

Cheers

Carlton,

Your running this policy from a device that is not Cisco?  

By default IOS will send out 5 ICMP requests then quit.  Other systems can run ICMP requests indefintley  unless the ping command is given an argument for packet count or a user interrupt (Control-C).   Maybe solarwinds does not iterate through the IP address variable because it never quits pinging the first IP address.

I do not know solar winds products but you may want to look at the ping options (packet count) in the solar wind tool. 

Review Cisco Networking for a $25 gift card