cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1356
Views
0
Helpful
9
Replies

EEM Script (TCL) to run 3 times in a day

Deben Bhattarai
Level 1
Level 1

HI All,

Need your kind help..

I am just new to EEM. I want run a script through which router automatically sends formated outputs thrice in a day ( 00:00 hrs,08:00 hrs and 16:00 hrs)

Can anyone help me out how to register the script so that i will get desred output.

i just modified the script downloaded from cisco [PFA]

after running the script mannually am getting the below log on console

*Mar 13 05:05:00.259: %HA_EM-6-LOG: cpu-test.tcl: no such file or directory
*Mar 13 05:05:00.259: %HA_EM-6-LOG: cpu-test.tcl:     invoked from within
*Mar 13 05:05:00.259: %HA_EM-6-LOG: cpu-test.tcl: "source [file join $dir tclIndex]"
*Mar 13 05:05:00.259: %HA_EM-6-LOG: cpu-test.tcl:     invoked from within
*Mar 13 05:05:00.259: %HA_EM-6-LOG: cpu-test.tcl: "$slave eval $Contents"
*Mar 13 05:05:00.259: %HA_EM-6-LOG: cpu-test.tcl:     (procedure "eval_script" line 7)
*Mar 13 05:05:00.259: %HA_EM-6-LOG: cpu-test.tcl:     invoked from within
*Mar 13 05:05:00.259: %HA_EM-6-LOG: cpu-test.tcl: "eval_script slave $scriptname"
*Mar 13 05:05:00.259: %HA_EM-6-LOG: cpu-test.tcl:     invoked from within
*Mar 13 05:05:00.259: %HA_EM-6-LOG: cpu-test.tcl: "if {$security_level == 1} {       #untrusted script
*Mar 13 05:05:00.259: %HA_EM-6-LOG: cpu-test.tcl:      interp create -safe slave
*Mar 13 05:05:00.259: %HA_EM-6-LOG: cpu-test.tcl:      interp share {} stdin slave
*Mar 13 05:05:00.259: %HA_EM-6-LOG: cpu-test.tcl:      interp share {} stdout slave
*Mar 13 05:05:00.259: %HA_EM-6-LOG: cpu-test.tcl: ..."
*Mar 13 05:05:00.259: %HA_EM-6-LOG: cpu-test.tcl:     (file "tmpsys:/lib/tcl/base.tcl" line 50)
*Mar 13 05:05:00.259: %HA_EM-6-LOG: cpu-test.tcl: Tcl policy execute failed: EEM Policy Error: Variable Execution-time has not been defined

1 Accepted Solution

Accepted Solutions

It appears you've modified the code since I sent it to you last.  The error you're seeing is not possible with the version I sent you.  What happens when you try the version I sent?

View solution in original post

9 Replies 9

Joe Clarke
Cisco Employee
Cisco Employee

This version should do what you want.

HI Joseph,

I want to enable in 4506 switches running  cat4500e-entservicesk9-mz.122-53.SG3.bin IOS

EEM Version is 2.40

XXXXXXXXXXXX#sh event manager version
Embedded Event Manager Version 2.40
Component Versions:
eem: (v240_throttle)2.21.112
eem-gold: (v240_throttle)1.2.37
eem-call-home: (v240_throttle)2.0.1
Event Detectors:
Name                Version   Node        Type
appl                01.00     node1/0     RP
syslog              01.00     node1/0     RP
rf                  01.00     node1/0     RP
cli                 01.00     node1/0     RP
config              01.00     node1/0     RP
counter             01.00     node1/0     RP
env                 01.00     node1/0     RP
gold                01.00     node1/0     RP
interface           01.00     node1/0     RP
ioswdsysmon         01.00     node1/0     RP
none                01.00     node1/0     RP
oir                 01.00     node1/0     RP
snmp                01.00     node1/0     RP
snmp-notification   01.00     node1/0     RP
test                01.00     node1/0     RP
timer               01.00     node1/0     RP
rpc                 01.00     node1/0     RP

regards

Deben

Sure.  The script I uploaded will work on your 4500.

HI Joseph,

I am getting below msg on console.

