Xymon Mailing List Archive search

hobbit-alerts.cfg -- Perl regex

4 messages in this thread

list Robert Herron · Thu, 11 Aug 2005 13:07:05 -0400 ·
I'm having a problem with Perl regular expressions in the
hobbit-alerts.cfg file.  Can someone tell me what I'm doing wrong:

Background info:  our servers are named by location, function, number
(e.g. NYCMAIL1).   As our data center in "NYC", a lot of systems's
names start with NYC.

I'm lazy and really don't want to have to type NYC over and over
again.  So, I tried using a macro with a wildcard like:

$HG-WinSvrsCrit=nyc%(app1|dc1|dc2|ex1|ex03|fs1|fs2|time).domain.com

but it doesn't work.  However, it works if I change it to:

$HG-WinSvrsCrit=%(nycapp1|nycdc1|nycdc2|nycex1|nycex03|nycfs1|nycfs2|nyctime).domain.com


The $HG-WinSvrsCrit wildcard is used later in hobbit-alerts.cfg with
statements like:

HOST=$HG-WinSvrsCrit $OPTIONS EXSERVICE=smtp,oradb
        MAIL bb_NetAdm
        MAIL bb_SrPCT
        MAIL bb_ProjMgr DURATION>60m

A "~/server/bin/hobbitd_alert --dump_config" looks correct for the
desired macro/wildcard combo:

HOST=nyc%(app1|dc1|dc2|ex1|ex03|fs1|fs2|gis2|time).domain.com
EXSERVICE=smtp,oradb COLOR=purple,red
        MAIL bb_NetAdm FORMAT=TEXT REPEAT=30
        MAIL bb_SrPCT FORMAT=TEXT REPEAT=30
        MAIL bb_ProjMgr FORMAT=TEXT REPEAT=30 DURATION>60

But the INFO page for the nyc[app1|dc1|dc2|ex1|ex03|fs1|fs2|gis2|time]
hosts only shows UNMATCHED catch-all entry.

I'm stumped.  Please help.
-- 


Robert Herron
user-8b27ea4290da@xymon.invalid
list Werner Michels · Thu, 11 Aug 2005 15:07:47 -0300 ·
Robert,

	Please try change the HG definition as:

$HG-WinSvrsCrit=%nyc(app1|dc1|dc2|ex1|ex03|fs1|fs2|time).domain.com

	Observe that the "%" is the first char and this indicates that your using perl regex.
	With this change your host group should work fine. 	
	-wm


On Thu, 11 Aug 2005 13:07:05 -0400
quoted from Robert Herron
Robert Herron <user-8b27ea4290da@xymon.invalid> wrote:
I'm having a problem with Perl regular expressions in the
hobbit-alerts.cfg file.  Can someone tell me what I'm doing wrong:

Background info:  our servers are named by location, function, number
(e.g. NYCMAIL1).   As our data center in "NYC", a lot of systems's
names start with NYC.

I'm lazy and really don't want to have to type NYC over and over
again.  So, I tried using a macro with a wildcard like:

$HG-WinSvrsCrit=nyc%(app1|dc1|dc2|ex1|ex03|fs1|fs2|time).domain.com

but it doesn't work.  However, it works if I change it to:

$HG-WinSvrsCrit=%(nycapp1|nycdc1|nycdc2|nycex1|nycex03|nycfs1|nycfs2|nyctime).domain.com


The $HG-WinSvrsCrit wildcard is used later in hobbit-alerts.cfg with
statements like:

HOST=$HG-WinSvrsCrit $OPTIONS EXSERVICE=smtp,oradb
        MAIL bb_NetAdm
        MAIL bb_SrPCT
        MAIL bb_ProjMgr DURATION>60m

A "~/server/bin/hobbitd_alert --dump_config" looks correct for the
desired macro/wildcard combo:

HOST=nyc%(app1|dc1|dc2|ex1|ex03|fs1|fs2|gis2|time).domain.com
EXSERVICE=smtp,oradb COLOR=purple,red
        MAIL bb_NetAdm FORMAT=TEXT REPEAT=30
        MAIL bb_SrPCT FORMAT=TEXT REPEAT=30
        MAIL bb_ProjMgr FORMAT=TEXT REPEAT=30 DURATION>60

But the INFO page for the nyc[app1|dc1|dc2|ex1|ex03|fs1|fs2|gis2|time]
hosts only shows UNMATCHED catch-all entry.

I'm stumped.  Please help.
-- 


Robert Herron
user-8b27ea4290da@xymon.invalid


E-mail classificado pelo Identificador de Spam Inteligente Terra.
Para alterar a categoria classificada, visite
http://mail.terra.com.br/protected_email/imail/imail.cgi?+_u=wmlistas&_l=1,1123780209.882174.29442.casama.terra.com.br,3853,Des15,Des15
list Henrik Størner · Thu, 11 Aug 2005 20:36:19 +0200 ·
quoted from Werner Michels
On Thu, Aug 11, 2005 at 03:07:47PM -0300, Werner Michels (Ext Lists) wrote:
Robert,

	Please try change the HG definition as:

$HG-WinSvrsCrit=%nyc(app1|dc1|dc2|ex1|ex03|fs1|fs2|time).domain.com

	Observe that the "%" is the first char and this indicates that your using perl regex.
	With this change your host group should work fine. 
Werner is right here - the "%" must be first, it's only mission is to
tell Hobbit to treat this as a regular expression instead of a simple
text string.

For debugging regular expressions, I routinely use the info-page
display (which shows clearly whether a host/test is matched or not),
but also the "pcretest" tool that comes with the pcre library. Like
this:

$ pcretest
PCRE version 4.5 01-December-2003

  re> /nyc(app1|dc1|dc2|ex1|ex03|fs1|fs2|time).domain.com/
  data> nycdc2.domain.com
    0: nycdc2.domain.com
    1: dc2
  data> nycdc4.domain.com
    No match


Regards,
Henrik
list Robert Herron · Thu, 11 Aug 2005 16:51:57 -0400 ·
Moving the % fixed the problem.  Thanks for the help and tip.
quoted from Henrik Størner

On 11 Aug 2005 20:45:26 -0000, user-ce4a2c883f75@xymon.invalid (Henrik Stoerner) wrote: 
On Thu, Aug 11, 2005 at 03:07:47PM -0300, Werner Michels (Ext Lists) wrote:
Robert,

      Please try change the HG definition as:

$HG-WinSvrsCrit=%nyc(app1|dc1|dc2|ex1|ex03|fs1|fs2|time).domain.com

      Observe that the "%" is the first char and this indicates that your using perl regex.
      With this change your host group should work fine.
Werner is right here - the "%" must be first, it's only mission is to
tell Hobbit to treat this as a regular expression instead of a simple
text string.

For debugging regular expressions, I routinely use the info-page
display (which shows clearly whether a host/test is matched or not),
but also the "pcretest" tool that comes with the pcre library. Like
this:

$ pcretest
PCRE version 4.5 01-December-2003

  re> /nyc(app1|dc1|dc2|ex1|ex03|fs1|fs2|time).domain.com/
  data> nycdc2.domain.com
    0: nycdc2.domain.com
    1: dc2
  data> nycdc4.domain.com
    No match


Regards,
Henrik

-- 


Robert Herron
user-8b27ea4290da@xymon.invalid