Xymon Mailing List Archive search

HOST regex

5 messages in this thread

list Paul Root · Mon, 4 Dec 2017 20:45:37 +0000 ·
I'm having trouble getting a regex going for hostnames in analysis.cfg

I've got machines   iadncmds1  through iadncmds6 and iadccmds1 through iadncmds9 and a couple other machines, all should/will have the same things to look at (ports, procs, etc).

I've tried the following:
HOST=%iad(ncm|ccm)ds(1-9),apancmdsd1,iadncmdsd2
HOST=%iad(ncm|ccm)ds\d,apancmdsd1,iadncmdsd2
HOST=%iad(ncm|ccm)ds.*,apancmdsd1,iadncmdsd2
HOST=%iad(ncm|ccm)ds(.*),apancmdsd1,iadncmdsd2

Any help here?

Thanks,
Paul.


This communication is the property of CenturyLink and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments.
list David Mills · Mon, 4 Dec 2017 20:55:40 +0000 ·
Paul -

As far as just the Perl RE goes, use this:

(iadncmds[1-6])|( iadccmds1[1-9])|...

So, in analysis.cfg: HOST=%(iadncmds[1-6])|( iadccmds1[1-9])| ...   # Where the "|..." includes the rest of your hosts, following a similar pattern

Use "[]"s to specify a range of numbers, not parens...

$  perl -e 'for ($i = 0; $i <= 7; $i ++ ) { if ( "iadncmds$i" =~ /iadncmds[1-6]/ ) { print "This matches: iadncmds$i\n" } else { print "iadncmds$i does not match...\n" } }'
iadncmds0 does not match...
This matches: iadncmds1
This matches: iadncmds2
This matches: iadncmds3
This matches: iadncmds4
This matches: iadncmds5
This matches: iadncmds6
iadncmds7 does not match...


~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
David Mills
Systems Administrator
Northrop Grumman
(XXX) XXX-XXXX (mobile)
quoted from Paul Root

From: Xymon [mailto:xymon-bounces at xymon.com] On Behalf Of Root, Paul T
Sent: Monday, December 4, 2017 2:46 PM
To: xymon at xymon.com
Subject: [Xymon] HOST regex

I'm having trouble getting a regex going for hostnames in analysis.cfg

I've got machines   iadncmds1  through iadncmds6 and iadccmds1 through iadncmds9 and a couple other machines, all should/will have the same things to look at (ports, procs, etc).

I've tried the following:
HOST=%iad(ncm|ccm)ds(1-9),apancmdsd1,iadncmdsd2
HOST=%iad(ncm|ccm)ds\d,apancmdsd1,iadncmdsd2
HOST=%iad(ncm|ccm)ds.*,apancmdsd1,iadncmdsd2
HOST=%iad(ncm|ccm)ds(.*),apancmdsd1,iadncmdsd2

Any help here?

Thanks,
Paul.


This communication is the property of CenturyLink and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments.
list Paul Root · Mon, 4 Dec 2017 21:17:01 +0000 ·
Ah, I see, I was adding more machines with a , after the regex, but that's treated as part of the regex, and the [] vs () for numbers.

Thanks,
Paul.
quoted from David Mills

From: Mills,David (HHSC Contractor) [mailto:user-7037272ac73f@xymon.invalid]
Sent: Monday, December 04, 2017 2:56 PM
To: Root, Paul T; xymon at xymon.com
Subject: RE: HOST regex

Paul -

As far as just the Perl RE goes, use this:

(iadncmds[1-6])|( iadccmds1[1-9])|...

So, in analysis.cfg: HOST=%(iadncmds[1-6])|( iadccmds1[1-9])| ...   # Where the "|..." includes the rest of your hosts, following a similar pattern

Use "[]"s to specify a range of numbers, not parens...

$  perl -e 'for ($i = 0; $i <= 7; $i ++ ) { if ( "iadncmds$i" =~ /iadncmds[1-6]/ ) { print "This matches: iadncmds$i\n" } else { print "iadncmds$i does not match...\n" } }'
iadncmds0 does not match...
This matches: iadncmds1
This matches: iadncmds2
This matches: iadncmds3
This matches: iadncmds4
This matches: iadncmds5
This matches: iadncmds6
iadncmds7 does not match...


~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
David Mills
Systems Administrator
Northrop Grumman
(XXX) XXX-XXXX (mobile)

From: Xymon [mailto:xymon-bounces at xymon.com] On Behalf Of Root, Paul T
Sent: Monday, December 4, 2017 2:46 PM
To: xymon at xymon.com<mailto:xymon at xymon.com>
Subject: [Xymon] HOST regex

I'm having trouble getting a regex going for hostnames in analysis.cfg

