07-19-2024 03:32 AM
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
Solved! Go to Solution.
07-22-2024 08:02 AM
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"
07-19-2024 03:51 AM
- FYI : https://bst.cloudapps.cisco.com/bugsearch/bug/CSCvg53802
M.
07-19-2024 04:23 AM
Hi Marce,
Thank you for your response but my variables do not include hyphens.
That is if I am not overlooking something.
Best Regards
07-19-2024 04:34 AM
- 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.
07-19-2024 04:58 AM
Hi Marce,
I doublechecked and no hyphens are used in variables in the EEM script.
Best Regards
07-19-2024 05:07 AM
- What are these then :
>.... (extract from script below)
>...look at line ... reset-cellular
action 005 cli command "event manager applet reset-cellular"
07-19-2024 06:00 AM
Hi Marce,
It is the name of the EEM script not a variable.
Best Regards
07-19-2024 06:06 AM
- Check what happens if you omit the hyphen in the name ,
M.
07-19-2024 06:34 AM
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.
07-22-2024 01:36 AM
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
07-22-2024 01:40 AM
>... 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.
07-22-2024 08:02 AM
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"
07-24-2024 12:44 AM
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!
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