We're here to help!

Monitoring Dbvisit Standby with Nagios(Standby Version 7.0)

Follow
Description

Please see the following KB article which discusses, more generally, approaches to monitoring Dbvisit Standby:

http://support.dbvisit.com/hc/en-us/articles/216296578-Monitoring-Standby

The following script, to monitor Dbvisit Standby with Nagios, was contributed by a customer and the original discussion can be found HERE. This is not maintained by Dbvisit and is provided only as an example.

First we need sudo privileges if not already enabled. Edit the /etc/sudoers and add the following entry under User privilege specification:

nagios ALL=(oracle) NOPASSWD: /usr/local/dbvisit/dbv_oraStartStop

This is needed because the script (dbv_oraStartStop) only works under the user oracle. Next copy the lines below and save it under check_dbvisit in your nagios/lib/plugins directory and make it executable:

Script
#!/bin/sh
# michael(at)weckerlein-edv.de
# 03/14/2007
# This Nagios plugin was created to check Dbvisit Standby technology status.

PROGNAME=basename $0
PROGPATH=echo $0 | sed -e 's,[\\/][^\\/][^\\/]\*$,,'
REVISION=echo '$Revision: 1.00 $' | sed -e 's/[^0-9.]//g'
. $PROGPATH/utils.sh
print_usage() {
  echo "Usage:"
  echo " $PROGNAME --status <ORACLE\_SID>"
  echo " $PROGNAME --help"
  echo " $PROGNAME --version"
}
print_help() {
  print_revision $PROGNAME $REVISION
  echo ""
  print_usage
  echo ""
  echo "Check DBVISIT status"
  echo ""
  echo "--status SID"
  echo " Check the state of the Database"
  echo " and print out the state standby or Primary"
}
case "$1" in
  1)
  cmd='--status'
  ;;
  *)
  cmd="$1"
  ;;
esac

# Information Options
case "$cmd" in
  --help)
  print_help
  exit $STATE_OK
  ;;
  -h)
  print_help
  exit $STATE_OK
  ;;
  --version)
  print_revision $PLUGIN $REVISION
  exit $STATE_OK
  ;;
  -V)
  print_revision $PLUGIN $REVISION
  exit $STATE_OK
  ;;
esac
case "$cmd" in
  --status)
  dbvchk=sudo -u oracle /usr/local/dbvisit/dbv\_oraStartStop status $2
  dbvchk2=echo $dbvchk | grep -c up
  if [ ${dbvchk2} -eq 1 ] ; then
    dbvchk3=`sudo -u oracle /usr/local/dbvisit/dbv_oraStartStop status $2 |
    echo "OK - $dbvchk3"
    exit $STATE_OK
  else
    dbvchk3=`sudo -u oracle /usr/local/dbvisit/dbv_oraStartStop status $2 |
    echo "ERROR - $dbvchk3"
    exit $STATE_CRITICAL
  fi
  ;;
esac

Edit your Nagios configuration file (normally it is /etc/nagios2/command.cfg). Make a new command entry check_dbvist --status $ARG1$ like this:

define command {
  command_name check_dbvisit
  command_line $USER1$/check_dbvisit --status $ARG1$
}

In your host configuration add a service entry like this:

#Check Oracle DB <SID> DBVISIT state
define service{
  use generic-service ; Name of service template to use
  host_name oracle1
  service_description ORACLE STANDBY STATE
  check_command check_dbvisit!<SID>
}

Change the <SID> with your database name. When using NRPE edit the /etc/nagios/nrpe.cfg file and add the command:

command[check_dbvisit]=/usr/lib/nagios/plugins/check_dbvisit --status <SID>

and add on your Nagios Masterserver a service entry:

#Check Oracle DB <SID> DBVISIT state
define service{
  use generic-service ; Name of service template to use
  host_name oracle1
  service_description ORACLE STANDBY STATE
  check_command check_nrpe!check_dbvisit
}

When you use the check_oracle.sh plugin you get errors on the Standby Database because its not open and no login was accepted. I have managed this by adding a few lines in the script. At line 177 add:

--login)
if [ -f /usr/local/dbvisit/dbvisit ]; then
  dbvchk=sudo -u oracle /usr/local/dbvisit/dbv\_oraStartStop status $2
  dbvchk2=echo $dbvchk | grep -c Standby
if [ ${dbvchk2} -eq 1 ] ; then
  echo "OK - Database is in Standby mode no login"
  exit $STATE_OK
fi
else
....
fi
"fi" <-- without quotemarks
;

Don't forget the fi at the end of the section --login also at line 198.

--cache)
if [ -f /usr/local/dbvisit/dbvisit ]; then
  dbvchk=sudo -u oracle /usr/local/dbvisit/dbv\_oraStartStop status $2
  dbvchk2=echo $dbvchk | grep -c Standby
if [ ${dbvchk2} -eq 1 ] ; then
  echo "OK - Database is in Standbymodus and not open"
  exit $STATE_OK
fi
else
....
fi 
"fi" <-- without quotemarks
;

Thats all. When your Nagiosuser is in the dba group it checks if the file dbvisit exists in /usr/local/dbvisit and then runs the dbv_oraStartStop --status. When the return code is standby it breaks the script and returns a exit$State OK to nagios.

Mike Donovan October 15, 2014 12:57

Have more questions? Submit a request

Comments