Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request - Support wildcards in exclude arguments #282

Open
ne-lgute opened this issue Feb 2, 2024 · 9 comments
Open

Feature Request - Support wildcards in exclude arguments #282

ne-lgute opened this issue Feb 2, 2024 · 9 comments

Comments

@ne-lgute
Copy link

ne-lgute commented Feb 2, 2024

When services need to be excluded, and the service name includes things like version numbers, the exclude argument needs to be changed every time the version number is updated.

Add support for wild cards and/or head/tail type matching rules, so the exclude argument does not need to be changed.

define command {
    command_name check_some_services
    command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -t 60 -c CheckServiceState -a CheckAlc 
    exclude=XYZService122.0.6253.9 exclude=$ARG1$ exclude=$ARG2$ exclude=$ARG3$ exclude=$ARG4$ exclude=$ARG5$
}
@smithmich
Copy link

Can the number part of this service somehow be matched with regex? I can't figure it out.
GoogleUpdaterInternalService124.0.6315.0

@smithmich
Copy link

This does not work in Nagios but it does match in regex calculator tests so maybe NRPE doesn't allow this regex expression.
GoogleUpdaterService[0-9]{1,3}.[0-9]{1,2}.[0-9]{1,4}.[0-9]{1,2}
or
^GoogleUpdaterService[0-9]{1,3}.[0-9]{1,2}.[0-9]{1,4}.[0-9]{1,2}$

@bunste
Copy link

bunste commented Feb 26, 2024

Did you try to use the filter argument?

filter=(name not regexp str(GoogleUpdater.*))

@smithmich
Copy link

smithmich commented Feb 26, 2024 via email

@bunste
Copy link

bunste commented Feb 26, 2024

Here is what what works for me. To exclude a service by name:

./check_nrpe -H IP_ADDRESS -c check_service -a 'exclude=gupdate'

Lets say the output (CRITICAL) lists both GoogleUpdaterInternalService124.0.6315.0 and GoogleUpdaterService124.0.6315.0

Then I can get rid off those two services with the following regex:

./check_nrpe -H IP_ADDRESS -c check_service -a 'exclude=gupdate!filter=(name not regexp str(GoogleUpdater.*))'

Using NRPE Plugin for Nagios version: 4.0.3

@smithmich
Copy link

OK I'm getting this error now running Nagios core 4.5.0
Failed to open service filter: 424: The specified service does not exist as an installed service.
Here is my check command: It's in test environment but mirrors production with many exclusions..
define command{
command_name check_some_services
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -t 60 -c CheckServiceState -a CheckAll exclude=RemoteRegistry exclude=wuauserv exclude=sppsvc exclude=gpsvc exclude=TrustedInstaller exclude=MapsBroker exclude=gupdate exclude=WbioSrvc exclude=CDPSvc exclude=tiledatamodelsvc exclude=BITS exclude=mfemms exclude=mfevtp exclude=ccmsetup exclude=edgeupdate exclude=WinDefend exclude=vm3dservice 'exclude=gupdate!filter=(name not regexp str(GoogleUpdater.*))' exclude=$ARG1$ exclude=$ARG2$ exclude=$ARG3$ exclude=$ARG4$ exclude=$ARG5$
}

@smithmich
Copy link

Update working. I was using the legacy CheckServiceStatus. I switched to the Check_Service and was able to filter the Google services like this:
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -t 60 -c Check_Service -a "filter=name not like 'Google'" exclude=RemoteRegistry exclude=wuauserv exclude=sppsvc exclude=gpsvc exclude=TrustedInstaller exclude=MapsBroker exclude=gupdate exclude=WbioSrvc exclude=CDPSvc exclude=tiledatamodelsvc exclude=BITS exclude=mfemms exclude=mfevtp exclude=ccmsetup exclude=edgeupdate exclude=WinDefend exclude=vm3dservice exclude=$ARG1$ exclude=$ARG2$ exclude=$ARG3$ exclude=$ARG4$ exclude=$ARG5$ #

Reference: https://nsclient.org/docs/reference/windows/CheckSystem/#check_service_filter

@bambaleon
Copy link

Hello. Where should i put this filter? Can you provide short manual, please?

@smithmich
Copy link

This line is in the /usr/local/nagios/etc/objects/commands.cfg file.
On the host I have this to call it:
define service {
use generic-service ;
host_name HOSTNAME ;
service_description AllAutomatic Services ;
servicegroups Service ;
check_command check_some_services!mfevtp!TrustedInstaller ;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants