Page 1 of 1

Dollar in argument

Posted: Fri Apr 21, 2017 5:16 am
by WillemDH
Whatever combination I'm trying to make I'm unable to use a dollar in one of my arguments. I'm using "filter=start_type = 'auto'" and excluding the delayed services.
One of the problematic services is 'MSSQL$HPWJA'

So without escaping or double dollar:

Code: Select all

/usr/local/nagios/libexec/check_nrpe_v3 -2 -P 10240 -H hostname -t 30 -c check_service -a "filter=start_type = 'auto' and name not in ('Bonjour Service','clr_optimization_v4.0.30319_32','clr_optimization_v4.0.30319_64','DocAve 6 Report Service','DocAve 6 Media Service','gupdate','MSSQL$HPWJA','NetTcpPortSharing','RemoteRegistry','ShellHWDetection','sppsvc','stisvc','TBS','TrustedInstaller','wuauserv')"
CRITICAL: MSSQL$HPWJA=stopped (auto), delayed ()
With double dollar:

Code: Select all

/usr/local/nagios/libexec/check_nrpe_v3 -2 -P 10240 -H hostname -t 30 -c check_service -a "filter=start_type = 'auto' and name not in ('Bonjour Service','clr_optimization_v4.0.30319_32','clr_optimization_v4.0.30319_64','DocAve 6 Report Service','DocAve 6 Media Service','gupdate','MSSQL$$HPWJA','NetTcpPortSharing','RemoteRegistry','ShellHWDetection','sppsvc','stisvc','TBS','TrustedInstaller','wuauserv')"
CRITICAL: MSSQL$HPWJA=stopped (auto), delayed ()
With double backslash and double dollar:

Code: Select all

/usr/local/nagios/libexec/check_nrpe_v3 -2 -P 10240 -H hostname -t 30 -c check_service -a "filter=start_type = 'auto' and name not in ('Bonjour Service','clr_optimization_v4.0.30319_32','clr_optimization_v4.0.30319_64','DocAve 6 Report Service','DocAve 6 Media Service','gupdate','MSSQL\\$$HPWJA','NetTcpPortSharing','RemoteRegistry','ShellHWDetection','sppsvc','stisvc','TBS','TrustedInstaller','wuauserv')"
CRITICAL: MSSQL$HPWJA=stopped (auto), delayed ()
With single backslash and double dollar:

Code: Select all

/usr/local/nagios/libexec/check_nrpe_v3 -2 -P 10240 -H hostname -t 30 -c check_service -a "filter=start_type = 'auto' and name not in ('Bonjour Service','clr_optimization_v4.0.30319_32','clr_optimization_v4.0.30319_64','DocAve 6 Report Service','DocAve 6 Media Service','gupdate','MSSQL\$$HPWJA','NetTcpPortSharing','RemoteRegistry','ShellHWDetection','sppsvc','stisvc','TBS','TrustedInstaller','wuauserv')"
CRITICAL: MSSQL$HPWJA=stopped (auto), delayed ()
With double dollar in double quotes:

Code: Select all

/usr/local/nagios/libexec/check_nrpe_v3 -2 -P 10240 -H hostname -t 30 -c check_service -a "filter=start_type = 'auto' and name not in ('Bonjour Service','clr_optimization_v4.0.30319_32','clr_optimization_v4.0.30319_64','DocAve 6 Report Service','DocAve 6 Media Service','gupdate','MSSQL"$$"HPWJA','NetTcpPortSharing','RemoteRegistry','ShellHWDetection','sppsvc','stisvc','TBS','TrustedInstaller','wuauserv')"
CRITICAL: MSSQL$HPWJA=stopped (auto), delayed ()
Not sure why the double dollar doesn't work as multiple posts suggest that is the solution? (such as https://support.nagios.com/forum/viewto ... =7&t=11763) Please advice how to handle this problem.

Willem

Re: Dollar in argument

Posted: Fri Apr 21, 2017 11:51 am
by mcapra
I assume this is a check being run against NSClient++? Which version of NSClient++ are you using? I have been unable to replicate this with the older 2.15 version of check_nrpe or the newer 3.0.1 version of check_nrpe against an NSClient++ 0.5.0.62 machine. The \$ works as an escape sequence for me:

Code: Select all

[root@xi-stable /]# /usr/local/nagios/libexec/check_nrpe -H 192.168.67.99 -t 30 -c check_service -a "filter=start_type = 'auto' and name not in ('Bonjour Service','clr_optimization_v4.0.30319_32','clr_optimization_v4.0.30319_64','DocAve 6 Report Service','DocAve 6 Media Service','gupdate','MSSQL$HPWJA','NetTcpPortSharing','RemoteRegistry','ShellHWDetection','sppsvc','stisvc','TBS','TrustedInstaller','wuauserv')"
CRITICAL: RSyslogWindowsAgent=stopped (auto), MSSQL$HPWJA=stopped (auto), delayed ()

