ConSol-Monitoring / snclient

SNClient+ - Cross platform monitoring agent
MIT License
48 stars 9 forks source link

check_service - problem with changing default warning & critical arguments #82

Closed kafos closed 7 months ago

kafos commented 7 months ago

I need to get a warning, if a service on windows is disabled and stopped but this is not the default warning arguments. So I tried different variations to change the default warning arguments but in most cases I get only "UNKNOWN - unknown argument:"

./check_nrpe -H 10.8.0.108 -c check_service -a 'service="SERVICENAME"' - works fine but not for disabled services

./check_nrpe -H 10.8.0.108 -c check_service -a 'service="SERVICENAME" warning="state!=started"' does not work and I get "UNKNOWN - unknown argument:"

sni commented 7 months ago

it seems like check_nrpe splits the arguments by exclamation marks. But no idea why it does that.

Running this:

%> /omd/versions/default/lib/monitoring-plugins/check_nrpe -H 127.0.0.1 -p 5667 -n -D -c check_service -a service=snclient warn="state!=started"
UNKNOWN - unexpected end of condition after 'state'

in the debug log i see the arguments submitted wrong:

[2024-01-18 11:12:27.596][Trace][pid:1011233][listener:306] incoming nrpe connection from 127.0.0.1:42902
[2024-01-18 11:12:27.596][Trace][pid:1011233][listen_nrpe:105] nrpe v4 request: check_service []string{"service=snclient", "warn=state", "=started"}
[2024-01-18 11:12:27.597][Trace][pid:1011233][snclient:706] command: check_service
[2024-01-18 11:12:27.597][Trace][pid:1011233][snclient:707] args: []string{"service=snclient", "warn=state", "=started"}

So the second argument arrives as two separate arguments and without the !. This should be fixed in check_nrpe unless this is on purpose somehow.

Luckily snclient has a textual alias for each operator as documented here: https://omd.consol.de/docs/snclient/checks/filter/#operator

So you can use warn="state is not started" or warn="state ne started". Or switch to check_nsc_web instead of check_nrpe which also does not have this issue.