cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
494
Views
0
Helpful
3
Replies

EEM Script Not Functioning as Anticipated

amason23
Level 1
Level 1

I have the following script, 

I keep getting the message " %HA_EM-6-FMPD_EEM_CONFIG: check_vlan_traffic: "end" action found outside of conditional block"

but I cant find any offending "end" statements. I am trying to understand what I am conceptually missing here.

  • Opening of foreach loop: Action 7.0
  • Closing of foreach loop: Action 20.0
  • Opening of if block: Action 14.0
  • Closing of if block: Action 20.0 (this end statement corresponds to the end of the foreach loop, but it also closes the if block)
  • Opening of if block: Action 15.0
  • Closing of if block: Action 16.0



event manager applet check_vlan_traffic
event timer watchdog time 60 maxrun 60
action 0.0 cli command "enable"
action 1.0 set vlans ""
action 2.0 cli command "show interfaces status | include Vl"
action 3.0 regexp "Vl([0-9]+)" "$_cli_result" vlan_number
action 4.0 set vlans "$vlans $vlan_number"
action 6.0 set test_count "0"
action 7.0 foreach vlan_number "in" "$vlans"
action 8.0 cli command "show interface Vlan $vlan_number | include rate"
action 9.0 regexp "([0-9]+) bps" "$_cli_result" input_rate output_rate
action 10.0 end
action 11.0 set total_rate "$((input_rate + output_rate) / 2000000)"
action 12.0 set test_count "$test_count + 1"
action 13.0 set total_traffic "$total_traffic + $total_rate"
action 14.0 if $test_count eq "3"
action 14.0 set avg_traffic "$total_traffic / 3"
action 15.0 if $avg_traffic le "5"
action 16.0 syslog msg "VLAN $vlan_number is probably not being used anymore. Average traffic: $avg_traffic Mbps."
action 18.0 set test_count "0"
action 19.0 set total_traffic "0"
action 20.0 end
action 21.0 end


Any assistance is appreciated.

3 Replies 3

action 10.0 end <<- I think message mention this end 

removing action 10 results in same issue

balaji.bandi
Hall of Fame
Hall of Fame

before i comment on your script, can I know the goal of this EEM ? tell us what device model and IOS Code running.

have you executed this show command - show interfaces status | include Vl <---- what output did you get?

BB

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

How to Ask The Cisco Community for Help

Review Cisco Networking for a $25 gift card