cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1308
Views
0
Helpful
2
Replies

EEM to Tcl

jmcgill298
Level 1
Level 1

I tried using the EEM to Tcl website, but I don't understand the output; can someone help?

 

# 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 cpu_stats
#    event snmp oid "1.3.6.1.4.1.9.9.109.1.1.1.1.3.1 "get-type exact entry-op ge 
#    entry-val "90" exit-op le exit-val "70" poll-interval 5
#    action 1.0 cli command "enable"
#    action 1.1 cli command "show process cpu sorted | append bootflash:cpu-stats"
#    action 1.2 cli command "show stack 503 | append bootflash:cpu-stats"
#    action 1.3 syslog msg "CPU Utilization spiked above 90%"
#

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) "show process cpu sorted | append bootflash:cpu-stats"} _cli_result] {
    error $_cli_result $errorInfo
}

if [catch {cli_exec $cli1(fd) "show stack 503 | append bootflash:cpu-stats"} _cli_result] {
    error $_cli_result $errorInfo
}

action_syslog msg "CPU Utilization spiked above 90%"

# Close open cli before exit.
catch {cli_close $cli1(fd) $cli1(tty_id)} result

I don't really know much about scripting, nor does this really seem to give me a place to start. I don't understand the first line at all; I expected to see something starting with tclsh.

2 Replies 2

Joe Clarke
Cisco Employee
Cisco Employee

This tool converts an EEM applet to an EEM Tcl policy.  The first line (not shown here) is the event registration line.  This EEM Tcl script needs to be registered with the EEM server by following the instructions at http://www.cisco.com/c/en/us/td/docs/ios/netmgmt/configuration/guide/12_2sx/nm_12_2sx_book/nm_eem_policy_tcl.html#wp1174855 .  Note: this is not a tclsh script.  It will not work with the IOS Tcl shell.

 

Beyond that, this is pure Tcl 8.3 code with a few EEM procedures.  So if you know Tcl, you can insert your own logic anywhere in the script below the namespace imports.

Thanks for responding Joseph, I believe this raises more questions for me than it answers. I think there is too much prerequisite work for me to do to make this worth while; I will pursue other options. 

Review Cisco Networking for a $25 gift card