Compare check_mssql result with today date

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
vusaravi
Posts: 23
Joined: Fri Mar 13, 2015 7:41 am

Compare check_mssql result with today date

Post by vusaravi »

Hi

We are using check_mssql plugin to monitor some db checks.

We have a new requirement to compare the result of the query with today's date.

Need some help in achieving the same.

Thanks in Advance.
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Compare check_mssql result with today date

Post by mcapra »

So you want to check a query's result against the current date?

Is there anything stopping you from doing that in the query itself?
https://stackoverflow.com/questions/103 ... odays-date

Then you could just have the query return 0 or something if the date is "correct" and use the --regex arg of check_mssql to match "0".
Former Nagios employee
https://www.mcapra.com/
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Compare check_mssql result with today date

Post by tmcdonald »

Thanks for the assist, @mcapra!
Former Nagios employee
vusaravi
Posts: 23
Joined: Fri Mar 13, 2015 7:41 am

Re: Compare check_mssql result with today date

Post by vusaravi »

Hi @mcapra

Thanks for your response.

My actual requirement is, my query will return response in data format (1 row) and now i want to compare the date with check_mssql whether it is today's date or not.

Finally i have modified the queries by using case and it is resolved.
Actual query:

Code: Select all

SELECT LAST_RUN_DATE from CRC
Modified Query:

Code: Select all

SELECT (CASE WHEN CAST(LAST_RUN_DATE AS DATE) = CAST(GETDATE() AS DATE) THEN 'SUCCESS' ELSE 'FAILED' END) AS NBWIP_REPORT_STATUS
FROM CRC
WHERE REPORT_CODE = 'NBWIPB'
You may close this ticket.
kyang

Re: Compare check_mssql result with today date

Post by kyang »

Sounds good! I'll be closing this thread!

If you have any more questions, feel free to create another thread.

Thanks for using the Nagios Support Forum!
Locked