Page 1 of 1

Excluding DB from mssql_health command-line

Posted: Tue Nov 15, 2016 5:00 am
by kithai
Hi guys!

I would like to know if there's a possibility to excluding a db from mssql_health plugin. I mean, i'm using

Code: Select all

./check_mssql_health --hostname 192.168.1.1 --port 1433 --username $$$$$$ --password $$$$$$ --mode database-backup-age 24 --commit
And plugin works fine, but the problem is there's a db in the server (temdb) that won't be backuped, so the plugin is returning CRITICAL every time i launch it, obviously
There is a option (--name) that i suppose you can use to "select" the db's you want to include in the command line, but if I use:

Code: Select all

./check_mssql_health --hostname 192,168,1,1 --port 1433 --username $$$$$ --password $$$$$$$ --mode database-backup-age 24 --name tempdb, anotherdb, anotherdb2 --commit
And the plugin returns OK, that's not possible

Any idea what's going on or what can i do?

Thanks!!

Re: Excluding DB from mssql_health command-line

Posted: Tue Nov 15, 2016 12:36 pm
by dwhitfield
Does ./check_mssql_health --hostname 192,168,1,1 --port 1433 --username $$$$$ --password $$$$$$$ --mode database-backup-age 24 --name tempdb --commit work as expected?

Re: Excluding DB from mssql_health command-line

Posted: Wed Nov 16, 2016 2:55 am
by kithai
Hi!

Thanks for your reply! Yes, when I use

Code: Select all

--name "nameofjustoneDB"
Plugin works fine, returning me the backup datetime of the selected DB, and saying OK, Warning or Critical depending on the trheshold configured before. Problem starts when you put more than one DB after --name, the plugin returns just OK, with no datetime and no longer data.

I can configure a command line and a service for every single DB in the DB server, and just exclude the system's DB's, but I think that's not a smart solution because the plugin can return data of all DB's with just one command line and service.

But there's the problem, tempdb has not any backup (we don't want to) so plugin is returning CRITICAL every time

Any idea guys?

Thank you so much!!

Re: Excluding DB from mssql_health command-line

Posted: Wed Nov 16, 2016 10:14 am
by dwhitfield
Unfortunately, you'll need to run separate checks for each DB if you want to exclude.

Re: Excluding DB from mssql_health command-line

Posted: Thu Nov 17, 2016 4:15 am
by kithai
Thanks for your reply!!

I realized that i can use a bash script that can search on the plugins answer looking for the word "CRITICAL" or even all phrase "CRITICAL: database X was never backed up" for more security" and if there is just one critical (like in my case) return a "0" to nagios to print a holly green OK or if there is more than one critical, return "2" (no need for a "1" to warning) to print a scary red CRITICAL, including a personal phrase for each case. Of course, you are loosing the backup datetime show in web-interface, but if you just want to check if all is OK or you might be worry for something, this works like a charm when you are looking for backup ages

If somebody need something like this here's the incredible simple scripts that allows you that:

#!/bin/bash
critical_count=`/usr/local/nagios/libexec/check_mssql_health --server $1 --port --username --password --mode database-backup-age 24 --commit`

if [ $critical_count -eq 1 ] ; then
echo "OK! All backup age under 24h"
exit 0
else
echo "CRITICAL! One or more DB Backup age exceeds 24h"
exit 2
fi

Re: Excluding DB from mssql_health command-line

Posted: Thu Nov 17, 2016 11:19 am
by rkennedy
Wrapper scripts are fun once you realize how powerful they are for one off things like this. :) Thanks for sharing!

Are we good to mark this one up as resolved?