Nagios Regex exclusion

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
mickp
Posts: 1
Joined: Wed Oct 12, 2016 9:37 am

Nagios Regex exclusion

Post by mickp »

I have some hosts - they are being included in a group by regex.

The group includes some db hosts, which I don't want to see.

Take these hostnames as examples:

mickp1env1-app1-1-dc1
mickp1env1-apache1-1-dc1
mickp1-db1-1-dc1
mickp1env1-apache2-1-dc1


My group is defined as follows:

Code: Select all

define hostgroup{
        hostgroup_name  mickp1
        alias           All mickp1 hosts
       members          mickp1.*
}
However, I don't want to see the db hosts in this group - it's for another team and they don't care about db hosts.

So, using regexr.com, I pasted the above hostnames into the free text box, then in the top I used this expression:

mickp1(?!-db).*

And it works, it finds everything except the db host.


However, when I replace mickp1.* with this in the hostgroups file, it fails. I get this error:

Code: Select all

Error: Could not expand members specified in hostgroup (config file '/etc/nagios/hosts/hostgroups.cfg', starting on line 231)
   Error processing object config files!

I have also tried the a positive lookup, so find them all - but not the db hosts:

members mickp1.*, !mickp1(?-db).*

This does not generate any error - and nagios reloads fine, but it still does not exclude.


I have tried this with with these settings:

Code: Select all

1. use_regexp_matching=1, use_true_regexp_matching=0
2. use_regexp_matching=1, use_true_regexp_matching=1
3. use_regexp_matching=0, use_true_regexp_matching=1
Nothing works.

Anyone got any ideas on what I'm doing wrong? Is it as basic as the exclusion from a group has to be another group name and not another rexgex? Or that in my first example, Nagios prefers to find rather than exclude?

Please help.....

Mick.
Last edited by mickp on Thu Oct 13, 2016 2:15 am, edited 2 times in total.
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: Nagios Regex exclusion

Post by dwhitfield »

Can you post /etc/nagios/hosts/hostgroups.cfg?
Locked