05-31-2017 03:16 PM
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.
Solved! Go to Solution.
06-01-2017 05:26 AM
06-01-2017 01:31 PM
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.
06-01-2017 05:26 AM
06-01-2017 08:17 AM
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?
06-01-2017 10:10 AM
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).
06-01-2017 11:16 AM
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"
06-01-2017 11:38 AM
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.
06-01-2017 12:47 PM
06-01-2017 01:31 PM
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.
06-02-2017 10:52 AM
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?
06-02-2017 11:22 AM
countdown is better. The "after" call means that you are occupying device resources longer than you really need.
06-02-2017 11:50 AM
Joe!
Excuse me!
But, when I show the policy, I see "maxrun 20.000"...
If the script still run after 20", will be killed?
06-02-2017 11:54 AM
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.
06-02-2017 12:34 PM
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
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide