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
check_nt checking multiple services using regex
check_nt checking multiple services using regex
Rob Hassing


-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: check_nt checking multiple services using regex
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
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?
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 Hassing


-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: check_nt checking multiple services using regex
Rob,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?
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
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: check_nt checking multiple services using regex
Great!rhassing wrote:Thank you Scott. That did the trick
Locking thread