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