#!/usr/bin/ksh ######################################## # Run on database servers # Restart http server if isqlplus does not come up # run from cron ########################################## host=$(hostname | cut -d"." -f1) ORACLE_HOME=/u01/app/oracle/product/10.2.0 ORACLE_OWNER=oracle ISQLPLUS='${ORACLE_HOME}/bin/isqlplusctl start' LOGFILE=/tmp/check.isqlplus LOGFILE_0=/tmp/check.isqlplus.0 TO='your_account@mail.com' function isqlplus_restart { PID=$(/usr/local/bin/lsof -i tcp:5560 | grep java | awk ' {print$2}') [[ ${PID} ]] && kill -9 ${PID} su - oracle -c "${ISQLPLUS}" echo "restarted isqlplus server on $host on $(date)" >> ${LOGFILE} @ echo "" | mailx -r account@oracle.com -s "Restarted isqlplus server on $host on $(date)" $TO } function http_ok { echo " isqlplus server OK on $host on $(date)" >> ${LOGFILE} } [[ $(/usr/local/bin/lynx -dump -connect_timeout=45 http://$host:5560/isqlplus | grep -i username) ]] && http_ok || isqlplus_restart tail -1000 ${LOGFILE} > $LOGFILE_0 mv $LOGFILE_0 $LOGFILE