Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements
Webcast-Catalyst9k
New Member

EEM applet for IPSLA

Hi,

I have a scenario where i would like to execute a EEM applet for running an ip sla event when othe ip sla event is up. Just to summarize an IP sla event success should trigger anothe IP sla event. I have tried the two options below but was not able to find any debug logs.

ip sla 10
icmp-jitter x.x.x.x source-ip x.x.x.x num-packets 10
frequency 30
ip sla schedule 10 life forever start-time now

ip sla 20
icmp-jitter x.x.x.x source-ip x.x.x.x num-packets 10

frequency 30


event manager applet SLA
event timer cron cron-entry "5 * * * *"
event ipsla operation-id 10 reaction-type timeout
action 10   if $_ipsla_condition eq "Occurred"
action 15    cli command "enable"
action 20    cli command "configure term"
action 25    cli command "no ip sla schedule 20 life forever start-time now"
action 30    else
action 35    cli command "enable"
action 40    cli command "configure term"
action 45    cli command "ip sla schedule 20 life forever start-time now"
action 50   end

OR

ip sla 10
icmp-jitter x.x.x.x source-ip x.x.x.x num-packets 10
frequency 30
ip sla schedule 10 life forever start-time now

ip sla 20
icmp-jitter y.y.y.y source-ip y.y.y.y num-packets 10
frequency 30

track 1 ip lsa reachability

event manager applet SLA-1
event timer cron cron-entry "5 * * * *"

event track 1 state up

action 10 cli command "enable"

action 20 cli command "conf t"

action 30 cli command "ip sla schedule 20 life forever start-time now"

action 40 cli command "end"

 

event manager applet SLA-2

event timer cron cron-entry "5 * * * *"

event track 1 state down

action 10 cli command "enable"

action 20 cli command '' conf t"

action 30 cli command "no ip sla schedule 20 life forever start-time now"

action 40 cli command "end"

Regards,

Sathvik K V

2 ACCEPTED SOLUTIONS

Accepted Solutions
Cisco Employee

EEM applet for IPSLA

In only uses the username for authorization.  Authentication is not done.

Cisco Employee

EEM applet for IPSLA

The way this is written doesn't make a lot of sense.   I think you want:

event manager applet APP-1

event track 1 state up

action 001 cli command "enable"

action 002 cli command "show clock"

action 003 regexp "([0-9]+):[0-9]:[0-9]" $_cli_result match hour

action 004 if $hour ge 9

action 005 if $hour le 18

action 006 cli command "conf t"

action 007 cli command "ip sla 2"

action 008 cli command "icmp-echo x.x.x.x source-ip x.x.x.x"

action 009 cli command "frequency 30"

action 010 cli command "ip sla schedule 2 life forever start-time now"

action 011 end

action 012 end

23 REPLIES
Cisco Employee

EEM applet for IPSLA

I really don't understand why you have both a cron timer and an IPSLA event here.  If you just want to react to one IPSLA collector issue and configure another one depending on the condition, remove the cron event.

New Member

EEM applet for IPSLA

Joseph,

Had already tested without the cron event but the result is the same. Intially cron was configured to run the script only during buisness hours. So if would would like to run a script only during buisness hours with IPSLA what do you suggest?

Regards,

Sathvik

Cisco Employee

EEM applet for IPSLA

Have a look at the applets in https://supportforums.cisco.com/message/4025820#4025820 .  That will show you how to extract the "hours" portion of show clock then test against that to see if you're within your business hours window.

New Member

EEM applet for IPSLA

Thanks Joseph will check on that.

Regards,

Sathvik

New Member

EEM applet for IPSLA

Joseph,

Wanted some some guidance using event manager session cli username USER-NAME.  If i would like to authenticate the user using TACACS or RADIUS server how would it work.

Which all ways can be used to authenticate user before running a script.

Regards,

Sathvik K V

Cisco Employee

EEM applet for IPSLA

It works the same.  Just make sure the USER-NAME is known to TACACS or Radius.

New Member

