I didn't write the SQL nor the original service check I just know that these worked for two years and now don't so the burden now lies on me to get it working again. I am not able to change the SQL query but I can make whatever changes in Nagios to get it to work.
Here's the original SQL query that would return the number of minutes UTC between current and last entry in the table.
Code: Select all
DECLARE @min datetime
SELECT @min = fielddate FROM [CUSTOMER1DB1].[dbo].[TABLE1]
where TABLE1_id = (SELECT max(TABLE1_id)
FROM [CUSTOMER1DB1].[dbo].[TABLE1]
where app_id like '<P%')
select DATEDIFF (ss,@min, GETUTCDATE())Code: Select all
DECLARE+%40min+datetime%0D%0ASELECT+%40min+%3D+fielddate+FROM+%5BCUSTOMER1DB1%5D.%5Bdbo%5D.%5BTABLE1%5D++%0D%0Awhere+TABLE1_id+%3D+%28SELECT+max%28TABLE1_id%29++%0D%0AFROM+%5BCUSTOMER1DB1%5D.%5Bdbo%5D.%5BTABLE1%5D++%0D%0Awhere+app_id+like+%27%3CP%25%27%29%0D%0Aselect+DATEDIFF+%28ss%2C%40min%2C+GETUTCDATE%28%29%29Code: Select all
-H X.X.X.X --username "XXX" --password "XXX" --database master --instance XXXX --query "DECLARE+%40min+datetime%0D%0ASELECT+%40min+%3D+fielddate+FROM+%5BCUSTOMER1DB1%5D.%5Bdbo%5D.%5BTABLE1%5D++%0D%0Awhere+TABLE1_id+%3D+%28SELECT+max%28TABLE1_id%29++%0D%0AFROM+%5BCUSTOMER1DB1%5D.%5Bdbo%5D.%5BTABLE1%5D++%0D%0Awhere+app_id+like+%27%3CP%25%27%29%0D%0Aselect+DATEDIFF+%28ss%2C%40min%2C+GETUTCDATE%28%29%29" --result "" --decode --warning 60 --critical 90 --querywarning 45000 --querycritical 86400Code: Select all
-H X.X.X.X --username "XXX" --password "XXX" --database master --instance XXXX --query "THIS QUERY" --result "" --decode --warning 60 --critical 90 --querywarning 45000 --querycritical 86400