08-08-2020 05:37 AM - edited 08-08-2020 05:49 AM
Hello ,
I need to create a EEM script that check a ping results .
If ping are working or not and then to continue the script by this result .
thanks !
event manager applet ping
event syslog pattern " %DIALER-6-UNBIND: Interface Vi2 unbound from profile Di0" period 1
action 1.0 cli command "enable"
action 2.0 cli command "config terminal"
action 3.0 cli command " interface dia0"
action 4.0 cli command "ppp pap sent-username ron@x password 1"
action 5.0 cli command "shutdown"
action 6.0 cli command "no shutdown"
action 7.0 cli command "event timer countdown time 30"
action 8.0 cli command "do ping 8.8.8.8"
!
end
08-08-2020 06:30 AM
Hi,
You may refer to the below syntax:
event manager applet ping event syslog pattern " %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback1, changed state to down" period 1 action 1.0 cli command "enable" action 2.0 cli command "conf t" action 3.0 cli command "do ping 8.8.8.8" action 4.0 regexp "100 percent" "$_cli_result" action 5.0 if $_regexp_result eq "1" action 5.1 syslog priority debugging msg "Ping success" action 5.2 end action 6.0 if $_regexp_result eq "0" action 6.1 syslog priority debugging msg "Ping fail" action 6.2 end
debug:
*Aug 8 13:28:35.715: %LINK-5-CHANGED: Interface Loopback1, changed state to administratively down
*Aug 8 13:28:36.723: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback1, changed state to down
*Aug 8 13:28:36.723: %HA_EM-6-LOG: ping : DEBUG(cli_lib) : : CTL : cli_open called.
*Aug 8 13:28:36.723: %HA_EM-6-LOG: ping : DEBUG(cli_lib) : : OUT : IOU1>
*Aug 8 13:28:36.723: %HA_EM-6-LOG: ping : DEBUG(cli_lib) : : IN : IOU1>enable
*Aug 8 13:28:36.844: %HA_EM-6-LOG: ping : DEBUG(cli_lib) : : OUT : IOU1#
*Aug 8 13:28:36.844: %HA_EM-6-LOG: ping : DEBUG(cli_lib) : : IN : IOU1#conf t
*Aug 8 13:28:36.967: %HA_EM-6-LOG: ping : DEBUG(cli_lib) : : OUT : Enter configuration commands, one per line. End with CNTL/Z.
*Aug 8 13:28:36.967: %HA_EM-6-LOG: ping : DEBUG(cli_lib) : : OUT : IOU1(config)#
*Aug 8 13:28:36.967: %HA_EM-6-LOG: ping : DEBUG(cli_lib) : : IN : IOU1(config)#do ping 8.8.8.8
*Aug 8 13:28:37.090: %HA_EM-6-LOG: ping : DEBUG(cli_lib) : : OUT : Type escape sequence to abort.
*Aug 8 13:28:37.090:
IOU1(config-if)#%HA_EM-6-LOG: ping : DEBUG(cli_lib) : : OUT : Sending 5, 100-byte ICMP Echos to 8.8.8.8, timeout is 2 seconds:
*Aug 8 13:28:37.090: %HA_EM-6-LOG: ping : DEBUG(cli_lib) : : OUT : !!!!!
*Aug 8 13:28:37.090: %HA_EM-6-LOG: ping : DEBUG(cli_lib) : : OUT : Success rate is 100 percent (5/5), round-trip min/avg/max = 5/5/5 ms
*Aug 8 13:28:37.090: %HA_EM-6-LOG: ping : DEBUG(cli_lib) : : OUT : IOU1(config)#
*Aug 8 13:28:37.090: %HA_EM-7-LOG: ping: Ping success
*Aug 8 13:28:37.090: %HA_EM-6-LOG: ping : DEBUG(cli_lib) : : CTL : cli_close called.
08-09-2020 08:45 AM
Hey @ronsametcohen :)
@ngkin2010already posted a script showing exactly what do to, thanks!
The key info on this:
You can log custom Syslog messages with EEM, just like shown in the script by @ngkin2010 .
Then, just create another EEM Script that reacts on your custom Syslogs!
Let me know what you think and if you need help with that.
Best regards
Juls
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