cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2912
Views
0
Helpful
2
Replies

EEM not running

pabloayala
Level 1
Level 1

I configured an EEM and I'm not sure why is not running, here's my template:

 

event manager applet ctsmanual_remove authorization bypass
 event none
 action 010 cli command "enable"
 action 015 cli command "show cts interface summary | in MANUAL"
 action 020 set intfs ""
 action 025 foreach line "$_cli_result" "\n"
 action 030  regexp "^([A-Z][a-z0-9/]+)[[:space:]]+MANUAL" "$line" match intf
 action 035  if $_regexp_result eq "1"
 action 040   append intfs "$intf "
 action 045  end
 action 050 end
 action 055 foreach intf "$intfs"
 action 060  puts "Interface is $intf"
 action 065 end
 action 070 cli command "conf t" pattern "CNTL/Z."
 action 075 cli command "interface $intf"
 action 080 cli command "no cts manual"
 action 085 cli command "shut"
 action 090 cli command "no shut"
 action 095 cli command "end"
 action 100 end

 

When I do event manager run ctsmanual_remove I don't see anything from the debugs (debug event manager action cli). I have multiple EEMs configured and some TCLs, everything is running as expected but this one that I just configured. Also, I would like to know if my logic is correct, basically I need the output from intfs to remove cts manual from the port or ports (depending if there's multiple interfaces).

 

I need to make this script bulletproof because I'm configuring devices remotely and I if I apply the cts command and something happens then I'll lose the connection to the switch and someone should console, there are a lot of devices that a local resource should drive 1 hour or more to console.

 

Thanks

1 Accepted Solution

Accepted Solutions

brselzer
Cisco Employee
Cisco Employee

Hello,

 

I think you have too many "ends":

 

event manager applet ctsmanual_remove authorization bypass
 event none
 action 010 cli command "enable"
 action 015 cli command "show cts interface summary | in MANUAL"
 action 020 set intfs ""
 action 025 foreach line "$_cli_result" "\n"
 action 030  regexp "^([A-Z][a-z0-9/]+)[[:space:]]+MANUAL" "$line" match intf
 action 035  if $_regexp_result eq "1"
 action 040   append intfs "$intf "
 action 045  end
 action 050 end
 action 055 foreach intf "$intfs"
 action 060  puts "Interface is $intf"
 action 065 end   <-----I don't think you want this one because for each interface you want to remove CTS. If you end the loop here, you will stop the loop before it runs the commands below
 action 070 cli command "conf t" pattern "CNTL/Z."
 action 075 cli command "interface $intf"
 action 080 cli command "no cts manual"
 action 085 cli command "shut"
 action 090 cli command "no shut"
 action 095 cli command "end"
 action 100 end

 

When I try to run this script I get the error:

 

*Feb 22 02:06:41.408: %HA_EM-6-FMPD_EEM_CONFIG: ctsmanual_remove: "end" action found outside of conditional block

 

I removed the action I pointed out above and the EEM ran. Other than that, the logic is fine. However, I didn't double check your regex as I didn't have the output from that command handy.

 

Hope that helps!

-Bradley Selzer
CCIE# 60833

View solution in original post

2 Replies 2

brselzer
Cisco Employee
Cisco Employee

Hello,

 

I think you have too many "ends":

 

event manager applet ctsmanual_remove authorization bypass
 event none
 action 010 cli command "enable"
 action 015 cli command "show cts interface summary | in MANUAL"
 action 020 set intfs ""
 action 025 foreach line "$_cli_result" "\n"
 action 030  regexp "^([A-Z][a-z0-9/]+)[[:space:]]+MANUAL" "$line" match intf
 action 035  if $_regexp_result eq "1"
 action 040   append intfs "$intf "
 action 045  end
 action 050 end
 action 055 foreach intf "$intfs"
 action 060  puts "Interface is $intf"
 action 065 end   <-----I don't think you want this one because for each interface you want to remove CTS. If you end the loop here, you will stop the loop before it runs the commands below
 action 070 cli command "conf t" pattern "CNTL/Z."
 action 075 cli command "interface $intf"
 action 080 cli command "no cts manual"
 action 085 cli command "shut"
 action 090 cli command "no shut"
 action 095 cli command "end"
 action 100 end

 

When I try to run this script I get the error:

 

*Feb 22 02:06:41.408: %HA_EM-6-FMPD_EEM_CONFIG: ctsmanual_remove: "end" action found outside of conditional block

 

I removed the action I pointed out above and the EEM ran. Other than that, the logic is fine. However, I didn't double check your regex as I didn't have the output from that command handy.

 

Hope that helps!

-Bradley Selzer
CCIE# 60833

Yep, you were right. Thanks a lot I really appreciate it your help.

 

Regards

Review Cisco Networking for a $25 gift card