06-14-2019 12:01 AM
I have two EEM running on one device (see below) I really do not want it to repeat the no shut command every 180 seconds. Is there a way to have it detect the current configuration before changing it?
For example using "TEST_BPS_IN" this test to see if the receive rate is below 3000 bits/sec then it shuts an interface....once its is shut I do not want it sending the shut command again every 180 seconds if the data remains below 3000 bits/sec.
event manager applet TEST_BPS_IN
event tag 1 interface name GigabitEthernet0/0/0 parameter receive_rate_bps entry-op lt entry-val 3000 entry-type value poll-interval 180
action 1.0 cli command "enable"
action 2.0 cli command "config t"
action 3.0 cli command "interface g0/0/0"
action 4.0 cli command "shut"
action 5.0 syslog msg "Interface g0/0/0 was shut via EEM"
event manager applet TEST_BPS_OVER
event tag 1 interface name GigabitEthernet0/0/0 parameter receive_rate_bps entry-op gt entry-val 10000 entry-type value poll-interval 180
action 1.0 cli command "enable"
action 2.0 cli command "config t"
action 3.0 cli command "interface g0/0/0"
action 4.0 cli command "no shut"
action 5.0 syslog msg "Interface g0/0/0 was no shut via EEM"
Solved! Go to Solution.
09-20-2019 05:13 AM
Hello again,
You need to tell the script where the if condition end:
event manager applet BPS_UNDER event tag 1 interface name GigabitEthernet0/0/0 parameter receive_rate_bps entry-op lt entry-val 999999 entry-type value poll-interval 120 action 0.1 cli command "show run in gi0/0/0" action 0.2 regexp "(no shutdown)" "$_cli_result" value action 0.3 if $_regexp_result eq "0" action 1.0 cli command "enable" action 2.0 cli command "config t" action 3.0 cli command "interface g0/0/0" action 4.0 cli command "shut" action 5.0 syslog msg "Interface g0/0/0 was shut via EEM" action 6.0 end
cheers,
Seb.
06-14-2019 12:49 AM
Hi there,
How about regex'ing the config of the interface for the presence of 'no shutdown'. If it not present then shut it down. Something like this:
action 0.1 cli command "show run in gi0/0/0" action 0.2 regexp "(no shutdown)" "$_cli_result" value action 0.3 if $_regexp_result eq "0" action 1.0 cli command "enable" action 2.0 cli command "config t" action 3.0 cli command "interface g0/0/0" action 4.0 cli command "shut" action 5.0 syslog msg "Interface g0/0/0 was shut via EEM"
cheers,
Seb.
09-20-2019 04:15 AM
Seb,
Thanks for the info. I am using this as a test:
event manager applet BPS_UNDER
event tag 1 interface name GigabitEthernet0/0/0 parameter receive_rate_bps entry-op lt entry-val 999999 entry-type value poll-interval 120
action 0.1 cli command "show run in gi0/0/0"
action 0.2 regexp "(no shutown)" "$_cli_result" value
action 0.3 if $_regexp_result eq "0"
action 5.0 syslog msg "EEM SHUT G0/0/1"
I get the following err
BPS_UNDER: Missing "end" action in conditional block
Can you explain this?
Once I get this working I will use the following config:
event manager applet BPS_UNDER
event tag 1 interface name GigabitEthernet0/0/0 parameter receive_rate_bps entry-op lt entry-val 999999 entry-type value poll-interval 120
action 0.1 cli command "show run in gi0/0/0"
action 0.2 regexp "(no shutdown)" "$_cli_result" value
action 0.3 if $_regexp_result eq "0"
action 1.0 cli command "enable"
action 2.0 cli command "config t"
action 3.0 cli command "interface g0/0/0"
action 4.0 cli command "shut"
action 5.0 syslog msg "Interface g0/0/0 was shut via EEM"
How does that look?
09-20-2019 05:13 AM
Hello again,
You need to tell the script where the if condition end:
event manager applet BPS_UNDER event tag 1 interface name GigabitEthernet0/0/0 parameter receive_rate_bps entry-op lt entry-val 999999 entry-type value poll-interval 120 action 0.1 cli command "show run in gi0/0/0" action 0.2 regexp "(no shutdown)" "$_cli_result" value action 0.3 if $_regexp_result eq "0" action 1.0 cli command "enable" action 2.0 cli command "config t" action 3.0 cli command "interface g0/0/0" action 4.0 cli command "shut" action 5.0 syslog msg "Interface g0/0/0 was shut via EEM" action 6.0 end
cheers,
Seb.
09-20-2019 04:26 AM
Hello
Try removing the poll-interval
event tag 1 interface name GigabitEthernet0/0/0 parameter receive_rate_bps entry-op lt entry-val 3000 entry-type value poll-interval 180event tag 1 interface name GigabitEthernet0/0/0 parameter receive_rate_bps entry-op gt entry-val 10000 entry-type value poll-interval 180
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