#!/bin/sh HOST=$1 SID=$2 if [ $# -eq 2 ] then ISTANCE=`ssh -l roomer $HOST "ps -ef |grep ora_smon_$SID|grep -v grep"` LIST=`ssh -l roomer $HOST "ps -ef |grep tnslsnr|grep $SID| grep -v grep"` elif [ $# -eq 3 ]; then ISTANCE=`ssh -l roomer $HOST "ps -ef |grep ora_smon_$SID|grep -v grep"` LIST=`ssh -l roomer $HOST "ps -ef |grep tnslsnr| grep -v grep"` else echo "usage: check_db.sh" echo "if listener has no name, then usage: check_db.sh " exit 3 fi if [ -n "$ISTANCE" ] && [ -n "$LIST" ]; then echo "OK : Oracle $SID is up and running" exit 0 elif [ ! -n "$ISTANCE" ]; then echo "CRITICAL : Oracle $SID istance is down, process not found" exit 2 elif [ ! -n "$LIST" ]; then echo "CRITICAL : Oracle listener for $SID is down, process not found" exit 2 elif [ ! -n "$LIST" ] && [ -n "$LIST" ]; then echo "CRITICAL : Oracle is down, processes not found for sid $SID" exit 2 fi