cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
4666
Views
5
Helpful
4
Replies

Stop Script running EEM over and over

Wan_Whisperer
Level 1
Level 1

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"

 

 

 

 

1 Accepted Solution

Accepted Solutions

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.

View solution in original post

4 Replies 4

Seb Rupik
VIP Alumni
VIP Alumni

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.

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?

 

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.

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 180

event tag 1 interface name GigabitEthernet0/0/0 parameter receive_rate_bps entry-op gt entry-val 10000 entry-type value poll-interval 180


Please rate and mark as an accepted solution if you have found any of the information provided useful.
This then could assist others on these forums to find a valuable answer and broadens the community’s global network.

Kind Regards
Paul

Review Cisco Networking for a $25 gift card