On 12/09/2009 05:26 PM, John P. Rouillard wrote: > > In message<4b1fbe1f.3070...@umn.edu>, > Tim Peiffer writes: >> Risto Vaarandi wrote: >>> First, there is a way to implement at-like functionality dynamically >>> in SEC through the 'tevent' action (it's the most recently added >>> action that appeared in version 2.4.2). >>> The 'tevent' action generates a synthetic event after given amount of >>> seconds, and the number of seconds can be a variable. Since you said >>> that you would like to provide the size of the maintenance window via >>> the event stream, you could augment that event with the number of >>> seconds that have remained to the beginning of the maintenance window. >>> You could then use Single rule for catching that event which triggers >>> the actual context creation via 'tevent': >>> [...] >>> type=Single >>> ptype=RegExp >>> pattern=MAINTENANCE AFTER (\d+) sec FOR (\d+) sec >>> desc=trigger the creation of maintenance context \ >>> after $1 seconds with a lifetime of $2 seconds >>> action=tevent $1 MAINT_CONTEXT_FOR_$2 >>> [...] > >> I think you have addressed part of what I am asking. Using you as a >> sounding board - So if I read a ticket and create a log event >> "myhost.mydomain Maintenance window scheduled 200912090800 for 3600 >> seconds", would I need to parse the start time, and compare to<now>, >> and use that delta in the tevent? > > That's how I read it. You can use eval to call the parsing > routine. Something like: > > eval %{deltatime} (mydeltatime($1);); tevent %{deltatime} \ > MAINT_CONTEXT_FOR_$2 > > If you use a time_t for your starting time, then mydeltatime is: > > return ($1 - time)
...and if you are on Linux or have the GNU date utility installed, then you can use /bin/date the as a core part of the parsing routine. For example, /bin/date -d '20091209 0800' +"%s" is able to accept your timestamp almost without modifications (you only have to insert a single space between date and time!), and it is able to convert it to seconds since epoch. I truly like the -d flag of GNU date, since you can throw a variety of free form strings to it like "next Sunday", "next Wednesday 12pm", or "1 week 2 days" (9 days from now). ("9 and half weeks" does not work, though :) Given that SEC supports the %u variable which indicates the current time in seconds from epoch, you only have to subtract these two values. In order to provide you an example, action=eval %diff (`date -d 'tomorrow' +"%%s"` - %u) always sets %diff to 86400. Note that you have to escape the % sign in the /bin/date format string, since otherwise it would be replaced with the value from the 'desc' field of your rule. hth, risto > > -- > -- rouilj > John Rouillard > =========================================================================== > My employers don't acknowledge my existence much less my opinions. > > ------------------------------------------------------------------------------ > Return on Information: > Google Enterprise Search pays you back > Get the facts. > http://p.sf.net/sfu/google-dev2dev > _______________________________________________ > Simple-evcorr-users mailing list > Simple-evcorr-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/simple-evcorr-users > ------------------------------------------------------------------------------ Return on Information: Google Enterprise Search pays you back Get the facts. http://p.sf.net/sfu/google-dev2dev _______________________________________________ Simple-evcorr-users mailing list Simple-evcorr-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/simple-evcorr-users