cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
491
Views
0
Helpful
5
Replies

EEM Scripting to shut down port when tracking show 2 uplinks are down

l.l
Level 1
Level 1

Hello,

I have setup 2 Track objects using "Track statements", if I run "show track 1 (or2) | include Track1|Line protocol", it will return the following:

Track 1

   Line protocol is Down ((hw down))

Track 2

  Line protocol is Down ((hw down))

I have testing my EEM script below, but

event manager applet test_down

event none (for manual test), will change to "event timer watchdog time 60" if script runs correctly

action 1.0 cli command "enable"

action 1.1 cli command "show track 1 | include Track1|Line protocol"

action 1.2 regexp "{^(Track \\d+|Line protocol is up|Line protocol is Down)}" "$_cli_result" match line1_state

action 1.3 show track 2 | include Track1|Line protocol"

action 1.4 regexp "{^(Track \\d+|Line protocol is up|Line protocol is Down)}" "$_cli_result" match line2_state

action 2.0 if $line1_state eq "Line protocol is Down"

action 2.1   if $line2_state eq "Line protocol is Down"

action 2.2 end

action 2.3 end

action 3 cli command "enable"

action 3.1 cli command "configure terminal"

action 3.2 cli command "interface range Gi1/0/11 -15 , Gi1/0/23"

action 3.3 cli command "shutdown"

action 3.4 cli command "end"

action 3.5 cli command "write memory"

After I pull two uplinks cables out and run the script manually, I got from message that shows: %HA_EM-3FMPD_UNKNOWN_ENV: fh_parse_var: could not find environment variable: line1_state

I am wondering why line1_state not set, and also using "if" and "&&" statement returns with syntax error.  My Cat-9300 is running on Cisco IOS-XE ver.17.6.1r[FC2]

Appreciate for your help.  Thank you. 

 

 

5 Replies 5

Hello,

the syntax does not look right. Post the full running config of your Cat9300...

Sorry, I am unable to post the full running config due to company policy.

Thank you.

friend why you make it complex 
use 
event track status UP/DOWN 

then action shut/no shut port 
MHM

Unfortunately, "event track" is not available in IOS-XE ver.17.6.1r[FC2], older version does support "event track" function.

Thank you.

balaji.bandi
Hall of Fame
Hall of Fame

what we are asking not full config (i guess in the past poster) - we would like to see how your SLA track configured and what results expected.

by your post what we understand, you like to shutdown the range of interface if both Track results down ? or you looking and or operation ?

if you looking Track 1 and Track2 down - then you need to use another track3 to monitor track1 and track 2 with Boolean

 

track 1 ip sla 1 reachability
track 2 ip sla 2 reachability
track 3 list boolean and
object 1
object 2
delay down 60
exit
!
ip sla 1
icmp-echo 10.10.20.1 source-interface Ethernet0/1
frequency 10
exit
ip sla schedule 1 life forever start-time now
!
ip sla 2
icmp-echo 10.10.30.1 source-interface Ethernet0/0
frequency 10
exit
ip sla schedule 2 life forever start-time now
!

event manager applet test_down
event syslog pattern "%TRACK-6-STATE: 3 list boolean and Up -> Down"
action 1 cli command "enable"
action 2 cli command "configure terminal"
action 3 cli command "interface range Et0/2-3"
action 4 cli command "shutdown"
action 5 cli command "end"
action 8 cli command "write memory"

 

The script only shutdown the ports - you need to bring up range interface based on the output expected to bring up

i am sure IOS-XE ver.17.6.1r should work if not report back to tweak as expected.

 

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

Review Cisco Networking for a $25 gift card