[j-nsp] Generating events based on day of week

Curtis Call ccall at juniper.net
Fri Oct 30 10:14:41 EDT 2009


If you are interested in a supported approach then take a look at the day-event.slax event script that was just added to Junoscriptorium:

http://junoscriptorium.googlecode.com/svn/trunk/library/juniper/event/utility/day-event/day-event.xml

It logs a syslog message every day in the format:

Oct 30 00:00:00  j4350 cscript: Day-Event: Fri Oct 30 00:00

So your event policies can trigger on it like this:

policy friday-policy {
    events system;
    attributes-match {
        system.message matches "Day-Event: Fri";
    }
    then {
        ...
    }
}

It runs at 00:00 by default, but can run at other times if desired, see the above weblink for details.

BTW, if the need is to do stateless firewall filters that change based on the day of week then there is already a commit+event script in Junoscriptorium that do all the heavy lifting for you.  With them loaded, all you need to do is add time-range macros to your filter terms:

     term night {
         apply-macro active-time-range {
             start-time "weekdays 17:00";
             stop-time "weekdays 20:00";
         }
         ...
     }

http://junoscriptorium.googlecode.com/svn/trunk/library/juniper/event/filters/time-based-filters/time-based-filters.xml
http://junoscriptorium.googlecode.com/svn/trunk/library/juniper/commit/filters/cs-time-based-filters/cs-time-based-filters.xml



More information about the juniper-nsp mailing list