Page 1 of 1

Host group members and regex

Posted: Wed Mar 29, 2017 6:02 am
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?

Re: Host group members and regex

Posted: Wed Mar 29, 2017 9:41 am
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.

Re: Host group members and regex

Posted: Wed Mar 29, 2017 9:55 am
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?

Re: Host group members and regex

Posted: Wed Mar 29, 2017 11:52 am
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