Oracle monitoring script for hacmp ?

Hi,

does anyone happen to have a sample of a hacmp monitoring script for oracle? With the process monitoring I seem to be only able to monitor the listener but not oracle itself ?

Thanks in advance
zxmaus

Not a HACMP-ready script, but should be easy to alter so IIRC HACMP just triggers if the exit code is 0 or not.

When I wrote scripts to check the "alive" status of DB2 or TSM, I usually just checked the return code of a simple SELECT on a system table. By doing this you can bypass checking for processes as this does not tell if they are still working or not.

Let me dig one out... bypass that OV (HP Open View /OMW) stuff and the German gibberish :wink: This script was one of many in a self written monitoring construct. The maybe interesting part for you is the bold marked.

#!/bin/ksh
#
# Skript: /usr/local/OV/OV__SOME__LIB_db2.ksh
#
# FS-PERMS:icmlib:db2iadm1:500
#
# Checkt fuer HP Open View, ob die DB2 verfuegbar ist. Liefert folgende
# Exitcodes:
#       0       Kein Fehler
#       1       Fehler (schreibt Lockfile)
#       2       Fehler noch vorhanden (Lockfile ist schon vorhanden)
#       3       Kein Fehler mehr vorhanden (Lockfile wird geloescht)
#       5       Kein UP-Flag
#
# Muss als Instanz Owner ausgefuehrt werden, sonst gibts Probleme.
#
# 21.05.04, M.
# 10.07.06, M.
# 02.08.06, M.
#############################################################################
#set -x

# Flag-Pruefung
flag_check()
{
  FLAG_DIR=/usr/local/var/app_status
  THIS_APP="LIB_db2"
  if [[ `cat ${FLAG_DIR}/${THIS_APP}` = "UP" ]]; then
        echo "UP -- Pruefung erfolgt nun... -- `date`"
  else
        echo "DOWN -- Es erfolgt keine Pruefung -- `date`"
        exit 5
  fi
}
flag_check

. ~icmlib/.profile

# OV spezifisches:
###################
OPC=/usr/lpp/OV/OpC/opcmsg

OV_NODE="node=`hostname`"               # Hostname
OV_APP='a="DB2"'                        # Applikation
OV_OBJ='o="Lib"'                        # Objekt, z.B. Instanz
OV_MGRP='msg_grp="SOME"'                # Message Group
OV_SID='service_id="SOME Archive:SOME Lib"'           # Angesprochener Knoten
                                        # Schweregrad:
OV_SV1='severity="critical"'
OV_SV2='severity="normal"'
                                        # Text-Messages:
OV_MSG1="msg_text=\"FEHLER: Datenbank fuer Library Server nicht erreichbar! --- Quelle: $0\""
OV_MSG2="msg_text=\"OK: Datenbank fuer Library Server wieder erreichbar. --- Quelle: $0\""


# Pruefungslogik
#################

LOCKFILE=/var/locks/OV_lib-db2.lock

db2 connect to icmlib_p > /dev/null 2>&1
db2 -x "select * from ICMUT01014001 fetch first 5 rows only" > /dev/null 2>&1

STATUS=`echo $?`

db2 connect reset > /dev/null 2>&1

if [[ ${STATUS} -gt 0 ]]; then
        if [[ -e ${LOCKFILE} ]]; then
                echo "ERROR -- `date`"
                exit 2
        fi

        touch ${LOCKFILE}
        echo ${OV_APP} ${OV_OBJ} ${OV_MGRP} ${OV_NODE} ${OV_SID} ${OV_SV1} ${OV_MSG1} |\
        xargs ${OPC}
        echo "ERROR -- `date`"
        exit 1
else
        if [[ -e ${LOCKFILE} ]]; then
                rm ${LOCKFILE}
                echo ${OV_APP} ${OV_OBJ} ${OV_MGRP} ${OV_NODE} ${OV_SID} ${OV_SV2} ${OV_MSG2} |\
                xargs ${OPC}
                echo "OK -- `date`"
                exit 3
        fi
fi

echo "OK -- `date`"
exit 0
1 Like