ConSol-Monitoring / snclient

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

Windows Service Monitoring not possible if Service-Name has spaces #107

Closed Stefan-Hoesl closed 3 months ago

Stefan-Hoesl commented 3 months ago

I am using following command line to check "my WinSerice" on Host myWinHost:

check_nsc_web -config /.../check_nsc_web.config -k -query "check_service service=my WinService" -u https://myWinhHst:8443
UNKNOWN - unknown argument: WinService

If I use %20 instead of space I get the following:

check_nsc_web -config /.../check_nsc_web.config -k -query "check_service service=my%20WinService" -u https://myWinHost:8443
UNKNOWN - failed to open service my%20WinService: failed to find service name my%20WinService: The specified service does not exist as an installed service.

How can I check Windows Services with spaces in Service-Names?

sni commented 3 months ago

%20 is url encoded and definitly not intended to work. What should work is: ... check_service service='my WinService' ...

You need to put text i quotes if it contains spaces. If that doesn't work, then it is a bug.

Stefan-Hoesl commented 3 months ago

Still get the same error when putting Servicename in single quotes:

check_nsc_web -config /.../check_nsc_web.config -k -query "check_service service='my WinService'" -u https://myWinhHst:8443
UNKNOWN - unknown argument: WinService
sni commented 3 months ago

You don't need -query, the shell otherwise removes some of the quotes, just do:

./check_nsc_web -p test -k -u "https://192.168.56.10:8443" check_service service='my WinService'
UNKNOWN - failed to open service my WinService: failed to find service name my WinService
Stefan-Hoesl commented 3 months ago

Thank you that fixed it. Even the check parameters have to be at the end of the command.