쉘 스크립트 관련 질문....
여기 주제에 맞을까 하구 몇시간 게시판 검색해보다가 글 올립니다.
스크립트를 이용하여 프로세서나 시스템에 이상이 있을경우 sms 를 이용 핸드폰으로 문자가 오게 해놨습니다.
문제는 오라클 프로세스가 죽으면 문자가 오게 하려구 함.
백업시간이 4시간 정도 걸리므로 계속 문자를 받을순 없고 ㅡㅡ;
오프라인 백업시작시 한번... 끝났을경우에 한번 문자가 오게 하고 싶습니다.
서버는 hp-ux 이며 오라클디비는 두개 입니다....
아래는 기존에 잇던 스크립트 내용입니다.
(오라클 프로세서 죽어도 문자가 안옴..)
(쉘스크립트 문외한 수준이라 눈 높이 답변 주시면 감사...)
읽어주셔서 감사합니다....
#-----------------------------------------------------------------------------------
# Check Oracle Background Check except backup time (Using /usr/bin/ps -ef command)
#
#ORAPROC_CTL_FILE=$CTL_DIR/CTL/oraproc.ctl.$HOST
#ORAPROC_CURR_TIME=`$SRT_DIR/func_time.ksh`
#let "ORAPROC_CTL_TIME=$ORAPROC_CURR_TIME + 600"
#if [ -f $ORAPROC_CTL_FILE ]
#then
# ORAPROC_PREV_TIME=`cat $ORAPROC_CTL_FILE`
#else
# print $ORAPROC_CTL_TIME > $ORAPROC_CTL_FILE
# ORAPROC_PREV_TIME=`cat $ORAPROC_CTL_FILE`
#fi
EXEC=`/usr/bin/ps -ef | grep /opt/omni/lbin/bma | grep -v "grep" | wc -l`
if [ "${EXEC}" -lt "1" ]
then
if [ "${SID}" != "" ]
then
for ORAPROCESS in pmon smon lgwr
do
ORASTATUS=`/usr/bin/ps -ef | grep ${SID} | grep -v 'grep' | grep ${ORAPROCESS}`
if [ "${ORASTATUS}" = "" ]
then
MSG="[ORACLE-down] ${SID} ${ORAPROCESS} is down"
print "$SYSDATE $MSG" >> $TEC_LOG
# if [ $ORAPROC_CURR_TIME -ge $ORAPROC_PREV_TIME ]
# then
# print $ORAPROC_CTL_TIME > $ORAPROC_CTL_FILE
$ALERTCMD -r CRITICAL -m "$MSG $SYSDESC" hostname=${HOST} origin=${IP} OracleInstance_rdbmsstate OracleInstance
# fi
fi
done
fi
exit 0
fi
exit 0
저도 쉘 스크립트는 잘모르지만 대충...$TEC_LOG로 지정된
저도 쉘 스크립트는 잘모르지만 대충...
$TEC_LOG로 지정된 파일을 먼저 점검하셔서 실제 메시지가 발생했는지를 확인해
보시고
만일 해당 시간에 메시지가 발생했다면 $ALERTCMD로 지정된 명령어가 잘 동작하는지
수동으로 확인해 보는게 좋겠네요.
------------------------------
좋은 하루 되세요.
Re: 쉘 스크립트 관련 질문....
$ALERTCMD 란 것이 문자를 보내주는 실행 프로그램인 것 같습니다만 Script 어디에도 해당 변수가 의미하는 실제 프로그램이 보이지 않네요.
이 프로그램을 찾아서 지정을 해 주세요.
예를 들어, $ALERTCMD 란 것이 실제로는 /bin/abc 란 이름이라면
ALERTCMD='/bin/abc'
와 같이 Script 앞쪽에 정의(?)해 주시면 됩니다.
잘 살아보세~~~
shell script debugging은sh -x 스크립트명
shell script debugging은
sh -x 스크립트명
과 같은 방식으로 합니다.
또는 맨위에
#!/bin/sh -x
라고 써주시면됩니다.
---
http://coolengineer.com
댓글 달기