cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2247
Views
0
Helpful
8
Replies

EEM Script Evaluation

Hello Community,

Can someone please take a look at the script below and tell me why on earth the simple script won't work when I try to run it manually,

event manager applet netflow_toptalk

event none

action 1.0 cli command "enable"

action 2.0 cli command "conf t"

action 3.0 cli command "flow record flowrecord1"

action 4.0 cli command "match ipv4 protocol"

action 5.0 cli command "match ipv4 tos"

action 6.0 cli command "match ipv4 source address"

action 7.0 cli command "match ipv4 destination address"

action 8.0 cli command "match transport source-port"

action 9.0 cli command "match transport destination-port"

action 10.0 cli command "match flow direction"

action 12.0 cli command "match interface input"

action 13.0 cli command "match interface output"

action 14.0 cli command "collect application name"

action 15.0 cli command "collect timestamp sys-uptime first"

action 17.0 cli command "flow monitor flowmonitor1"

action 18.0 cli command "cache timeout active 86520"

action 19.0 cli command "cache entries 32768"

action 20.0 cli command "record FlowRecord1"

action 22.0 cli command "alias exec toptalkers event manager run toptalkers.tcl"

action 22.0 cli command "end"

The is the debug

Sep 24 13:06:35.212:

Sep 24 13:06:35.212: tty is now going through its death sequence

Sep 24 13:06:35.348: %HA_EM-6-LOG: netflow_toptalkers : DEBUG(cli_lib) : : CTL : cli_open called.

Sep 24 13:06:35.356: %HA_EM-6-LOG: netflow_toptalkers : DEBUG(cli_lib) : : OUT : UK01380-Tormarton-1921>

Sep 24 13:06:35.356: %HA_EM-6-LOG: netflow_toptalkers : DEBUG(cli_lib) : : IN  : UK01380-Tormarton-1921>enable

Sep 24 13:06:35.372: %HA_EM-6-LOG: netflow_toptalkers : DEBUG(cli_lib) : : OUT : UK01380-Tormarton-1921#

Sep 24 13:06:35.372: %HA_EM-6-LOG: netflow_toptalkers : DEBUG(cli_lib) : : IN  : UK01380-Tormarton-1921#match flow direction

Sep 24 13:06:35.392: %HA_EM-6-LOG: netflow_toptalkers : DEBUG(cli_lib) : : OUT :                         ^

Sep 24 13:06:35.392: %HA_EM-6-LOG: netflow_toptalkers : DEBUG(cli_lib) : : OUT : % Invalid input detected at '^' marker.

Sep 24 13:06:35.392: %HA_EM-6-LOG: netflow_toptalkers : DEBUG(cli_lib) : : OUT :

Sep 24 13:06:35.392: %HA_EM-6-LOG: netflow_toptalkers : DEBUG(cli_lib) : : OUT : UK01380-Tormarton-1921#

Sep 24 13:06:35.392: %HA_EM-6-LOG: netflow_toptalkers : DEBUG(cli_lib) : : IN  : UK01380-Tormarton-1921#match interface input

Sep 24 13:06:35.516: %HA_EM-6-LOG: netflow_toptalkers : DEBUG(cli_lib) : : OUT :                         ^

Sep 24 13:06:35.516: %HA_EM-6-LOG: netflow_toptalkers : DEBUG(cli_lib) : : OUT : % Invalid input detected at '^' marker.

Sep 24 13:06:35.516: %HA_EM-6-LOG: netflow_toptalkers : DEBUG(cli_lib) : : OUT :

Sep 24 13:06:35.516: %HA_EM-6-LOG: netflow_toptalkers : DEBUG(cli_lib) : : OUT : UK01380-Tormarton-1921#

Sep 24 13:06:35.516: %HA_EM-6-LOG: netflow_toptalkers : DEBUG(cli_lib) : : IN  : UK01380-Tormarton-1921#match interface output

Sep 24 13:06:35.660: %HA_EM-6-LOG: netflow_toptalkers : DEBUG(cli_lib) : : OUT :                         ^

