cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Announcements

Community Helping Community

500
Views
5
Helpful
4
Replies
Beginner

Stop Script running EEM over and over

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
VIP Advisor

Re: Stop Script running EEM over and over

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
Highlighted
VIP Advisor

Re: Stop Script running EEM over and over

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.

Everyone's tags (1)
Beginner

Re: Stop Script running EEM over and over

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?

 

VIP Advisor

Re: Stop Script running EEM over and over

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

VIP Advisor

Re: Stop Script running EEM over and over

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



kind regards
Paul

Please rate and mark posts accordingly if you have found any of the information provided useful.
It will hopefully assist others with similar issues in the future
CreatePlease to create content
Content for Community-Ad
July's Community Spotlight Awards