[Xymon] HOST regex
Mills,David (HHSC Contractor)
David.Mills at hhsc.state.tx.us
Wed Dec 6 22:30:42 CET 2017
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>
~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
David Mills
Systems Administrator
Northrop Grumman
(512) 595-1238 (mobile)
From: Bakkies Gatvol [mailto:bakgat8 at hotmail.com]
Sent: Wednesday, December 6, 2017 2:36 PM
To: Root, Paul T <Paul.Root at CenturyLink.com>; Mills,David (HHSC Contractor) <David.Mills at hhsc.state.tx.us>; 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 <Paul.Root at CenturyLink.com<mailto:Paul.Root at CenturyLink.com>>
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:David.Mills at hhsc.state.tx.us]
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
(512) 595-1238 (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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.xymon.com/pipermail/xymon/attachments/20171206/6b476de2/attachment.html>
More information about the Xymon
mailing list