Sep 24 13:06:35.660: %HA_EM-6-LOG: netflow_toptalkers : DEBUG(cli_lib) : : OUT : % Invalid input detected at '^' marker.

Sep 24 13:06:35.660: %HA_EM-6-LOG: netflow_toptalkers : DEBUG(cli_lib) : : OUT :

Sep 24 13:06:35.660: %HA_EM-6-LOG: netflow_toptalkers : DEBUG(cli_lib) : : OUT : UK01380-Tormarton-1921#

Sep 24 13:06:35.660: %HA_EM-6-LOG: netflow_toptalkers : DEBUG(cli_lib) : : IN  : UK01380-Tormarton-1921#collect application name

Sep 24 13:06:35.788: %HA_EM-6-LOG: netflow_toptalkers : DEBUG(cli_lib) : : OUT :                          ^

Sep 24 13:06:35.788: %HA_EM-6-LOG: netflow_toptalkers : DEBUG(cli_lib) : : OUT : % Invalid input detected at '^' marker.

Sep 24 13:06:35.788: %HA_EM-6-LOG: netflow_toptalkers : DEBUG(cli_lib) : : OUT :

Sep 24 13:06:35.788: %HA_EM-6-LOG: netflow_toptalkers : DEBUG(cli_lib) : : OUT : UK01380-Tormarton-1921#

Sep 24 13:06:35.788: %HA_EM-6-LOG: netflow_toptalkers : DEBUG(cli_lib) : : IN  : UK01380-Tormarton-1921#collect timestamp sys-uptime first

Sep 24 13:06:35.908: %HA_EM-6-LOG: netflow_toptalkers : DEBUG(cli_lib) : : OUT :                          ^

Sep 24 13:06:35.908: %HA_EM-6-LOG: netflow_toptalkers : DEBUG(cli_lib) : : OUT : % Invalid input detected at '^' marker.

Sep 24 13:06:35.908: %HA_EM-6-LOG: netflow_toptalkers : DEBUG(cli_lib) : : OUT :

Sep 24 13:06:35.908: %HA_EM-6-LOG: netflow_toptalkers : DEBUG(cli_lib) : : OUT : UK01380-Tormarton-1921#

Sep 24 13:06:35.908: %HA_EM-6-LOG: netflow_toptalkers : DEBUG(cli_lib) : : IN  : UK01380-Tormarton-1921#exit

Sep 24 13:06:36.024: %HA_EM-6-LOG: netflow_toptalkers : DEBUG(cli_lib) : : OUT : UK01380-Tormarton-1921>

Sep 24 13:06:36.024: %HA_EM-6-LOG: netflow_toptalkers : DEBUG(cli_lib) : : IN  : UK01380-Tormarton-1921>flow monitor FlowMonitor1

Sep 24 13:06:36.044: %HA_EM-6-LOG: netflow_toptalkers : DEBUG(cli_lib) : : OUT :                         ^

Sep 24 13:06:36.044: %HA_EM-6-LOG: netflow_toptalkers : DEBUG(cli_lib) : : OUT : % Invalid input detected at '^' marker.

Sep 24 13:06:36.044: %HA_EM-6-LOG: netflow_toptalkers : DEBUG(cli_lib) : : OUT :

Sep 24 13:06:36.044: %HA_EM-6-LOG: netflow_toptalkers : DEBUG(cli_lib) : : OUT : UK01380-Tormarton-1921>

Sep 24 13:06:36.044: %HA_EM-6-LOG: netflow_toptalkers : DEBUG(cli_lib) : : IN  : UK01380-Tormarton-1921>cache timeout active 86520

Sep 24 13:06:36.164: %HA_EM-6-LOG: netflow_toptalkers : DEBUG(cli_lib) : : OUT :                          ^

Sep 24 13:06:36.164: %HA_EM-6-LOG: netflow_toptalkers : DEBUG(cli_lib) : : OUT : % Invalid input detected at '^' marker.

Sep 24 13:06:36.164: %HA_EM-6-LOG: netflow_toptalkers : DEBUG(cli_lib) : : OUT :

