Re: [Simple-evcorr-users] Scheduling context creation?

2009-12-09 Thread Tim Peiffer
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?

Regards,
Tim

Risto Vaarandi wrote:
 Tim,
 you could tackle the problem in several ways.

 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

 type=Single
 ptype=RegExp
 pattern=MAINT_CONTEXT_FOR_(\d+)
 desc=create maintenance context for $1 seconds
 action=create MAINT_CONTEXT $1

 Another (and perhaps simpler) way of addressing the problem would be 
 to create a temporary context with the lifetime of $1 seconds in the 
 first rule, which would create MAINT_CONTEXT with a lifetime of $2 
 from its action-on-expire list. In that case you only have one rule, 
 and if you are afraid of losing state between restarts, SEC can be 
 easily configured to store/reload its contexts to/from disk at 
 shutdown/restart (see a 5 year old post from the mailing list: 
 http://sourceforge.net/mailarchive/message.php?msg_id=4177CC7F.7080002%40eyp.ee).
  

 On the other hand, 'tevent' creates a separate synthetic event that 
 can be matched by other rules as well, and its use is more convenient 
 if you would like to set up several event processing rules for 
 maintenance window creation.

 hth,
 risto


 On 12/03/2009 02:23 PM, Tim Peiffer wrote:
 I have been running SEC as a method to front-end trouble ticketing via
 HP ServiceCenter.  One of the problems I have not figured out is how to
 dynamically schedule context creation so that I can bypass the ticket
 creation if there is a known maintenance window.  I have very little
 clue on how to develop a dynamic scheduler in SEC.  I am looking for
 ideas; has this problem already been tackled?  I am thinking that I
 might be able to employ the perl module Schedule::At
 (http://search.cpan.org/~joserodr/Schedule-At-1.08/At.pm), but that may
 not be necessary.  I think that the actual maintenance window should be
 sent through the event stream.

 Lets say that there is a known maintenance window on a particular device
 (router, switch).  I would like to do a search of the network topology
 starting at the device that the maintenance window is declared, and
 create a context for each one of the managed devices below that point.
 The context creation should have a defined date/time of birth, and a
 defined life time.

 Regards,
 Tim


--
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


Re: [Simple-evcorr-users] Scheduling context creation?

2009-12-09 Thread Risto Vaarandi
On 12/09/2009 05:26 PM, John P. Rouillard wrote:

 In message4b1fbe1f.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 tonow,
 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