Re: [Simple-evcorr-users] Help with rule

2010-10-01 Thread John P. Rouillard

In message 1285950348.25147.9.ca...@kittyhawk.ittns.northwestern.edu,
Mike Rykowski writes:
What I want to do is ignore subsequent messages if the mac and network
are the same. But if a subsequent message has the same network but
different mac then send email. 

Ahh, so I have the wrong problem description too.

 ... dhcpd: DHCPDISCOVER from 00:00:00:00:00:00 via 1.2.3.4: network 1.2.3/23: 
 no free leases


I haven't had a chance to test this but I think it should work. Try
the following:

  type = pair
  desc = match starting line and extract elements
  ptype = regexp
  pattern = dhcpd: DHCPDISCOVER from \S+ via \S+ network (\S+) no free leases
  context = ! network_$1
  rem = action when event A arrives
  action = create 120 context_$1

  desc2 = match event on same network but for different ethernet address
  ptype2 = substr
  pattern2 = dhcpd: DHCPDISCOVER from (\S+) via \S+ network $1 no free leases
  rem = action when event B arrives within window
  action2 = 
  window = 120

If another 

  ... from 00:00:00:00:00:00 via 1.2.3.4: network 1.2.3/23: no free leases

comes through, it is suppressed automatically because it matches the
trigger event as specified by pattern. If an event like:

 ... from 11:11:11:11:11:11 via 1.2.3.4: network 1.2.3/23: no free leases

comes through, it doesn't trigger pattern 1 because the context
network_1.2.3/23 (network_$1) exists for 2 minutes after the
triggering event. However it does match pattern 2.

If an event:

  ... from 00:01:00:00:00:00 via 1.2.3.4: network 1.2.3.0/24: no free leases

comes through, it won't match pattern2 since $1 is set to 1.2.3/23 (it may
match pattern and start a new correlation operation though).

--
-- rouilj
John Rouillard
===
My employers don't acknowledge my existence much less my opinions.

--
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
___
Simple-evcorr-users mailing list
Simple-evcorr-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/simple-evcorr-users


Re: [Simple-evcorr-users] Help with rule

2010-10-01 Thread Risto Vaarandi
So you would like to react on the *second* DHCPDISCOVER event, where the 
network is the same as for the previous event, but MAC is different?

If that's the case, here are the rulesets for sample A and B events.

The first solutions employs one Pair rule. Since regular expressions are 
identical in both parts of the rule, the first regular expression will 
grab all events and nothing gets passed to the second expression. In 
order to prevent this from happening, we have to use a context called 
TRACKING_$2 which will be created when the first event appears. For 
example, if event blah A blah B appears, context TRACKING_B is 
created. The presence of the context will switch off the first regular 
expression for 60 seconds if any subsequent event blah * blah B 
arrives. After example event blah A blah B has arrived, we will also 
create an alias HAVE_SEEN_B_WITH_A which indicates that we have seen B 
with A (creating an alias instead of another context is useful, since 
TRACKING_B and HAVE_SEEN_B_WITH_A are supposed to exist exactly at the 
same time).

Suppose now that second instance of blah * blah B event comes in. Note 
that the first regular expression is unable to match due to the presence 
of TRACKING_B. However, the second regular expression matches only if * 
is not A (since the presence of HAVE_SEEN_B_WITH_A prevents the match 
from occurring). For instance, if blah C blah B comes in, it matches, 
since HAVE_SEEN_B_WITH_C does not exist, and thus a string we have 
observed B without A (instead A there was C) gets written to standard 
output:

type=Pair
ptype=regexp
pattern=blah (.+) blah (.+)
context=!TRACKING_$2
desc=tracking second instance of $2
action=create TRACKING_$2 60; alias TRACKING_$2 HAVE_SEEN_$2_WITH_$1
ptype2=regexp
pattern2=blah (.+) blah $2
context2=!HAVE_SEEN_%2_WITH_$1
desc2=we have observed %2 without %1 (instead %1 there was $1)
action2=write - %s; delete TRACKING_%2
window=60

(Note that the lifetime of the Pair operation and the contexts is 60 
seconds.)

If you would like to achieve the same effect with Single rules, you 
could do something like:

type=Single
ptype=regexp
pattern=blah (.+) blah (.+)
context=!TRACKING_$2
desc=start tracking second instance of $2 without $1
action=create TRACKING_$2 60; alias TRACKING_$2 HAVE_SEEN_$2_WITH_$1

type=Single
ptype=regexp
pattern=blah (.+) blah (.+)
context=TRACKING_$2  !HAVE_SEEN_$2_WITH_$1
desc=we have observed $2 twice with different companions
action=write - %s; delete TRACKING_$2

It is quite similar to previous Pair rule - you just can't get the name 
of first companion of B into the alarm (A, that is). I have to admit I 
like the second solution a bit more, since all correlation logic is 
presented as boolean expressions, and is thus easier to read.

In your last post, I also noticed that you used ^ for negation inside 
the pattern2 field. That will not work unfortunately -- ^ works as a 
negation operator only inside square brackets [^...], but this construct 
matches *one* character only. If you want to negate a whole string, Perl 
regexp negative look-ahead or look-behind might do the trick. I my 
example, I haven't used it, but the first solution might be somewhat 
simpler with it:

type=Pair
ptype=regexp
pattern=blah (.+) blah (.+)
context=!TRACKING_$2
desc=tracking second instance of $2
action=create TRACKING_$2 60
ptype2=regexp
pattern2=blah ((?!$1)\S+) blah $2
desc2=we have observed %2 without %1 (instead %1 there was $1)
action2=write - %s; delete TRACKING_%2
window=60

Note that I haven't tested it fully, but after a quick test it seemed to 
work.

hope this helps and is not too confusing :)
risto


On 10/01/2010 07:25 PM, Mike Rykowski wrote:
 What I want to do is ignore subsequent messages if the mac and network
 are the same. But if a subsequent message has the same network but
 different mac then send email.

 So it seems I'd like to see your example solutions :)

 On Fri, 2010-10-01 at 19:17 +0300, Risto Vaarandi wrote:
 hi Mike,

 I have almost completed two possible example solutions to the problem,
 but after seeing your e-mail I have an inkling I've got the problem
 statement wrong :(
 So far I had an impression that you would like to do some clever
 pairwise correlation for events that are matched by (almost) identical
 regular expressions. (Just a note: if the expressions are almost the
 same, it is actually a bit tricky with Pair* rules.)
 However, from the example I've got an understanding that you would
 simply like to suppress duplicate alarms for within a given time window,
 provided that *both* the MAC address and the network are the same. Is my
 understanding correct?
 If so, you could try the following rule:

 type=SingleWithSuppress
 ptype=RegExp
 pattern=\S+\s+\S+\s+\S+\s+\S+ dhcpd: DHCPDISCOVER from (\S+) via \S+
 network (\S+): no free leases
 desc=$2 no free leases for MAC $1
 action=send email
 window=120

 If I didn't get it quite right, I'll post my two example solutions :)




Re: [Simple-evcorr-users] Help with rule

2010-10-01 Thread Mike Rykowski
Big thank you to both you and Risto it is working.  



On Fri, 2010-10-01 at 12:47 -0400, John P. Rouillard wrote:

   type = pair
   desc = match starting line and extract elements
   ptype = regexp
   pattern = dhcpd: DHCPDISCOVER from \S+ via \S+ network (\S+) no free leases
   context = ! network_$1
   rem = action when event A arrives
   action = create 120 context_$1
 
   desc2 = match event on same network but for different ethernet address
   ptype2 = substr
   pattern2 = dhcpd: DHCPDISCOVER from (\S+) via \S+ network $1 no free leases
   rem = action when event B arrives within window
   action2 = 
   window = 120

-- 
Mike Rykowski
NU-IT Telecommunications and Network Services


--
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
___
Simple-evcorr-users mailing list
Simple-evcorr-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/simple-evcorr-users