Time-based IOS actions

One of my regular readers asked this question:

I want to shut my particular interface after 6:oo pm every day. Right now I have just the general idea as to how EEM works. What I guessed is that when the router's clock ticks 6:00 pm a syslog message might be generated and event manager will catch it and execute the particular command. But I don’t understand how EEM monitors the clock so that it knows its 6:00 pm now and it has to generate a syslog message.

If you want a quick answer, you’ll find the exact solution in the Time-based wireless interface activity article in the EEM category in the CT3 wiki. However, you might want to get a bit more out of this question.

If you want to use EEM, the best investment of your time would be to spend an hour or two reading its introductory documentation, particularly the section describing the event detectors. It nicely describes four time-based event detectors available in EEM. You can also try searching my blog and CT3 wiki. For example, I’ve written about EEM timer cron event more than two years ago. The blog labels and wiki categorization should be of great help: start with the EEM label in the blog and the EEM category in the CT3 wiki.

Last but not least, there’s always more than one way to solve a problem with Cisco IOS. If you’re not happy with EEM, you can use Kron.

This article is part of You've asked for it series.

3 comments:

  1. Here's an example I did for one of my clients. They do not want to hear the phones ring after 4:00, so I have have the script change the PLAR's to the AA @ 4:00, then back at 8:00 AM.

    event manager applet WEEKDAY_START
    event timer cron name WEEKDAY_START cron-entry "1 8 * * 1-5"
    action 1.0 cli command "enable"
    action 1.1 cli command "config t"
    action 1.2 cli command "voice-port 0/0/0"
    action 1.3 cli command "connection plar 198"
    action 1.4 cli command "voice-port 0/0/1"
    action 1.5 cli command "connection plar 198"
    action 1.6 cli command "voice-port 0/0/2"
    action 1.7 cli command "connection plar 198"
    action 1.8 cli command "voice-port 0/0/3"
    action 1.9 cli command "connection plar 198"
    action 2.0 cli command "voice-port 0/1/2"
    action 2.1 cli command "connection plar 198"
    action 2.2 cli command "voice-port 0/1/3"
    action 2.3 cli command "connection plar 198"
    action 2.4 cli command "voice-port 0/2/0"
    action 2.5 cli command "connection plar 198"
    action 2.6 cli command "exit"
    action 2.7 cli command "exit"
    action 2.8 cli command "del /force flash:plar_change"
    action 2.9 cli command "show run | append plar_change"
    action 3.0 cli command "more flash:plar_change"
    action 3.1 mail server "$_email_server" to "voice@mail.com" from "$_email_from" subject "Coastal PLAR Change" body "$_cli_result"

    event manager applet WEEKDAY_END
    event timer cron name WEEKDAY_END cron-entry "1 16 * * 1-5"
    action 1.0 cli command "enable"
    action 1.1 cli command "config t"
    action 1.2 cli command "voice-port 0/0/0"
    action 1.3 cli command "connection plar 6005"
    action 1.4 cli command "voice-port 0/0/1"
    action 1.5 cli command "connection plar 6005"
    action 1.6 cli command "voice-port 0/0/2"
    action 1.7 cli command "connection plar 6005"
    action 1.8 cli command "voice-port 0/0/3"
    action 1.9 cli command "connection plar 6005"
    action 2.0 cli command "voice-port 0/1/2"
    action 2.1 cli command "connection plar 6005"
    action 2.2 cli command "voice-port 0/1/3"
    action 2.3 cli command "connection plar 6005"
    action 2.4 cli command "voice-port 0/2/0"
    action 2.5 cli command "connection plar 6005"
    action 2.6 cli command "exit"
    action 2.7 cli command "exit"
    action 2.8 cli command "del /force flash:plar_change"
    action 2.9 cli command "show run | append plar_change"
    action 3.0 cli command "more flash:plar_change"
    action 3.1 mail server "$_email_server" to "voice.mail.com" from "$_email_from" subject "Coastal PLAR Change" body "$_cli_result"

    ReplyDelete
  2. It is also possible to configure a time-based ACL with deny any statement.

    ReplyDelete
  3. @Laszlo: you're right, time-based ACL achieves the same results, but sometimes you want to shut down the physical (for example, wireless) interface (not to mention the potential routing problems if you happen to drop all the traffic on the best route :).

    ReplyDelete

You don't have to log in to post a comment, but please do provide your real name/URL. Anonymous comments might get deleted.

Ivan Pepelnjak, CCIE#1354, is the chief technology advisor for NIL Data Communications. He has been designing and implementing large-scale data communications networks as well as teaching and writing books about advanced technologies since 1990. See his full profile, contact him or follow @ioshints on Twitter.