IBM Support

75 ways to demystify DB2: #10: Expert Advice: Monitoring the changes in HADR state.

Technical Blog Post


Abstract

75 ways to demystify DB2: #10: Expert Advice: Monitoring the changes in HADR state.

Body

Hello all,

I am sharing one small script to monitor the changes in HADR state. If you know better way to monitor it, please share it in comments section. Thank you!

Script:

#!/usr/bin/ksh
set +x
######################################################################################################
# Objective:
#    Monitor the change in HADR state
# How it works?
#  This is a cron job that needs to be set at OS level as DB2 instance user.
#  It needs to be run for every 10 minutes interval.
#  This script will scan through your db2diag.log entries generated in last 10 minutes and look for function
# 'hdrSetHdrState'.
#  It counts the total number of such entries and generates an alert if count is more than 0 .
######################################################################################################

if [ -f /home/db2inst1/sqllib/db2profile ]; then
    . /home/db2inst1/sqllib/db2profile
fi


count=`db2diag -history 10m -gi "funcn=hdrSetHdrState" -count | awk '{print $2}'`

if [ $count -eq 0 ]; then
   echo "HADR state is unchanged."
 else
   echo "Alert:HADR status has changed for $count time(s)."
fi

# script ends here.

Please feel free to modify the script as per your requirements and your environmental setup.

Thank you!

 

 

[{"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SSEPGG","label":"Db2 for Linux, UNIX and Windows"},"Component":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

UID

ibm11141228