Personal tools
You are here: Home → DB2 → Scripts DB2 → Nagios Plugins to monitor DB2 events → Checking if an instance is available
Navigation
Log in


Forgot your password?
 
Document Actions

Checking if an instance is available

by Felipe Alkain de Souza — last modified 2010-08-06 17:39

This script checks if DB2 instance is up

What
When 2010-08-06
from 17:39 to 17:39
Add event to calendar vCal
iCal

#!/usr/bin/ksh
##########################################################
# Author: Felipe Alkain de Souza
#
# Script Name: check_instance_up.sh
#
# Functionality: This script checks if DB2 instance is up
#
# Usage: ./check_instance_up.sh
#
##########################################################

. $HOME/sqllib/db2profile

### Nagios RCs Variables
STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKNOWN=3

SVCNAME=`db2 get dbm cfg |grep SVCENAME |awk -F= '{print $2}'`

PORTNUM=`grep $SVCNAME /etc/services |awk '{print $2}' |awk -F/ '{print $1}'`

PROC=`netstat -na |grep $PORTNUM |wc -l`

if [[ $PROC -eq "0" ]]; then
    echo "$STATE_CRITICAL&DB2 - Instance $DB2INSTANCE down on `hostname`"   
    exit $STATE_CRITICAL
   
    else
    echo "$STATE_OK&DB2 - Instance $DB2INSTANCE is up."   
   exit $STATE_OK
   
fi

Security Awareness
Would you like your company to implement gamification into your security awareness program?





Polls