Page 1 of 1

configure DB failover log in Nagios XI

Posted: Tue Sep 24, 2019 11:12 pm
by pbachu2
Hi All,

Can anyone suggest if we can monitor the DB failover log in Nagios XI.

Regards,
Priyanka Bachu

Re: configure DB failover log in Nagios XI

Posted: Wed Sep 25, 2019 1:24 pm
by mbellerue
Is this a Microsoft SQL Server failover database? Is there a query or command that you run right now to find the failover status?

Re: configure DB failover log in Nagios XI

Posted: Wed Sep 25, 2019 11:36 pm
by pbachu2
Hi,

We are keeping stored procedure and declaring it in service in the host.cfg

Stored procedure : SP - exec [instance_stats].[dbo].[AGDetect]
Service command :
check_command check_mssql_health!TWRUAT.EXT!sql --name "`cat /etc/nagios/database-queries/dc1uat101-DB-AvailableGroups.sql`" --name2 'AvailableGroups' --critical "SECONDARY"
check_command check_mssql_health!TWRUAT.EXT!sql --name "`cat /etc/nagios/database-queries/dc1uat101-DB-AvailableGroups.sql`" --name2 'AvailableGroups' --units 'Results' --critical 'SECONDARY'


Requirement from user :
Below are the details of storeproc and servers.

SP - exec [instance_stats].[dbo].[AGDetect]
Server- DC1UAT101

Below is the snip for output of above storeproc. Configure alert on DC1UAT101, If value is PRIMARY, Set alert to Green / OK. If any value other than this, it should be CRITICAL.

Re: configure DB failover log in Nagios XI

Posted: Thu Sep 26, 2019 12:29 pm
by mbellerue
Okay, this looks great. You've got a single field that tells you whether the server is PRIMARY or SECONDARY. I've got a similar table and entry on my MS SQL system. Here's what it looks like when I run a check from the command line.

Code: Select all

/usr/local/nagios/libexec/check_mssql -H 192.168.145.90 --username "sa" --password "Temp1234" --database testnagios --port 1433 --query "select mytext from testtable" --decode --result "PRIMARY"

array(1) {
  [0]=>
  array(1) {
    ["mytext"]=>
    string(7) "PRIMARY"
  }
}
OK: Query results matched "PRIMARY", Query duration=0.000449 seconds.|query_duration=0.000449s;; 'mytext'=PRIMARY;
So in the above command, if the result from the query showed anything other than PRIMARY, it would go critical. Also, since you already have a stored procedure, you might try the stored procedure flag, rather than the --query flag.

-s, --storedproc Optional stored procedure to execute on MSSQL server.

Try that command out and see if it suits your needs.