I've got machines   iadncmds1  through iadncmds6 and iadccmds1 through iadncmds9 and a couple other machines, all should/will have the same things to look at (ports, procs, etc).

I've tried the following:
HOST=%iad(ncm|ccm)ds(1-9),apancmdsd1,iadncmdsd2
HOST=%iad(ncm|ccm)ds\d,apancmdsd1,iadncmdsd2
HOST=%iad(ncm|ccm)ds.*,apancmdsd1,iadncmdsd2
HOST=%iad(ncm|ccm)ds(.*),apancmdsd1,iadncmdsd2

Any help here?

Thanks,
Paul.


This communication is the property of CenturyLink and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments.
This communication is the property of CenturyLink and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments.
list Bakkies Gatvol · Wed, 6 Dec 2017 20:36:23 +0000 ·
Please help me too!


aburtssom01.auca.corp
aburtssom02.auca.corp
aburtssom03.auca.corp
aburtssom04.auca.corp

astptoemm01.auca.corp

aburtssom01.auca.corp
aburtssom02.auca.corp
aburtssom03.auca.corp
aburtssom04.auca.corp


HOST=%((a(burt|scop)ssom0(1|2).auca.corp)|astptoemm01.auca.corp)


will this work?


and then how to I exclude it from a CLASS lower down?


CLASS=linux EXHOST=%*.auca.corp


could I


CLASS=linux EXHOST=%((a(burt|scop)ssom0(1|2).auca.corp)|astptoemm01.auca.corp)
quoted from Paul Root


From: Xymon <xymon-bounces at xymon.com> on behalf of Root, Paul T <user-76fdb6883669@xymon.invalid>
Sent: Monday, December 4, 2017 4:17 PM
To: 'Mills,David (HHSC Contractor)'; xymon at xymon.com
Subject: Re: [Xymon] HOST regex


Ah, I see, I was adding more machines with a , after the regex, but that’s treated as part of the regex, and the [] vs () for numbers.


Thanks,

Paul.


From: Mills,David (HHSC Contractor) [mailto:user-7037272ac73f@xymon.invalid]
Sent: Monday, December 04, 2017 2:56 PM
To: Root, Paul T; xymon at xymon.com
Subject: RE: HOST regex


Paul –


As far as just the Perl RE goes, use this:


(iadncmds[1-6])|( iadccmds1[1-9])|…


So, in analysis.cfg: HOST=%(iadncmds[1-6])|( iadccmds1[1-9])| …   # Where the “|…” includes the rest of your hosts, following a similar pattern


Use “[]”s to specify a range of numbers, not parens…


$  perl -e 'for ($i = 0; $i <= 7; $i ++ ) { if ( "iadncmds$i" =~ /iadncmds[1-6]/ ) { print "This matches: iadncmds$i\n" } else { print "iadncmds$i does not match...\n" } }'

iadncmds0 does not match...

This matches: iadncmds1

This matches: iadncmds2

This matches: iadncmds3

This matches: iadncmds4

This matches: iadncmds5

This matches: iadncmds6

iadncmds7 does not match...


~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~

David Mills
Systems Administrator
Northrop Grumman
(XXX) XXX-XXXX (mobile)


From: Xymon [mailto:xymon-bounces at xymon.com] On Behalf Of Root, Paul T
Sent: Monday, December 4, 2017 2:46 PM
To: xymon at xymon.com<mailto:xymon at xymon.com>
Subject: [Xymon] HOST regex


I’m having trouble getting a regex going for hostnames in analysis.cfg


I’ve got machines   iadncmds1  through iadncmds6 and iadccmds1 through iadncmds9 and a couple other machines, all should/will have the same things to look at (ports, procs, etc).


I’ve tried the following:

HOST=%iad(ncm|ccm)ds(1-9),apancmdsd1,iadncmdsd2

HOST=%iad(ncm|ccm)ds\d,apancmdsd1,iadncmdsd2

HOST=%iad(ncm|ccm)ds.*,apancmdsd1,iadncmdsd2

HOST=%iad(ncm|ccm)ds(.*),apancmdsd1,iadncmdsd2


Any help here?


Thanks,

Paul.


This communication is the property of CenturyLink and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments.

This communication is the property of CenturyLink and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments.
list David Mills · Wed, 6 Dec 2017 21:30:42 +0000 ·
Bakkies -

Hi!

My personal policy in writing Perl regex's in analysis.cfg is to balance the power of covering many hosts using a complex regex with the need to keep these same regex's not too complex to be easy to maintain. In other words, IMHO, it might be better to break a response rule in analysis.cfg (i.e. a HOST=%... stanza) into two or more stanzas for readability/maintainability.

Having said that, I would match all the "aburtssom*" hosts and the "astptoemm*" host using this trigger:

HOST=%(aburtssom0[1-4].auca.corp)|(astptoemm01.auca.corp)
...

To match all the hosts indicated (if I'm guessing correctly at your intention) in your sample regex, I'd probably do something like this to avoid the complexity of nesting parenthetical expressions:

HOST=%(aburtssom0[1-4].auca.corp)|(ascopssom0[12].auca.corp)|( astptoemm01.auca.corp)
...

This will match:
aburtssom01.auca.corp - aburtssom04.auca.corp
ascopssom01.auca.corp and ascopssom02.auca.corp, and
astptoemm01.auca.corp

I'll leave the exclusion part of your question to someone more clever than I! <smile>
quoted from Bakkies Gatvol

~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
David Mills
Systems Administrator
Northrop Grumman
(XXX) XXX-XXXX (mobile)

From: Bakkies Gatvol [mailto:user-66e2e196cd54@xymon.invalid]
Sent: Wednesday, December 6, 2017 2:36 PM
To: Root, Paul T <user-76fdb6883669@xymon.invalid>; Mills,David (HHSC Contractor) <user-7037272ac73f@xymon.invalid>; xymon at xymon.com
Subject: Re: HOST regex


Please help me too!


aburtssom01.auca.corp
aburtssom02.auca.corp
aburtssom03.auca.corp
aburtssom04.auca.corp

astptoemm01.auca.corp

aburtssom01.auca.corp
aburtssom02.auca.corp
aburtssom03.auca.corp
aburtssom04.auca.corp


HOST=%((a(burt|scop)ssom0(1|2).auca.corp)|astptoemm01.auca.corp)


will this work?


and then how to I exclude it from a CLASS lower down?


CLASS=linux EXHOST=%*.auca.corp


could I


CLASS=linux EXHOST=%((a(burt|scop)ssom0(1|2).auca.corp)|astptoemm01.auca.corp)


From: Xymon <xymon-bounces at xymon.com<mailto:xymon-bounces at xymon.com>> on behalf of Root, Paul T <user-76fdb6883669@xymon.invalid<mailto:user-76fdb6883669@xymon.invalid>>
Sent: Monday, December 4, 2017 4:17 PM
To: 'Mills,David (HHSC Contractor)'; xymon at xymon.com<mailto:xymon at xymon.com>
Subject: Re: [Xymon] HOST regex


Ah, I see, I was adding more machines with a , after the regex, but that's treated as part of the regex, and the [] vs () for numbers.


Thanks,

Paul.


From: Mills,David (HHSC Contractor) [mailto:user-7037272ac73f@xymon.invalid]
Sent: Monday, December 04, 2017 2:56 PM
To: Root, Paul T; xymon at xymon.com<mailto:xymon at xymon.com>
Subject: RE: HOST regex


Paul -


As far as just the Perl RE goes, use this:


(iadncmds[1-6])|( iadccmds1[1-9])|...


So, in analysis.cfg: HOST=%(iadncmds[1-6])|( iadccmds1[1-9])| ...   # Where the "|..." includes the rest of your hosts, following a similar pattern


Use "[]"s to specify a range of numbers, not parens...


$  perl -e 'for ($i = 0; $i <= 7; $i ++ ) { if ( "iadncmds$i" =~ /iadncmds[1-6]/ ) { print "This matches: iadncmds$i\n" } else { print "iadncmds$i does not match...\n" } }'

iadncmds0 does not match...

This matches: iadncmds1

This matches: iadncmds2

This matches: iadncmds3

This matches: iadncmds4

This matches: iadncmds5

This matches: iadncmds6

iadncmds7 does not match...


~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~

David Mills
Systems Administrator
Northrop Grumman
(XXX) XXX-XXXX (mobile)


From: Xymon [mailto:xymon-bounces at xymon.com] On Behalf Of Root, Paul T
Sent: Monday, December 4, 2017 2:46 PM
To: xymon at xymon.com<mailto:xymon at xymon.com>
Subject: [Xymon] HOST regex


I'm having trouble getting a regex going for hostnames in analysis.cfg


I've got machines   iadncmds1  through iadncmds6 and iadccmds1 through iadncmds9 and a couple other machines, all should/will have the same things to look at (ports, procs, etc).


I've tried the following:

HOST=%iad(ncm|ccm)ds(1-9),apancmdsd1,iadncmdsd2

HOST=%iad(ncm|ccm)ds\d,apancmdsd1,iadncmdsd2

HOST=%iad(ncm|ccm)ds.*,apancmdsd1,iadncmdsd2

HOST=%iad(ncm|ccm)ds(.*),apancmdsd1,iadncmdsd2


Any help here?


Thanks,

Paul.


This communication is the property of CenturyLink and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments.
This communication is the property of CenturyLink and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments.