cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
3950
Views
20
Helpful
12
Replies

Best way to execute TCL script on Router startup/reload

ilrobby00
Level 1
Level 1

Hi there!

I've read a lot of posts about eem but, now, I'm really confused about which is the best way to execute a tcl script at router's boot/reload...

I've a isr 887VA (MPC8300):

Version 12.4(22r)YB5, RELEASE SOFTWARE (fc1)

C880 Software (C880DATA-UNIVERSALK9-M), Version 15.1(4)M7, RELEASE SOFTWARE (fc2)

System image file is "c880data-universalk9-mz.151-4.M7.bin

License UDI:

*0        CISCO887VA-SEC-K9
License Information for 'c880-data'
    License Level: advipservices   Type: Permanent

I've a wakeonlan tlc script that I want execute 30 min after the router boot time (after a controlled power loss made by ups and after a full charge of ups battery... when the power come back, router can powers up itself and I want that it sends magic packet to a server's nic).

Eem version is 3.2 but seems that not all command options that I've find in other posts/cisco docs, can be execute on my ios version/enabled features...

Can you help me please?

Bye,

Robby.

2 Accepted Solutions

Accepted Solutions

Cron is more reliable when it comes to running EEM policies at reload.  No, maxrun is not a built-in argument to tclsh scripts.  This should work for you if you switch to using a cron-based policy.

View solution in original post

12 Replies 12

Hello Joe!

Thanks, I've already read your guide! But in conf t, I haven't "event timer", only event manager"...

Event timer is a sub-command of event manager?

Yes.  From the examples you see in my doc, you first configure the applet:

event manager applet foo

Then you configure the event (e.g., timer).  From the applet, you can call tclsh to invoke your Tcl script (as it sounds like you're using UDP sockets in your Tcl script, and they won't work in EEM Tcl).

Really thanks Joe!

Yes, udp socket!

Something like that, should works?


event manager directory user library flash:/eem/tcl_scripts

event manager applet WoL

event syslog pattern "SYS-5-RESTART"

event timer countdown time 1800

action 0 cli command "enable"

action 1 cli command "tclsh flash:/eem/tcl_scripts/WoL.tcl maxrun 60"

action 2 cli command "exit"

action 3 cli command "exit"

Well, I'm not sure how your script is written, but this is likely wrong.  The tclsh script isn't an EEM script, so not sure why it would be in an "eem" subdirectory.  Any parameter, maxrun likely wouldn't have meaning to a tclsh script, either. 

Additionally, I would use the "event timer cron cron-entry @reboot" approach to launch your policy after reload.

The folder name is only my bad concept!

cron is better than syslog-event, for cpu/mem load?

I've attached the scitpt, If you still have a minute to check it for me, to be sure!!

If i run from cli, it works!

Joe, tcl scripts ran from a cli, has a maxrun timeout?

Cron is more reliable when it comes to running EEM policies at reload.  No, maxrun is not a built-in argument to tclsh scripts.  This should work for you if you switch to using a cron-based policy.

Ok Joe!

I'll try and give you a feedback!

Just one last thing, it's better to use the eem event countdown, or an "after" instruction in tcl script?

countdown is better.  The "after" call means that you are occupying device resources longer than you really need.

Joe!

Excuse me!

But, when I show the policy, I see "maxrun 20.000"...

If the script still run after 20", will be killed?

From an EEM standpoint, yes.  The default maxrun is 20 seconds, and if the policy runs longer than 20 seconds it will be killed.  You can increase this at the applet level if you need to.

Joe it works!!!!

Now I've to hope that the uefi bios of server, the fw of nic, really listening for the wol packets!!

Really, reaaly thanks again Joe!

Just for future reference, this is the policy that I've defined:

event manager directory user library flash:/eem/tcl_scripts

event manager applet WoL

event timer cron cron-entry "@reboot"

event timer countdown time 1800 maxrun 120

description "Send WoL Magic Packet to vServer @vRouter_Reboot"

action 0 cli command "enable"

action 1 cli command "tclsh flash:/eem/tcl_scripts/WoL.tcl 000000000000"

action 2 cli command "exit"

action 3 cli command "exit"

exit

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: