check_mssql: Error CRITICAL: Could not execute the Query

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
paulconca
Posts: 31
Joined: Tue Jan 16, 2018 7:05 am

check_mssql: Error CRITICAL: Could not execute the Query

Post by paulconca »

Hi

I am doing some test as we may be moving from our current monitoring tool, to Nagios XI

The query is as follows: (works fine on our current monitoring tool and on the database)


select *****_*******.epr_id, *****_*******.app, *****_*******.Entity_ID, *****_*******.app_env, *****_*******_connect_expiry, *****_*******_connect_cn from *****_*******, *****_*******_connection where (*****_*******.tracking_id = *****_*******_.tracking_id and *****_*******.app_env = 'itg' ) and (*****_*******_connection.Validation_expiry between cast(getdate()as date) and dateadd(day,7,cast(getdate()as date)))

A simple query works so it is not a connection or access issue. :!:

Variations I have tried (Single quotes, double quotes, etc)

./check_mssql -H '**********.net' -U '****' -P *******' -I '***' -d 'master' -q select *****_*******.epr_id, *****_*******.app, *****_*******.Entity_ID, *****_*******.app_env, *****_*******_connect_expiry, *****_*******_connect_cn from *****_*******, *****_*******_connection where (*****_*******.tracking_id = *****_*******_.tracking_id and *****_*******.app_env = 'itg' ) and (*****_*******_connection.Validation_expiry between cast(getdate()as date) and dateadd(day,7,cast(getdate()as date)))

-bash: syntax error near unexpected token `('

"Eror CRITICAL: Could not execute the Query"for all the below
./check_mssql -H '**********.net' -U '****' -P *******' -I '***' -d 'master' -q "select *****_*******.epr_id, *****_*******.app_techlead, *****_*******.Entity_ID, *****_*******.app_env, *****_*******_expiry, *****_*******_connection.Validation_cn from *****_*******, *****_*******_connection where (*****_*******.tracking_id = *****_*******.tracking_id and *****_*******.app_env = 'itg' ) and (*****_*******_connect_expiry between cast(getdate()as date) and dateadd(day,7,cast(getdate()as date)))”

'select ‘*****_*******.epr_id, *****_*******.app_techlead, *****_*******.Entity_ID, *****_*******.app_env, *****_*******_connect_expiry, *****_*******_connect_cn from *****_*******, *****_*******_connection where (*****_*******.tracking_id = *****_*******_connecttrack_id and *****_*******.app_env = 'itg' ) and (*****_*******_connect.Valid_expiry between cast(getdate()as date) and dateadd(day,7,cast(getdate()as date)))’


select “’*****_*******.epr_id’, ‘*****_*******.app_techlead’, ‘*****_*******.Entity_ID’, ‘*****_*******.app_env’, ‘*****_*******_connect.Valid_expiry’, ‘*****_*******_connect._cn’ from ‘*****_*******’, ‘*****_*******_connection where’ (‘*****_*******.tracking_id’ = ‘*****_*******_connect.track_id’ and ‘*****_*******.app_env’ = 'itg' ) and (‘*****_*******_connect.Valid_expiry’ between cast(getdate()as date) and dateadd(day,7,cast(getdate()as date)))”

Any assistance is much appreciated
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: check_mssql: Error CRITICAL: Could not execute the Query

Post by mcapra »

Are there any SPs, views, or triggers included in this query's execution?

You could also try this Perl based plugin and see if it produces the same issues:
https://github.com/nagios-plugins/nagio ... k_mssql.pl
Former Nagios employee
https://www.mcapra.com/
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: check_mssql: Error CRITICAL: Could not execute the Query

Post by npolovenko »

Thanks, @mcapra!
@paulconca, Let us know if the check_mssql.pl plugin works for you.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
paulconca
Posts: 31
Joined: Tue Jan 16, 2018 7:05 am

Re: check_mssql: Error CRITICAL: Could not execute the Query

Post by paulconca »

That plugin does not seem to work at all, for me

/check_mssql.pl -H ******* -U '**********' -P '***************' -I '*********' -d '*********' -q "select getdate()"
-bash: ./check_mssql.pl: @PERL@: bad interpreter: No such file or directory

Tried this, but still not working
6 # Requires freetds and DBD::Sybase
7 # http://www.freetds.org
8 # http://www.mbay.net/~mpeppler/


Any ideas why the orginal ./check_mssql works for some queries and not others?

Thank you
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: check_mssql: Error CRITICAL: Could not execute the Query

Post by mcapra »

paulconca wrote:Any ideas why the orginal ./check_mssql works for some queries and not others?
Yes. Certain ODBC connection libs, specifically the ones used in the check_mssql PHP script, don't handle the following objects very gracefully in my experience:
mcapra wrote:Are there any SPs, views, or triggers included in this query's execution?
Understanding the underlying objects involved in the query would be useful in reproducing any "weirdness" with this plugin. Have you tried fiddling with the usage of GETDATE()? Either hard-coding the result or removing the call?
Former Nagios employee
https://www.mcapra.com/
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: check_mssql: Error CRITICAL: Could not execute the Query

Post by scottwilkerson »

paulconca wrote:That plugin does not seem to work at all, for me

/check_mssql.pl -H ******* -U '**********' -P '***************' -I '*********' -d '*********' -q "select getdate()"
-bash: ./check_mssql.pl: @PERL@: bad interpreter: No such file or directory
This error is because you cannot use the plugin without compiling them, it still has the @PERL@ at the top because you have not run configure on the nagios plugin package

https://support.nagios.com/kb/article.php?id=569
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked