Host group members and regex

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
hales8181
Posts: 33
Joined: Thu Jan 19, 2017 11:15 am

Host group members and regex

Post by hales8181 »

I'm trying to populate a hostgroup using wild cards but having a bit of difficulty.

My nagios.cfg has this set:
use_regexp_matching=1
use_true_regexp_matching=0

Hostgroup template:
define hostgroup {
hostgroup_name Regex testing
alias Regex testing
hostgroup_members ^Reg ExTest.*Environments
}

define hostgroup {
hostgroup_name Reg ExTest ABC Environments
alias Reg ExTest ABC Environments
}

And the results of this is that the hostgroup Regex testing has one hostgroup member that is "^Reg ExTest.*Environments" and a disabled hostgroup named "^Reg ExTest.*Environments" is created.

What is it that I'm doing wrong?
avandemore
Posts: 1597
Joined: Tue Sep 27, 2016 4:57 pm

Re: Host group members and regex

Post by avandemore »

Did you see this page?
https://assets.nagios.com/downloads/nag ... ricks.html
It states:
If you want regular expression matching to be used on all object names, enable the use_true_regexp_matching config option.
https://assets.nagios.com/downloads/nag ... p_matching

If you change that option, you'll need to restart or reload the nagios process to pick up the new config.
Previous Nagios employee
hales8181
Posts: 33
Joined: Thu Jan 19, 2017 11:15 am

Re: Host group members and regex

Post by hales8181 »

I've seen this - I've tried that but then if I want to exclude a host with an exclamation mark from a service I'm getting an error:

Error: Failed to expand host list '!testserver.testdomain.local' for service 'Drive F: Disk Usage'

I really don't want to be messing around with regex's - all I'm trying to do is match a group of other hostgroups that have the same beginning and the same ending - therefore just a wildcard in the middle.

How is the best way to accomplish this?
avandemore
Posts: 1597
Joined: Tue Sep 27, 2016 4:57 pm

Re: Host group members and regex

Post by avandemore »

I don't think regex can be used on hostgroup_members, only the members field.

I've filed this bug on it:
https://github.com/NagiosEnterprises/na ... issues/354
Previous Nagios employee
Locked