cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
861
Views
0
Helpful
12
Replies

Nested EEM script error

gwijnants
Level 1
Level 1

Hi all,

I am testing an EEM script that shut / no shut an interface if a track is not UP (name of the script reset-cellular).
The EEM script worked, now I wanted to implement the EEM script into another EEM script (name of the script is test).

Now if it is nested into the test EEM script it does not work anymore? When running the test EEM script i receive following error:

%HA_EM-3-FMPD_UNKNOWN_ENV: fh_parse_var: could not find environment variable: state
%HA_EM-3-FMPD_ERROR: Error executing applet test statement 010

 

event manager environment q "
event manager applet test
 event none
 action 001 cli command "enable"
 action 002 cli command "reload in 15" pattern "confirm"
 action 003 cli command "y"
 action 004 cli command "config t"
 action 005 cli command "event manager applet reset-cellular"
 action 006 cli command "event timer countdown time 300"
 action 007 cli command "action 010 cli command enable"
 action 008 cli command "action 020 cli command $q show track 10 | inc Reachability$q"
 action 009 cli command "action 030 regexp $q Reachability is ([\_A-Za-z0-9]+) $q $q $_cli_result$q match state"
 action 010 cli command "action 040 if $state ne $qUp$q"
 action 011 cli command "action 060 cli command $q config t$q"
 action 012 cli command "action 070 cli command $q interface Ce0/1/0$q"
 action 013 cli command "action 080 cli command $q shut$q"
 action 014 cli command "action 090 cli command $q no shut$q"
 action 015 cli command "action 100 cli command $q no event manager applet reset-cellular$q"
 action 016 cli command "action 110 cli command end"
 action 017 cli command "action 120 else"
 action 018 cli command "action 130 cli command $q config t$q"
 action 019 cli command "action 140 cli command $q no event manager applet reset-cellular$q"
 action 020 cli command "action 150 cli command end"
 action 021 cli command "action 160 end"
 action 022 cli command "end"

If you directly configure the EEM script reset-cellular there are no errors.

no event manager applet reset-cellular
event manager applet reset-cellular
event timer countdown time 300
action 010 cli command enable
action 020 cli command " show track 10 | inc Reachability"
action 030 regexp " Reachability is ([\_A-Za-z0-9]+)" " $_cli_result" match state
action 040 if $state ne "Up"
action 060 cli command " config t"
action 070 cli command " interface Ce0/1/0"
action 080 cli command " shut"
action 090 cli command " no shut"
action 100 cli command " no event manager applet reset-cellular"
action 110 cli command end
action 120 else
action 130 cli command " config t"
action 140 cli command " no event manager applet reset-cellular"
action 150 cli command end
action 160 end

Does anyone know what I am doing wrong?

Kind Regards

1 Accepted Solution

Accepted Solutions

you want to pass $state and not the value stored in $state.  Update the line below to include escape (\ backslash) so that $state is passed and not the value.

 

 action 010 cli command "action 040 if \$state ne Up"

  

View solution in original post

12 Replies 12

marce1000
VIP
VIP

 

              - FYI : https://bst.cloudapps.cisco.com/bugsearch/bug/CSCvg53802

 M.



-- Each morning when I wake up and look into the mirror I always say ' Why am I so brilliant ? '
    When the mirror will then always repond to me with ' The only thing that exceeds your brilliance is your beauty! '

Hi Marce,

Thank you for your response but my variables do not include hyphens.
That is if I am not overlooking something.

Best Regards

 

 - Perhaps the best way to check then , is to open the EEM script with  your favorite editor ; and look for a hyphen (if any) with the search tool(s) provided , 

 M.



-- Each morning when I wake up and look into the mirror I always say ' Why am I so brilliant ? '
    When the mirror will then always repond to me with ' The only thing that exceeds your brilliance is your beauty! '

Hi Marce,

I doublechecked and no hyphens are used in variables in the EEM script.

Best Regards

 

  - What are these then :
      >.... (extract from script below)
      >...look at line  ... reset-cellular

action 005 cli command "event manager applet reset-cellular"


-- Each morning when I wake up and look into the mirror I always say ' Why am I so brilliant ? '
    When the mirror will then always repond to me with ' The only thing that exceeds your brilliance is your beauty! '

Hi Marce,

It is the name of the EEM script not a variable.

Best Regards

 

          - Check what happens if you  omit  the hyphen in the name  , 

 M.



-- Each morning when I wake up and look into the mirror I always say ' Why am I so brilliant ? '
    When the mirror will then always repond to me with ' The only thing that exceeds your brilliance is your beauty! '

Dan Frey
Cisco Employee
Cisco Employee

Error message says it can not read variable state that is created on line 009.   

Why do you want to write/destroy a policy every time it detects a tracked object goes down?   The script could read the tracked object then execute reset-cellular if needed or do nothing if not needed.

Hi Dan,

Because this only needs te be done after a restart and if after the restart the track is still down.

In the test above I have stated Event none but in reality it is event syslog pattern "%SYS-5-RESTART". I just changed it of someone would want to test it. I know its because it can not read the variable on line 009. It is the variable state that it can not read. However if I make the same EEM not nested it does work and it can read the variable. So is this a bug maybe or am I doing something wrong?.

Best Regards

 

         >... So is this a bug maybe ...
  - In such cases it is always to use and or upgrade to the latest advisory software version for your cisco device
     model and check if that can help , 

 M.



-- Each morning when I wake up and look into the mirror I always say ' Why am I so brilliant ? '
    When the mirror will then always repond to me with ' The only thing that exceeds your brilliance is your beauty! '

you want to pass $state and not the value stored in $state.  Update the line below to include escape (\ backslash) so that $state is passed and not the value.

 

 action 010 cli command "action 040 if \$state ne Up"

  

Hi Dan,

Thank you for the solution!

Also a quick note, I had to adapt action 009 in the same way. See code below.

 action 009 cli command "action 030 regexp $q Reachability is ([\_A-Za-z0-9]+) $q $q \$_cli_result$q match state"

 Best Regards!

Review Cisco Networking for a $25 gift card