Checking if a database is available
This script checks DB2 database connectivity
What | |
---|---|
When |
2010-08-06 17:37
2010-08-06 17:37
2010-08-06 from 17:37 to 17:37 |
Add event to calendar |
vCal iCal |
#!/usr/bin/ksh
##############################################################
# Author: Felipe Alkain de Souza
#
# Script Name: check_db_connections.sh
#
# Functionality: This script checks DB2 database connectivity
#
# Usage: ./check_db_connections.sh <db_name>
#
##############################################################
. $HOME/sqllib/db2profile
### Nagios RCs Variables
STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKNOWN=3
### Check if the databases are online
db2 connect to $1 > /dev/null
if [ $? -ne 0 ]
then
echo "$STATE_CRITICAL&DB2 - The database $1 did not conee!"
exit $STATE_CRITICAL
else
echo "$STATE_OK&DB2 - The database $1 is available!"
exit $STATE_OK
fi
db2 connect reset