IST: %HA_EM-6-LOG: cpu-test.tcl: invalid command name "else"
IST: %HA_EM-6-LOG: cpu-test.tcl:     while executing
IST: %HA_EM-6-LOG: cpu-test.tcl: "else "
IST: %HA_EM-6-LOG: cpu-test.tcl:     invoked from within
IST: %HA_EM-6-LOG: cpu-test.tcl: "$slave eval $Contents"
IST: %HA_EM-6-LOG: cpu-test.tcl:     (procedure "eval_script" line 7)
IST: %HA_EM-6-LOG: cpu-test.tcl:     invoked from within
IST: %HA_EM-6-LOG: cpu-test.tcl: "eval_script slave $scriptname"
IST: %HA_EM-6-LOG: cpu-test.tcl:     invoked from within
IST: %HA_EM-6-LOG: cpu-test.tcl: "if {$security_level == 1} {       #untrusted script
IST: %HA_EM-6-LOG: cpu-test.tcl:      interp create -safe slave
IST: %HA_EM-6-LOG: cpu-test.tcl:      interp share {} stdin slave
IST: %HA_EM-6-LOG: cpu-test.tcl:      interp share {} stdout slave
IST: %HA_EM-6-LOG: cpu-test.tcl: ..."
IST: %HA_EM-6-LOG: cpu-test.tcl:     (file "tmpsys:/lib/tcl/base.tcl" line 50)
IST: %HA_EM-6-LOG: cpu-test.tcl: Tcl policy execute failed: invalid command name "else"

Below is the configuration on Switch

============================

XXXXXXXXXX#sh run | in event

event manager environment email_server x.x.x.x
event manager environment email_from xxx@xxx.com
event manager environment email_to xxx@xxx.com
event manager directory user policy "bootflash:/"
event manager policy cpu-test.tcl type user

thanks and regards.

DBN

Try this version.

HI Joseph ,

Thanks for you help.

But now iam geting error no " body" variable as below.

Mar 18 21:00:00.635 IST: %HA_EM-6-LOG: cpu-test.tcl: can't read "body": no such variable
Mar 18 21:00:00.635 IST: %HA_EM-6-LOG: cpu-test.tcl:     while executing
Mar 18 21:00:00.635 IST: %HA_EM-6-LOG: cpu-test.tcl: "format "%sMailservername: %s" "$body" "$email_server""
Mar 18 21:00:00.635 IST: %HA_EM-6-LOG: cpu-test.tcl:     invoked from within
Mar 18 21:00:00.635 IST: %HA_EM-6-LOG: cpu-test.tcl: "$slave eval $Contents"
Mar 18 21:00:00.635 IST: %HA_EM-6-LOG: cpu-test.tcl:     (procedure "eval_script" line 7)
Mar 18 21:00:00.635 IST: %HA_EM-6-LOG: cpu-test.tcl:     invoked from within
Mar 18 21:00:00.635 IST: %HA_EM-6-LOG: cpu-test.tcl: "eval_script slave $scriptname"
Mar 18 21:00:00.635 IST: %HA_EM-6-LOG: cpu-test.tcl:     invoked from within
Mar 18 21:00:00.635 IST: %HA_EM-6-LOG: cpu-test.tcl: "if {$security_level == 1} {       #untrusted script
Mar 18 21:00:00.635 IST: %HA_EM-6-LOG: cpu-test.tcl:      interp create -safe slave
Mar 18 21:00:00.635 IST: %HA_EM-6-LOG: cpu-test.tcl:      interp share {} stdin slave
Mar 18 21:00:00.635 IST: %HA_EM-6-LOG: cpu-test.tcl:      interp share {} stdout slave
Mar 18 21:00:00.635 IST: %HA_EM-6-LOG: cpu-test.tcl: ..."
Mar 18 21:00:00.635 IST: %HA_EM-6-LOG: cpu-test.tcl:     (file "tmpsys:/lib/tcl/base.tcl" line 50)
Mar 18 21:00:00.635 IST: %HA_EM-6-LOG: cpu-test.tcl: Tcl policy execute failed: can't read "body": no such variable

rgds

dbn

It appears you've modified the code since I sent it to you last.  The error you're seeing is not possible with the version I sent you.  What happens when you try the version I sent?

Hi Joseph,

Thanks for your ultimate support.

For mail sending part in need to contact my Exchange Admin for SMTP access.

Do u have any ebook for further study TCL in cisco device. If yes please help. I just google but i didnt find any.

regards

Deben

You may be able to find the ebook version of "Tcl Scripting for Cisco IOS" ISBN 978-1587059452.  Amazon offers it for the Kindle.

Review Cisco Networking for a $25 gift card