Excluding DB from mssql_health command-line

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
kithai
Posts: 11
Joined: Mon Nov 14, 2016 3:42 am

Excluding DB from mssql_health command-line

Post 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!!
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: Excluding DB from mssql_health command-line

Post 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?
kithai
Posts: 11
Joined: Mon Nov 14, 2016 3:42 am

Re: Excluding DB from mssql_health command-line

Post 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!!
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: Excluding DB from mssql_health command-line

Post by dwhitfield »

Unfortunately, you'll need to run separate checks for each DB if you want to exclude.
kithai
Posts: 11
Joined: Mon Nov 14, 2016 3:42 am

Re: Excluding DB from mssql_health command-line

Post 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
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Excluding DB from mssql_health command-line

Post 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?
Former Nagios Employee
Locked