mssql query monitoring

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
mohan23
Posts: 118
Joined: Tue Oct 03, 2017 7:11 am

mssql query monitoring

Post by mohan23 »

I have a mssql query where query returns backup history of all database nodes for which backup has not happened for more than 1 day and output contains database name and time frame of backup last happened. Now I need a script to monitor mssql query and trigger critical state alert when query returns any output and if query returns null script should show ok.

Appreciate quick help here
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: mssql query monitoring

Post by cdienger »

The /usr/local/nagios/libexec/check_mssql plugin may be able to help here. It may be easier to work with a count of databases that don't have a backup. The example provided in check_mssql's help has:

Code: Select all

check_mssql -H myserver -U myuser -P mypass -q "SELECT COUNT(*) FROM mytable" -r "632" -c 10 -W 2 -C 5
Test this from the command line first and then once that works you can use the MS SQL wizard to create a check in the XI UI.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
mohan23
Posts: 118
Joined: Tue Oct 03, 2017 7:11 am

Re: mssql query monitoring

Post by mohan23 »

If query returns numeric value, script provided by you will work.

But my query itself will Returns string data + date . I want to alert them if query returns any output and if query returns null I want to show ok.
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: mssql query monitoring

Post by cdienger »

Have you tested anything with the check_mssql plugin? From my testing, this looks like it should do the trick:

/usr/local/nagios/libexec/check_mssql -H DATABASEIP --username "USERNAME" --password "PASSWORD" --database DATABASENAME --port 1433 --query "YOURQUERY" --decode --warning 50 --critical 200 --result ""
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
mohan23
Posts: 118
Joined: Tue Oct 03, 2017 7:11 am

Re: mssql query monitoring

Post by mohan23 »

Query will result string data .it will not result number value .
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: mssql query monitoring

Post by cdienger »

Correct, the last query I provided will result in a string being returned. It checks to see if a string is returned and if there is one returned it will trigger a CRITICAL. If nothing is returned it will be OK.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
mohan23
Posts: 118
Joined: Tue Oct 03, 2017 7:11 am

Re: mssql query monitoring

Post by mohan23 »

Can you give me link to download check_mssql plugin script?
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: mssql query monitoring

Post by lmiltchev »

The check_mssql plugin is installed by default in Nagios XI. You should have it on your system... You can confirm that by running:

Code: Select all

/usr/local/nagios/libexec/check_mssql -h
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked