Page 1 of 1
check_nt checking multiple services using regex
Posted: Tue Nov 24, 2020 4:35 am
by rhassing
Hello,
Is it possible to use regular expressions in check_nt to see if multiple services are running?
We have a lot of servers running services which all start whit the same three letters, but have different names on all servers.
Instead of creating all these different service check, I would like to create 1 service check to see which services are running starting with the three letters.
Best regards,
Rob Hassing
Re: check_nt checking multiple services using regex
Posted: Tue Nov 24, 2020 4:54 pm
by scottwilkerson
You should be able to do something like this to match all services that contain YYYYYY
Code: Select all
./check_nrpe -H HOST -u -t 30 -c check_service -a "filter=name like 'YYYYYY'"
Re: check_nt checking multiple services using regex
Posted: Wed Dec 16, 2020 2:53 am
by rhassing
When I try the command on the commandline, this works as expected.
But when I try the same command in Nagios XI it fails with: "Failed to validate filter see log for details: Filter expression is not valid: name like \'uds.c\'
I have tried the following as well:
-a filter=”name like \‘uds.c\’”
-a filter=”name like \"uds.c\"”
With the same result.
Does anyone have another suggestion?
Re: check_nt checking multiple services using regex
Posted: Wed Dec 16, 2020 10:31 am
by scottwilkerson
rhassing wrote:When I try the command on the commandline, this works as expected.
But when I try the same command in Nagios XI it fails with: "Failed to validate filter see log for details: Filter expression is not valid: name like \'uds.c\'
I have tried the following as well:
-a filter=”name like \‘uds.c\’”
-a filter=”name like \"uds.c\"”
With the same result.
Does anyone have another suggestion?
Rob,
Is it just failing when you run a test of the command from inside the CCM? There are some commands that just cannot work from there for security concerns, certain chars must be escaped when coming from a web GUI, this command has several of them. If you save the command as I showed you it should just work when Nagios executes it even though it fails through the CCM
Re: check_nt checking multiple services using regex
Posted: Thu Dec 17, 2020 3:56 am
by rhassing
Thank you Scott. That did the trick

Re: check_nt checking multiple services using regex
Posted: Thu Dec 17, 2020 8:07 am
by scottwilkerson
rhassing wrote:Thank you Scott. That did the trick

Great!
Locking thread