On 10/25/2012 01:30 PM, Robert Charroux wrote:
> Hi, i'm trying to find a way to delete a certain amount of contexts a
> rule created. this based on a daily task.
> the contexts are created like this by the rule : already_got_$2 , where
> $2 is a hostname
>
> So, what i'd like to do is something like that:
>
> #RO
> type=calendar
> time = 0 0 * * * *
> desc = reseting contetxts of the form 'already_got_.*'
> action = delete already_got_.*
>
> thus, deleting every contexts that match this pattern. but not every
> contetxts that other rules can have created.
>
> Anyone have an idea ?

hi Robert,

one way to address this problem would be to use aliases connected to a 
single context. Any context can have multiple names which all refer to 
the same internal data structure. If the context is deleted, all names 
disappear, but if just one alias is removed, other names stay intact.
The following ruleset illustrates this idea:

type=single
ptype=regexp
pattern=create (\S+)
desc=create context $1
action=create CONTEXT; alias CONTEXT $1

type=single
ptype=regexp
pattern=delete (\S+)
desc=delete context $1
action=unalias $1

type=calendar
time=0 0 * * *
desc=delete context
action=delete CONTEXT

The first rule creates the context CONTEXT (if it already exists, its 
creation timestamp will be updated and event store is emptied, but alias 
list does not change). After that, a new alias name is created with 
'alias CONTEXT $1'. The second rule removed a given alias name, while 
the final calendar rule deletes CONTEXT with all aliases each midnight.

Unfortunately, currently there is no way to do generic regular 
expression matching against context names. But I am planning to add a 
loop action to the next sec release, and if there would also be an 
action 'findcont %o regexp', that would allow for creating repeated 
actions over data in variable %o.

kind regards,
risto

>
>
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_sfd2d_oct
>
>
>
> _______________________________________________
> Simple-evcorr-users mailing list
> Simple-evcorr-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/simple-evcorr-users


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
Simple-evcorr-users mailing list
Simple-evcorr-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/simple-evcorr-users

Reply via email to