EEM applet for IPSLA

So password should be provided in the script :  action 10 cli command "password"

Mentioning  password in the script is not suggested. Is there any other option that could be used??

Regards,

Sathvik

Cisco Employee

EEM applet for IPSLA

No, passwords are not required and not used.  You only need to specify the username.

New Member

EEM applet for IPSLA

Thank you will try the script now.

Just curious to know how would it work without a password

Cisco Employee

EEM applet for IPSLA

In only uses the username for authorization.  Authentication is not done.

New Member

EEM applet for IPSLA

Joseph,Thank you for the support

New Member

EEM applet for IPSLA

Hi Joseph,

I would like to run the script pasted below during buisness hours(9am to 6pm).  When two if conditions are used is it the first condition is checked and if that passes it will check the second condition.

event manager applet APP-1
event track 1 state up
action 001 cli command "enable"
action 002 cli command "show clock"
action 003 regexp "([0-9]+):[0-9]:[0-9]" $_cli_result match hour
action 004 if $hour ge 9
action 005 cli command "conf t"
action 006 cli command "ip sla 2"
action 007 cli command "icmp-echo x.x.x.x source-ip x.x.x.x"
action 008 cli command "frequency 30"
action 009 cli command "ip sla schedule 2 life forever start-time now"
action 010 end
action 011 if $hour le 18
action 012 cli command "ip sla 2"
action 013 cli command "icmp-echo x.x.x.x source-ip x.x.x.x"
action 014 cli command "frequency 30"
action 015 cli command "ip sla schedule 2 life forever start-time now"
action 016 end


event manager applet APP-2
event track 1 state down
action 10 cli command "enable"
action 20 cli command "conf t"
action 30 cli command "no ip sla 2"
action 40 cli command "end"

Regards,

Sathvik

Cisco Employee

EEM applet for IPSLA

The way this is written doesn't make a lot of sense.   I think you want:

event manager applet APP-1

event track 1 state up

action 001 cli command "enable"

action 002 cli command "show clock"

action 003 regexp "([0-9]+):[0-9]:[0-9]" $_cli_result match hour

action 004 if $hour ge 9

action 005 if $hour le 18

action 006 cli command "conf t"

action 007 cli command "ip sla 2"

action 008 cli command "icmp-echo x.x.x.x source-ip x.x.x.x"

action 009 cli command "frequency 30"

action 010 cli command "ip sla schedule 2 life forever start-time now"

action 011 end

action 012 end

New Member

EEM applet for IPSLA

Okie will check this. So a nested IF condition should be used.

Not much knowledge on EEM

New Member

EEM applet for IPSLA

Changed this line and it worked thank you

New Member

EEM applet for IPSLA

Hi Joseph,

I justed tried the script with action 004 if $hour ge 9 and action 005 if $hour le 12 and it didnt work. Time now is 12:05 but still script went on to execute ip sla.

Regards,

Sathvik

Cisco Employee

EEM applet for IPSLA

Of course, because the hour is le 12.  You should change that to lt so it will stop after 11:59.

New Member

EEM applet for IPSLA

Joseph, i meant after changing to 005 if $hour le 12 and the time current time on the device is 12:10 the script still configures IPSLA. I want the script to configure IPSLA only  between 9 to 12.

Cisco Employee

EEM applet for IPSLA

Right. The hour is stil 12.  12 le 12, so it makes sense the script still works.  As I said, change to lt 12, then you will get what you want.

New Member

EEM applet for IPSLA

ohh got the answer to my question, im matching only hours thanks

New Member

EEM applet for IPSLA

Joseph, for a IOS that doesnt support regular expression is there any way to configure EEM to run in a given time frame?

Cisco Employee

EEM applet for IPSLA

You'll need to convert to Tcl using http://www.marcuscom.com/convert_applet then install a Tcl policy.  The converted Tcl code should work as-is, though.

New Member

EEM applet for IPSLA


Thank you thats very helpful.

1203
Views
9
Helpful
23
Replies
CreatePlease to create content