host group regex revisited

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
esantora
Posts: 2
Joined: Sat Nov 17, 2018 8:18 am

host group regex revisited

Post by esantora »

Hello,

I've read through previous regex posts on here, but still haven't found a solution to my issue.

I have the following set in my nagios.cfg:

use_regexp_matching=1
use_true_regexp_matching=1

I'm using the following regex for hostgroup members:

^\w.*\.(sub1|sub2|sub3)\.?[\w.]*$

In Nagios, this matches:

host-a.sub1
host-b.sub2

but not:

host-c.sub1.example.com
host-d.sub2.example.com

I tested the regex on regex101.com and it matches both formats. Am I missing something in Nagios?

Any help would be greatly appreciated!

Thanks!
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: host group regex revisited

Post by cdienger »

the $ is a special character in Nagios configs and it looks like that is where the problem occurs. Try dropping it:

^\w.*\.(sub1|sub2|sub3)\.?[\w.]*
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked