Personal tools
You are here: Home DB2 Scripts DB2 Shell Scripts to DB2 Script to Check if Instance is running
Navigation
Log in


Forgot your password?
 
Document Actions

Script to Check if Instance is running



#!/bin/ksh
# Check if Instance is running
#---------------------------------------------------------------------------------------------

# Do not modify anything below this line:
echo " $DB2INSTANCE" > ~/erro.out

# Get the hostname and set all letters to uppercase
HOSTNAME=$(hostname | /usr/bin/tr '[a-z]' '[A-Z]')
EMAIL=$("<put your e-mail here>"
#Get the number of instances running in the server
NUM_PROC=$(ps -ef | grep $DB2INSTANCE | grep db2sysc | grep -v grep | wc -l)

if [[ $NUM_PROC -ne "1" ]]; then
      echo "Instance down"
      mail -s "DB2: Instance $DB2INSTANCE down on $HOSTNAME" $EMAIL < /dev/null
      # trying to restart db2
      db2start
      NUM_PROC=$(ps -ef | grep $DB2INSTANCE | grep db2sysc | grep -v grep | wc -l)
      if [[ $NUM_PROC -eq "1" ]]; then
           mail -s "Instance $DB2INSTANCE restarted successfully on $HOSTNAME" $dft_email_id < /dev/null
      fi
fi
exit 0




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





Polls