Sep 24 13:06:36.164: %HA_EM-6-LOG: netflow_toptalkers : DEBUG(cli_lib) : : OUT : UK01380-Tormarton-1921>

Sep 24 13:06:36.164: %HA_EM-6-LOG: netflow_toptalkers : DEBUG(cli_lib) : : IN  : UK01380-Tormarton-1921>cache entries 32768

Sep 24 13:06:36.284: %HA_EM-6-LOG: netflow_toptalkers : DEBUG(cli_lib) : : OUT :                          ^

Sep 24 13:06:36.284: %HA_EM-6-LOG: netflow_toptalkers : DEBUG(cli_lib) : : OUT : % Invalid input detected at '^' marker.

Sep 24 13:06:36.284: %HA_EM-6-LOG: netflow_toptalkers : DEBUG(cli_lib) : : OUT :

Cheers

Carlton

8 Replies 8

Joe Clarke
Cisco Employee
Cisco Employee

You've fallen into the trap of thinking the action labels are numbers when they are actually strings.  Do a show run, and you'll see the actual order the actions will run.  Action labels are evaluated in lexicographical order, so you'll need to rethink your number strategy so that each action executes in the correct order.  Typically preceeding actions with zeros works:

001

002

003

...

010

...

Thanks Joseph,

I was going crazy!

Hi Joeseph,

Other than the number strategy you provided can you let me know what numbering strategies are commonly used.

I tried the following but it didn't work:

event manager applet netflow_server

event none

action 1.1 cli command "enable"

action 2.1 cli command "conf t"

action 3.1 cli command "flow record FlowRecord1"

action 4.1 cli command "match ipv4 protocol"

action 5.1 cli command "match ipv4 tos"

action 6.1 cli command "match ipv4 source address"

action 7.1 cli command "match ipv4 destination address"

action 8.1 cli command "match transport source-port"

action 9.1 cli command "match transport destination-port"

action 10.1 cli command "match flow direction"

action 12.1 cli command "match interface input"

action 13.1 cli command "match interface output"

action 14.1 cli command "collect application name"

action 15.1 cli command "collect timestamp sys-uptime first"

action 16.1 cli command "exit"

action 17.1 cli command "flow monitor FlowMonitor1"

action 18.1 cli command "cache timeout active 86520"

action 19.1 cli command "cache entries 32768"

action 20.1 cli command "record FlowRecord1"

action 21.1 cli command "event manager run netflow_server"

Kind regards

As I said you need to normalize your numbering by, for example, preceeding each with leading zeros.

001

002

...

010

...

020

Joseph,

I get it - I'm being a numbty today. However, can you tell me why the following line of the script doesn't work:

if [catch {cli_exec $cli1(fd) "event manager run talkerstop.tcl"} _cli_result] {

    error $_cli_result $errorInfo

}

Basically, I would like the script to automatically be run at the end.

#

# This EEM tcl policy was generated by the EEM applet conversion

# utility at http://www.marcuscom.com/convert_applet/

# using the following applet:

#

# event manager applet toptalkers

# event none

# action 1.1 cli command "enable"

# action 1.2 cli command "conf t"

# action 1.3 cli command "flow record FlowRecord1"

# action 1.4 cli command "match ipv4 protocol"

# action 1.5 cli command "match ipv4 tos"

# action 1.6 cli command "match ipv4 source address"

# action 1.7 cli command "match ipv4 destination address"

# action 1.8 cli command "match transport source-port"

# action 1.9 cli command "match transport destination-port"

# action 2.1 cli command "match flow direction"

# action 2.2 cli command "match interface input"

# action 2.3 cli command "match interface output"

# action 2.4 cli command "collect application name"

# action 2.5 cli command "collect timestamp sys-uptime first"

# action 2.6 cli command "exit"

# action 2.7 cli command "flow monitor FlowMonitor1"

# action 2.8 cli command "cache timeout active 86520"

# action 2.9 cli command "cache entries 32768"

# action 3.1 cli command "record FlowRecord1"

# action 3.2 cli command "event manager run talkerstop.tcl"

#

namespace import ::cisco::eem::*

namespace import ::cisco::lib::*

array set arr_einfo [event_reqinfo]

if [catch {cli_open} result] {

    error $result $errorInfo

} else {

    array set cli1 $result

}

if [catch {cli_exec $cli1(fd) "enable"} _cli_result] {

    error $_cli_result $errorInfo

}

if [catch {cli_exec $cli1(fd) "conf t"} _cli_result] {

    error $_cli_result $errorInfo

}

if [catch {cli_exec $cli1(fd) "flow record FlowRecord1"} _cli_result] {

    error $_cli_result $errorInfo

}

if [catch {cli_exec $cli1(fd) "match ipv4 protocol"} _cli_result] {

    error $_cli_result $errorInfo

}

if [catch {cli_exec $cli1(fd) "match ipv4 tos"} _cli_result] {

    error $_cli_result $errorInfo

}

if [catch {cli_exec $cli1(fd) "match ipv4 source address"} _cli_result] {

    error $_cli_result $errorInfo

}

if [catch {cli_exec $cli1(fd) "match ipv4 destination address"} _cli_result] {

    error $_cli_result $errorInfo

}        

if [catch {cli_exec $cli1(fd) "match transport source-port"} _cli_result] {

    error $_cli_result $errorInfo

}

if [catch {cli_exec $cli1(fd) "match transport destination-port"} _cli_result] {

    error $_cli_result $errorInfo

}

if [catch {cli_exec $cli1(fd) "match flow direction"} _cli_result] {

    error $_cli_result $errorInfo

}

if [catch {cli_exec $cli1(fd) "match interface input"} _cli_result] {

    error $_cli_result $errorInfo

}

if [catch {cli_exec $cli1(fd) "match interface output"} _cli_result] {

    error $_cli_result $errorInfo

}

if [catch {cli_exec $cli1(fd) "collect application name"} _cli_result] {

    error $_cli_result $errorInfo

}

if [catch {cli_exec $cli1(fd) "collect timestamp sys-uptime first"} _cli_result] {

    error $_cli_result $errorInfo

}

if [catch {cli_exec $cli1(fd) "exit"} _cli_result] {

    error $_cli_result $errorInfo

}

if [catch {cli_exec $cli1(fd) "flow monitor FlowMonitor1"} _cli_result] {

    error $_cli_result $errorInfo

}

if [catch {cli_exec $cli1(fd) "cache timeout active 86520"} _cli_result] {

    error $_cli_result $errorInfo

}

if [catch {cli_exec $cli1(fd) "cache entries 32768"} _cli_result] {

    error $_cli_result $errorInfo

}

if [catch {cli_exec $cli1(fd) "record FlowRecord1"} _cli_result] {

    error $_cli_result $errorInfo

}

if [catch {cli_exec $cli1(fd) "event manager run talkerstop.tcl"} _cli_result] {

    error $_cli_result $errorInfo

}

# Close open cli before exit.

catch {cli_close $cli1(fd) $cli1(tty_id)} result

Cheers

Because you're still in config mode when you run this command.  You need to exit from config mode first.

Joseph,

I made the change as you suggested, however I still can only get the script to run by manually running

event manager run toptalkers.tcl.

::cisco::eem::event_register_none

#

# This EEM tcl policy was generated by the EEM applet conversion

# utility at http://www.marcuscom.com/convert_applet/

# using the following applet:

#

# event manager applet toptalkers

# event none

# action 1.1 cli command "enable"

# action 1.2 cli command "conf t"

# action 1.3 cli command "flow record FlowRecord1"

# action 1.4 cli command "match ipv4 protocol"

# action 1.5 cli command "match ipv4 tos"

# action 1.6 cli command "match ipv4 source address"

# action 1.7 cli command "match ipv4 destination address"

# action 1.8 cli command "match transport source-port"

# action 1.9 cli command "match transport destination-port"

# action 2.1 cli command "match flow direction"

# action 2.2 cli command "match interface input"

# action 2.3 cli command "match interface output"

# action 2.4 cli command "collect application name"

# action 2.5 cli command "collect timestamp sys-uptime first"

# action 2.6 cli command "exit"

# action 2.7 cli command "flow monitor FlowMonitor1"

# action 2.8 cli command "cache timeout active 86520"

# action 2.9 cli command "cache entries 32768"

# action 3.1 cli command "record FlowRecord1"

# action 3.2 cli command "end"

# action 3.3 cli command "event manager run toptalkers.tcl"

#

namespace import ::cisco::eem::*

namespace import ::cisco::lib::*

array set arr_einfo [event_reqinfo]

if [catch {cli_open} result] {

    error $result $errorInfo

} else {

    array set cli1 $result

}

if [catch {cli_exec $cli1(fd) "enable"} _cli_result] {

    error $_cli_result $errorInfo

}

if [catch {cli_exec $cli1(fd) "conf t"} _cli_result] {

    error $_cli_result $errorInfo

}

if [catch {cli_exec $cli1(fd) "flow record FlowRecord1"} _cli_result] {

    error $_cli_result $errorInfo

}

if [catch {cli_exec $cli1(fd) "Description Flow Record to Determine Top Talkers Attached to

FlowMonitor1"} _cli_result] {

    error $_cli_result $errorInfo

}

if [catch {cli_exec $cli1(fd) "match ipv4 protocol"} _cli_result] {

    error $_cli_result $errorInfo

}

if [catch {cli_exec $cli1(fd) "match ipv4 tos"} _cli_result] {

    error $_cli_result $errorInfo

}

if [catch {cli_exec $cli1(fd) "match ipv4 source address"} _cli_result] {

    error $_cli_result $errorInfo

}

if [catch {cli_exec $cli1(fd) "match ipv4 destination address"} _cli_result] {

    error $_cli_result $errorInfo

}

if [catch {cli_exec $cli1(fd) "match transport source-port"} _cli_result] {

    error $_cli_result $errorInfo

}

if [catch {cli_exec $cli1(fd) "match transport destination-port"} _cli_result] {

    error $_cli_result $errorInfo

}

if [catch {cli_exec $cli1(fd) "match flow direction"} _cli_result] {

    error $_cli_result $errorInfo

}

if [catch {cli_exec $cli1(fd) "match interface input"} _cli_result] {

    error $_cli_result $errorInfo

}

if [catch {cli_exec $cli1(fd) "match interface output"} _cli_result] {

    error $_cli_result $errorInfo

}

if [catch {cli_exec $cli1(fd) "collect application name"} _cli_result] {

    error $_cli_result $errorInfo

}

if [catch {cli_exec $cli1(fd) "collect timestamp sys-uptime first"} _cli_result] {

    error $_cli_result $errorInfo

}

if [catch {cli_exec $cli1(fd) "exit"} _cli_result] {

    error $_cli_result $errorInfo

}

if [catch {cli_exec $cli1(fd) "flow monitor FlowMonitor1"} _cli_result] {

    error $_cli_result $errorInfo

}

if [catch {cli_exec $cli1(fd) "cache timeout active 86520"} _cli_result] {

    error $_cli_result $errorInfo

}

if [catch {cli_exec $cli1(fd) "cache entries 32768"} _cli_result] {

    error $_cli_result $errorInfo

}

if [catch {cli_exec $cli1(fd) "record FlowRecord1"} _cli_result] {

    error $_cli_result $errorInfo

}

if [catch {cli_exec $cli1(fd) "end"} _cli_result] {

    error $_cli_result $errorInfo

}

if [catch {cli_exec $cli1(fd) "event manager run toptalkers.tcl"} _cli_result] {

    error $_cli_result $errorInfo

}

# Close open cli before exit.

catch {cli_close $cli1(fd) $cli1(tty_id)} result

Any help will be greatly appreciated.

You didn't have it written this way before.  But no that I see what you're trying to do, it will not work.  You cannot have the script call itself like this.  That will be an infinite loop.  Why do you want to do this?

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: