12-13-2020 10:43 AM
Community,
I'm new to event manager and reading up. I need help with what information can be pulled into a variable. Using ISR G2 equipment, 15.4
Can I use an applet to basically do the following?
1. ping x.x.x.x source y.y.y.y repeat 50
2. return the sucess rate percentage
3. If sucess rate < 98%, then 'conf t, int tun 0, delay 100000,end'
4. If sucess rate > 98%, then 'conf t, int tun 0, delay 50000,end'
This is the output you'd normally get from ping, but I don't know if I can return/variable the sucess rate only
Sending 50, 100-byte ICMP Echos to 172.20.254.2, timeout is 2 seconds:
Packet sent with a source address of 172.20.254.3
!..!!.!!!!!.!!.!!!!!.!!.!.!..!!!!!.!!.!!!.!.!!!!.!
Success rate is 70 percent (35/50), round-trip min/avg/max = 120/121/136 ms
Side Note:
An IP SLA echo doesn't work for this, because it seems to only send one packet, so even though you can see how bad the packet loss is above, it comes back good most of the time with IP SLA echo.
Question 2: If so, what method should you use to get the success percentage? Context or something else?
Thanks
Solved! Go to Solution.
12-13-2020 11:57 AM
Hello,
the two scripts below should work...
event manager environment PING_SUCCESS 98
!
event manager applet PING_UP_EEM
event timer watchdog time 300
action 1.0 cli command "enable"
action 2.0 cli command "1.1.1.2 source 1.1.1.1 repeat 50"
action 2.1 set MATCH regexp_substr
action 3.0 regexp ".*Success rate is [0-9]+.*" $_cli_result _regexp_result regexp_substr
action 4.0 if $MATCH gt $PING_SUCCESS
action 6.0 cli command "conf t"
action 7.0 cli command "interface tunnel 0"
action 8.0 cli command "delay 100000"
action 9.0 cli command "end"
action 9.1 end
!
event manager applet PING_DOWN_EEM
event timer watchdog time 300
action 1.0 cli command "enable"
action 2.0 cli command "1.1.1.2 source 1.1.1.1 repeat 50"
action 2.1 set MATCH regexp_substr
action 3.0 regexp ".*Success rate is [0-9]+.*" $_cli_result _regexp_result regexp_substr
action 4.0 if $MATCH lt $PING_SUCCESS
action 6.0 cli command "conf t"
action 7.0 cli command "interface tunnel 0"
action 8.0 cli command "delay 50000"
action 9.0 cli command "end"
action 9.1 end
12-13-2020 12:37 PM - edited 12-13-2020 12:38 PM
I'll present an example if you wanted to consolidate into a single policy. The maxrun120 is going to be important as the default time to live of EEM is 20 seconds which is not enough in some situations. If the tunnel is down then the ping command will run for 100 seconds (50 ICMP pkts with 2 second timeout). If this happens and you do not update the maxrun timer to something greater than 100 seconds the script will not complete and the delay attribute will not be updated.
event manager applet tunnelHealth
event none maxrun 120
action 010 cli command "enable"
action 020 cli command "ping 8.8.8.8 source gig1 repeat 50"
action 040 regexp "Success rate is ([0-9]+) percent" "$_cli_result" match percent
action 045 puts "$match"
action 050 cli command "conf t"
action 060 cli command "int tun 0"
action 070 if $percent ge "98"
action 080 cli command "delay 50000"
action 090 else
action 100 cli command "delay 100000"
action 110 end
12-13-2020 11:57 AM
Hello,
the two scripts below should work...
event manager environment PING_SUCCESS 98
!
event manager applet PING_UP_EEM
event timer watchdog time 300
action 1.0 cli command "enable"
action 2.0 cli command "1.1.1.2 source 1.1.1.1 repeat 50"
action 2.1 set MATCH regexp_substr
action 3.0 regexp ".*Success rate is [0-9]+.*" $_cli_result _regexp_result regexp_substr
action 4.0 if $MATCH gt $PING_SUCCESS
action 6.0 cli command "conf t"
action 7.0 cli command "interface tunnel 0"
action 8.0 cli command "delay 100000"
action 9.0 cli command "end"
action 9.1 end
!
event manager applet PING_DOWN_EEM
event timer watchdog time 300
action 1.0 cli command "enable"
action 2.0 cli command "1.1.1.2 source 1.1.1.1 repeat 50"
action 2.1 set MATCH regexp_substr
action 3.0 regexp ".*Success rate is [0-9]+.*" $_cli_result _regexp_result regexp_substr
action 4.0 if $MATCH lt $PING_SUCCESS
action 6.0 cli command "conf t"
action 7.0 cli command "interface tunnel 0"
action 8.0 cli command "delay 50000"
action 9.0 cli command "end"
action 9.1 end
12-13-2020 12:37 PM - edited 12-13-2020 12:38 PM
I'll present an example if you wanted to consolidate into a single policy. The maxrun120 is going to be important as the default time to live of EEM is 20 seconds which is not enough in some situations. If the tunnel is down then the ping command will run for 100 seconds (50 ICMP pkts with 2 second timeout). If this happens and you do not update the maxrun timer to something greater than 100 seconds the script will not complete and the delay attribute will not be updated.
event manager applet tunnelHealth
event none maxrun 120
action 010 cli command "enable"
action 020 cli command "ping 8.8.8.8 source gig1 repeat 50"
action 040 regexp "Success rate is ([0-9]+) percent" "$_cli_result" match percent
action 045 puts "$match"
action 050 cli command "conf t"
action 060 cli command "int tun 0"
action 070 if $percent ge "98"
action 080 cli command "delay 50000"
action 090 else
action 100 cli command "delay 100000"
action 110 end
12-13-2020 04:12 PM
You sirs...are diamonds in the rough! Thank you both.
12-14-2020 06:13 AM
I think Daniel's script is a lot better, since it combines both actions in one script...
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide