02-16-2010 11:24 AM
I'm using the sendmail.tcl script template from the Embedded Event Manager (EEM) Scripting Community (http://forums.cisco.com/eforum/servlet/EEM?page=search_results&fn=search&count=20&skip=60&catId=0&keywords=&sortBy=3&order=DESC&mode=browse). I would like to schedule the script to run once a month, but I can't figure out how to do so. The template includes the following line:
#::cisco::eem::event_register_timer cron name test cron_entry "0 * * *" queue_priority low nice 1 maxrun 20
I haven't been able to find any documentation on how to use cron in combination with a tcl script stored in the flash of the router. I tried simply removing the "#" to uncommend the line, and then re-registered the policy, but to no avail. My goal in doing all of this is to have the router email me with the "show tech" output once a month. I'm just missing the automation part at the moment. Thanks!
02-16-2010 12:09 PM
02-17-2010 12:32 PM
I didn't want to wait until midnight to see if your script worked, so I used the following cron command at the very top of the script:
::cisco::eem::event_register_timer cron name test cron_entry "0 * * * *" queue_priority low nice 1 maxrun 20
I unregistered and re-registered the policy, and even ran the script manually, but it still has not sent an email automatically. Any thoughts?
02-17-2010 04:46 PM
Post the output of "show event manager policy registered".
02-17-2010 08:01 PM
No. Class Type Event Type Trap Time Registered Name
1 script user timer cron Off Tue Feb 16 19:26:35 2010 sendmail.tcl
name {test} cron entry {27 * * * *}
nice 1 queue-priority low maxrun 20.000
02-17-2010 09:27 PM
The way you have it registered here, it will run every 27 minute of the hour. Check the output of "show event manager history event" to see if it's running. You should also make sure your clock is set correctly (e.g. synced with NTP). If you still can't get it to run, it would be helpful to see the output of "debug event manager tcl cli" and "debug event manager tcl smtp" after the policy is scheduled to run.
02-19-2010 11:10 AM
I corrected the clock yesterday by syncing it with an NTP server. It was only off a little bit.
blmrtr#show debug
Embedded Event Manager:
Debug EEM Tcl CLI library debugging is on
Debug EEM Tcl SMTP library debugging is on
blmrtr#show event manager history events
No. Time of Event Event Type Name
1 Fri Feb19 05:00:00 2010 timer cron script: sendmail.tcl
2 Fri Feb19 06:00:00 2010 timer cron script: sendmail.tcl
3 Fri Feb19 07:00:00 2010 timer cron script: sendmail.tcl
4 Fri Feb19 08:00:00 2010 timer cron script: sendmail.tcl
5 Fri Feb19 09:00:00 2010 timer cron script: sendmail.tcl
6 Fri Feb19 10:00:00 2010 timer cron script: sendmail.tcl
7 Fri Feb19 11:00:00 2010 timer cron script: sendmail.tcl
8 Fri Feb19 12:00:00 2010 timer cron script: sendmail.tcl
9 Fri Feb19 13:00:00 2010 timer cron script: sendmail.tcl
10 Fri Feb19 14:00:00 2010 timer cron script: sendmail.tcl
blmrtr#show log
Feb 19 19:00:01.077: %HA_EM-6-LOG: sendmail.tcl: DEBUG(cli_lib) : CTL : cli_open called.cannot get pty for exec: Error opening vty
Feb 19 19:00:01.077: %HA_EM-6-LOG: sendmail.tcl: while executing
Feb 19 19:00:01.077: %HA_EM-6-LOG: sendmail.tcl: "cli_open"
Feb 19 19:00:01.077: %HA_EM-6-LOG: sendmail.tcl: invoked from within
Feb 19 19:00:01.077: %HA_EM-6-LOG: sendmail.tcl: "$slave eval $Contents"
Feb 19 19:00:01.077: %HA_EM-6-LOG: sendmail.tcl: (procedure "eval_script" line 7)
Feb 19 19:00:01.077: %HA_EM-6-LOG: sendmail.tcl: invoked from within
Feb 19 19:00:01.077: %HA_EM-6-LOG: sendmail.tcl: "eval_script slave $scriptname"
Feb 19 19:00:01.077: %HA_EM-6-LOG: sendmail.tcl: invoked from within
Feb 19 19:00:01.077: %HA_EM-6-LOG: sendmail.tcl: "if {$security_level == 1} { #untrusted script
Feb 19 19:00:01.077: %HA_EM-6-LOG: sendmail.tcl: interp create -safe slave
Feb 19 19:00:01.077: %HA_EM-6-LOG: sendmail.tcl: interp share {} stdout slave
Feb 19 19:00:01.077: %HA_EM-6-LOG: sendmail.tcl: interp share {} stderr slave..."
Feb 19 19:00:01.077: %HA_EM-6-LOG: sendmail.tcl: (file "system:/lib/tcl/base.tcl" line 50)
Feb 19 19:00:01.077: %HA_EM-6-LOG: sendmail.tcl: Tcl policy execute failed: cannot get pty for exec: Error opening vty
02-19-2010 11:15 AM
It looks like you may be out of VTY lines. What version of IOS are you running?
02-19-2010 11:30 AM
Cisco IOS Software, 2800 Software (C2800NM-ADVIPSERVICESK9-M), Version 12.4(6)T2, RELEASE SOFTWARE (fc1)
line vty 0 4
access-class 99 in
password 7 xxxxxxxxxxxxxxxxxx
login local
transport input telnet ssh
line vty 5 15
access-class 99 in
password 7 xxxxxxxxxxxxxxxxxxxx
login local
transport input telnet ssh
blmrtr#show line
Tty Line Typ Tx/Rx A Modem Roty AccO AccI Uses Noise Overruns Int
0 0 CTY - - - - - 0 0 0/0 -
1 1 AUX 9600/9600 - - - - - 0 0 0/0 -
* 322 322 VTY - - - - 99 101 0 0/0 -
* 323 323 VTY - - - - 99 21 0 0/0 -
* 324 324 VTY - - - - 99 10 0 0/0 -
* 325 325 VTY - - - - 99 4 0 0/0 -
* 326 326 VTY - - - - 99 2 0 0/0 -
* 327 327 VTY - - - - 99 1 0 0/0 -
* 328 328 VTY - - - - 99 0 0 0/0 -
* 329 329 VTY - - - - 99 0 0 0/0 -
* 330 330 VTY - - - - 99 0 0 0/0 -
* 331 331 VTY - - - - 99 0 0 0/0 -
* 332 332 VTY - - - - 99 0 0 0/0 -
* 333 333 VTY - - - - 99 0 0 0/0 -
* 334 334 VTY - - - - 99 0 0 0/0 -
* 335 335 VTY - - - - 99 0 0 0/0 -
* 336 336 VTY - - - - 99 37 0 0/0 -
337 337 VTY - - - - 99 20 0 0/0 -
Line(s) not in async mode -or- with no hardware support:
2-321
02-19-2010 01:14 PM
You are out of VTY lines. EEM requires at least two VTY lines to be free in order to execute CLI commands. Try clearing some of the lines, then test the policy.
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: