On Wed, 10 Oct 2012, Boyles, Gary P wrote: > David, > Thank you for your response. > > Yes... I am worried about performance, so I'm trying to design-in good > performance from the get-go.
One thing to remember is that regex matches can be expensive (especially complex regex matches like you use to pull variables out of a line). In many cases it's faster to use a snippet of perl code to do the job. I have a fairly standard snippet that I use: pattern=sub { $timestamp = substr($_[0],0,16);@junk=split(' ', substr($_[0],17));$server = shift @junk; $tag = shift @junk;@test=split('\|',join(' ',@junk));unshift @test,($timestamp,$server,$tag); return @test; This takes the syslog line, extracts the timestamp, server and syslog tag and then reassembles everything as an array. This particular line is for dealing with a log that is pipe delimited, if it's space delimited I don't need to pull out the server and tag fields and it reduces down to: pattern=sub { $timestamp = substr($_[0],0,16);@test=split(' ', substr($_[0],17));unshift @test,($timestamp); return @test; I usually add if statements before the return to test for various conditions in the log line. It's ugly, but much faster than a complex regex that extracts out 4-5 fields that are widely separated in the line. David Lang > Thank you for your help!!! > Gary Boyles > > -----Original Message----- > From: da...@lang.hm [mailto:da...@lang.hm] > Sent: Wednesday, October 10, 2012 1:11 PM > To: Risto Vaarandi > Cc: Boyles, Gary P; simple-evcorr-users@lists.sourceforge.net > Subject: Re: [Simple-evcorr-users] Setup and use of context and variables. > > On Wed, 10 Oct 2012, Risto Vaarandi wrote: > >> hi Gary, >> below are short answers to your questions: >> >> 2012/10/10 Boyles, Gary P <gary.p.boy...@intel.com>: >>> >>> Question #2: >>> >>> ========== >>> >>> Once I create a context-string, is there a way to do pattern-matching on the >>> context name? >>> >>> >>> >>> What I?d like to do is have the CONTEXT name equal something >>> like?nodexyz::DC1::POD1?, and then to a pattern match to see if the node >>> name equals ?nodexyz? is contained in that CONTEXT name. >>> >> >> unfortunately, pattern matching can't be done for context names. >> On the other hand, there might be several workarounds, depending on >> the actual problem you have (maybe it is possible to cleverly use >> context aliases?) > > When you run into really sticky problems in this area, remember that if > you use a script as your pattern type you can have it set or reference > variables, including doing whatever pattern matching on things that you > want. > > perl hashes give you a huge amount of flexibility in this area. It's > trivial (and cheap) to check for the existance of a particular hash key > with exists, and you can always do keys %hash to get a list of the keys > and then search or do regexes against that list. > > David Lang > ------------------------------------------------------------------------------ Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev _______________________________________________ Simple-evcorr-users mailing list Simple-evcorr-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/simple-evcorr-users