cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2836
Views
5
Helpful
6
Replies

TCL Script to ping a host and if down, execute some IOS Commands

dastrix80
Level 1
Level 1

Hi All

 

I have a reoccuring issue in that the UCSE IP address on the management port goes down for some reason and my SNMP traps fail.

 

What I would like to do, is use a TCL script or something to ping this ip address (192.168.0.8) and if it fails, execute a shut/no shut on interface UCS2/0

TCL, Network ManagementDoing this 3-4 times per day would be useful

 

Does anyone have a sample configuration?

Thank you!

6 Replies 6

balaji.bandi
Hall of Fame
Hall of Fame

I believe you can achieve this with EEM Script

 

here is example (not sure what is the code of your IOS)

 

track 1 ip sla 10 reachability
delay down 10 up 10
ip sla 10
icmp-echo 192.168.0.8
frequency 30
ip sla schedule 10 life forever start-time now
!
event manager applet Link-Down
event track 1 state down
action 1.0 syslog msg "Reply timed out; Link is down"
action 2.0 cli command "enable"
action 3.0 cli command "conf t"
action 4.0 cli command "interface e0/0"   <-- change to your interface
action 5.0 cli command "shut"
action 6.0 cli command "no shut"
action 7.0 cli command "end"
action 8.0 syslog msg "Interface Ethernet 0/0 shutdown"
!

 

Manually test and advise.

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

Wow thank you for the fast reply!

 

IP SLA , nice solution. I will test adn advise

Ive modified the frequency timer to every 30minutes, will test and advise. May take some days as it doesnt always fail.

sure, if you have console access, you can manually shutdown and see if that script works

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

It works :)

 

Is there any issue in terms of load by having a frequency of say every 1 minute? Its a Cisco 3945

 

Do these scripts have the ability to do HTTP POST? It would be VERY useful to use some script to HTTP post an ON command to webserver when things go up or down based on PING response etc.

It works :)

Good to hear all work as expected.

 

ISR 3945 is good box, it should be ok, until you have many EEM Running in the Kit.

 

Do these scripts have the ability to do HTTP POST? It would be VERY useful to use some script to HTTP post an ON command to webserver when things go up or down based on PING response etc.

 

If i understand correctly you looking to send some output post to http server.

if this correct, you can send email (if you have setup smtp relay setup on your smtp service correctly)

you can also redirect the logs to syslog. and make own reports (out of the box)

 

make sense ?  if this resolved mark as resolved so it will be useful for other community users.

 

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

Review Cisco Networking for a $25 gift card