Page 1 of 1

Error when setting up a MSSQL Query monitor

Posted: Tue Sep 27, 2016 2:44 pm
by brettmlawrence
No output on stdout) stderr: /bin/sh: -c: line 0: unexpected EOF while looking for matching `"'

/bin/sh: -c: line 1: syntax error: unexpected end of file

really lost on this one.. Any help would be great.

Re: Error when setting up a MSSQL Query monitor

Posted: Tue Sep 27, 2016 2:50 pm
by mcapra
Can you show us the full check command definition you are using for this service as well as the output of that command run from the CLI?

Re: Error when setting up a MSSQL Query monitor

Posted: Tue Sep 27, 2016 2:59 pm
by brettmlawrence
check_xi_mssql_query!--username SVC_Nagios --password "Password" --database DATABASE --port 1433 --query "Select+Case+When+%28%09SELECT+COUNT%28%2A%29+%0D%0A%09%09%09%09%09FROM+HDMPMC_SHADOW.DBO.HDMA%29%0D%0A%09%09%09%09%09%3E+0+Then+%27Good%27+else+%27Bad%27%0D%0A%09%09%09%09%09end" --result "Good" --decode --result Good

Re: Error when setting up a MSSQL Query monitor

Posted: Tue Sep 27, 2016 3:32 pm
by rkennedy
Could you test it over the CLI and post the full input/output? It would be ran like this -

Code: Select all

/usr/local/nagios/libexec/check_mssql --username SVC_Nagios --password "Password" --database DATABASE --port 1433 --query "Select+Case+When+%28%09SELECT+COUNT%28%2A%29+%0D%0A%09%09%09%09%09FROM+HDMPMC_SHADOW.DBO.HDMA%29%0D%0A%09%09%09%09%09%3E+0+Then+%27Good%27+else+%27Bad%27%0D%0A%09%09%09%09%09end" --result "Good" --decode --result Good
Does the password contain any special characters?

One strange thing, is I'm unable to run it over the CLI using your query because of your username (the _). This might be a limitation for you. See below -

Code: Select all

[root@localhost libexec]# ./check_mssql -H 127.0.0.1 --username "SVC_Nagios" --password "Password" --database DATABASE --port 1433 --query "Select+Case+When+%28%09SELECT+COUNT%28%2A%29+%0D%0A%09%09%09%09%09FROM+HDMPMC_SHADOW.DBO.HDMA%29%0D%0A%09%09%09%09%09%3E+0+Then+%27Good%27+else+%27Bad%27%0D%0A%09%09%09%09%09end" --result "Good" --decode --result Good
UNKNOWN: Invalid characters in the username.

[root@localhost libexec]# ./check_mssql -H 127.0.0.1 --username "SVCNagios" --password "Password" --database DATABASE --port 1433 --query "Select+Case+When+%28%09SELECT+COUNT%28%2A%29+%0D%0A%09%09%09%09%09FROM+HDMPMC_SHADOW.DBO.HDMA%29%0D%0A%09%09%09%09%09%3E+0+Then+%27Good%27+else+%27Bad%27%0D%0A%09%09%09%09%09end" --result "Good" --decode --result Good
CRITICAL: Could not connect to 127.0.0.1:1433 as SVCNagios.

Re: Error when setting up a MSSQL Query monitor

Posted: Wed Sep 28, 2016 1:27 pm
by brettmlawrence
...$ /usr/local/nagios/libexec/check_xi_mssql_query! --username UPHS\SVC_Nagios --password "PW" --database HDMPMC_SHADOW --port 1433 --query "Select+Case+When+%28%09SELECT+COUNT%28%2A%29+%0D%0A%09%09%09%09%09FROM+HDMPMC_SHADOW.DBO.HDMA%29%0D%0A%09%09%09%09%09%3E+0+Then+%27Good%27+else+%27Bad%27%0D%0A%09%09%09%09%09end" --result "Good" --decode --result Good
-bash: !": event not found
...$ ./check_mssql -H 170.166.22.135 --username SVC_Nagios --password "PW" --database HDMPMC_SHADOW --port 1433 --query "Select+Case+When+%28%09SELECT+COUNT%28%2A%29+%0D%0A%09%09%09%09%09FROM+HDMPMC_SHADOW.DBO.HDMA%29%0D%0A%09%09%09%09%09%3E+0+Then+%27Good%27+else+%27Bad%27%0D%0A%09%09%09%09%09end" --result "Good" --decode --result Good
-bash: !": event not found

I received the same error when trying to run it using the command found on the configuration page as well as running it using the one you posted.

Re: Error when setting up a MSSQL Query monitor

Posted: Wed Sep 28, 2016 2:51 pm
by rkennedy
Judging by the error you received, I'm going to guess that there are symbols / special characters in your check. The way around this is to save your credentials to a variable, and then pass the variable as your password.

What you'll want to do, is use the resource.cfg file to save the password. See this link - https://assets.nagios.com/downloads/nag ... Macros.pdf

Then, when you run through the wizard (or even after), adjust the password field to be $USER#$ (where # is the macro # you use). This will tell XI to replace $USER9$ (for example) with 7&8!(|dasfs for example.

Re: Error when setting up a MSSQL Query monitor

Posted: Thu Sep 29, 2016 10:05 am
by brettmlawrence
Thank you! I am getting closer.. Am I able to pass Windows network accounts through this? I keep adding my domain \ User and the error is returning that it cannot connect.

Re: Error when setting up a MSSQL Query monitor

Posted: Thu Sep 29, 2016 10:56 am
by brettmlawrence
Thanks for all the help. I have this resolved! We can close this.

Re: Error when setting up a MSSQL Query monitor

Posted: Thu Sep 29, 2016 11:50 am
by dwhitfield
Glad to hear it is resolved. I am going to lock the tread. Please feel free to post again if you have you another issue. Thank you for using the Nagios forums!