[root@xi-stable /]# /usr/local/nagios/libexec/check_nrpe -H 192.168.67.99 -t 30 -c check_service -a "filter=start_type = 'auto' and name not in ('Bonjour Service','clr_optimization_v4.0.30319_32','clr_optimization_v4.0.30319_64','DocAve 6 Report Service','DocAve 6 Media Service','gupdate','MSSQL\$HPWJA','NetTcpPortSharing','RemoteRegistry','ShellHWDetection','sppsvc','stisvc','TBS','TrustedInstaller','wuauserv')"
CRITICAL: RSyslogWindowsAgent=stopped (auto), delayed ()

[root@xi-stable /]# /usr/local/nagios/libexec/check_nrpe -H 192.168.67.99
I (0.5.0.62 2016-09-14) seem to be doing fine...

...

[root@xi-stable /]# /usr/local/nagios/libexec/check_nrpe -H 192.168.67.99 -t 30 -c check_service -a "filter=start_type = 'auto' and name not in ('Bonjour Service','clr_optimization_v4.0.30319_32','clr_optimization_v4.0.30319_64','DocAve 6 Report Service','DocAve 6 Media Service','gupdate','MSSQL$HPWJA','NetTcpPortSharing','RemoteRegistry','ShellHWDetection','sppsvc','stisvc','TBS','TrustedInstaller','wuauserv')"
CRITICAL: RSyslogWindowsAgent=stopped (auto), MSSQL$HPWJA=stopped (auto), delayed ()

[root@xi-stable /]# /usr/local/nagios/libexec/check_nrpe_v3 -H 192.168.67.99 -t 30 -c check_service -a "filter=start_type = 'auto' and name not in ('Bonjour Service','clr_optimization_v4.0.30319_32','clr_optimization_v4.0.30319_64','DocAve 6 Report Service','DocAve 6 Media Service','gupdate','MSSQL\$HPWJA','NetTcpPortSharing','RemoteRegistry','ShellHWDetection','sppsvc','stisvc','TBS','TrustedInstaller','wuauserv')"
CRITICAL: RSyslogWindowsAgent=stopped (auto), delayed ()
Though of course there will be slightly different escaping that needs to be done when setting it up in XI.

Re: Dollar in argument

Posted: Fri Apr 21, 2017 1:46 pm
by WillemDH
Nsclient 0.5.1.22, nrpe 3.0.1, XI 5.4

Re: Dollar in argument

Posted: Fri Apr 21, 2017 2:19 pm
by mcapra
Updated my NSClient++ to match yours, and still can't replicate:

Code: Select all

[root@xi-stable session]# /usr/local/nagios/libexec/check_nrpe -H 192.168.67.99
I (0.5.1.22 2017-04-06) seem to be doing fine...

[root@xi-stable session]# /usr/local/nagios/libexec/check_nrpe -H 192.168.67.99 -t 30 -c check_service -a "filter=start_type = 'auto' and name not in ('Bonjour Service','clr_optimization_v4.0.30319_32','clr_optimization_v4.0.30319_64','DocAve 6 Report Service','DocAve 6 Media Service','gupdate','MSSQL\$HPWJA2','NetTcpPortSharing','RemoteRegistry','ShellHWDetection','sppsvc','stisvc','TBS','TrustedInstaller','wuauserv')"
CRITICAL: RSyslogWindowsAgent=stopped (auto), delayed ()

[root@xi-stable session]# /usr/local/nagios/libexec/check_nrpe -H 192.168.67.99 -t 30 -c check_service -a "filter=start_type = 'auto' and name not in ('Bonjour Service','clr_optimization_v4.0.30319_32','clr_optimization_v4.0.30319_64','DocAve 6 Report Service','DocAve 6 Media Service','gupdate','MSSQL$HPWJA2','NetTcpPortSharing','RemoteRegistry','ShellHWDetection','sppsvc','stisvc','TBS','TrustedInstaller','wuauserv')"
CRITICAL: RSyslogWindowsAgent=stopped (auto), MSSQL$HPWJA2=stopped (auto), delayed ()
Though reading your OP, I don't see \$ used. I doubt that will be enough for the XI end of things, but does that work in your CLI executions?

Re: Dollar in argument

Posted: Fri Apr 21, 2017 3:27 pm
by WillemDH
Ok, started to doubt myself I did indeed not try \$ which does work in cli. So does it need an extra \ in XI CCM?

Re: Dollar in argument

Posted: Mon Apr 24, 2017 9:55 am
by mcapra
An extra $ actually. Here's what i've got for my $ARG2$ value using the default check_nrpe command:

Code: Select all

-a "filter=start_type = 'auto' and name not in ('Bonjour Service','clr_optimization_v4.0.30319_32','clr_optimization_v4.0.30319_64','DocAve 6 Report Service','DocAve 6 Media Service','gupdate','MSSQL\$$HPWJA2','NetTcpPortSharing','RemoteRegistry','ShellHWDetection','sppsvc','stisvc','TBS','TrustedInstaller','wuauserv')"
Which seems to be working.

Re: Dollar in argument

Posted: Wed Apr 26, 2017 10:37 am
by WillemDH
This works for me. Thanks alot. Please close.