Page 1 of 1
mssql query monitoring
Posted: Tue May 28, 2019 9:59 pm
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
Re: mssql query monitoring
Posted: Wed May 29, 2019 2:30 pm
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.
Re: mssql query monitoring
Posted: Wed May 29, 2019 2:38 pm
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.
Re: mssql query monitoring
Posted: Thu May 30, 2019 10:56 am
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 ""
Re: mssql query monitoring
Posted: Mon Jun 03, 2019 5:14 am
by mohan23
Query will result string data .it will not result number value .
Re: mssql query monitoring
Posted: Mon Jun 03, 2019 9:39 am
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.
Re: mssql query monitoring
Posted: Wed Jun 12, 2019 1:45 pm
by mohan23
Can you give me link to download check_mssql plugin script?
Re: mssql query monitoring
Posted: Wed Jun 12, 2019 2:37 pm
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