쉘 스크립트 관련 질문....

argares의 이미지

여기 주제에 맞을까 하구 몇시간 게시판 검색해보다가 글 올립니다.

스크립트를 이용하여 프로세서나 시스템에 이상이 있을경우 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

codebank의 이미지

저도 쉘 스크립트는 잘모르지만 대충...

$TEC_LOG로 지정된 파일을 먼저 점검하셔서 실제 메시지가 발생했는지를 확인해
보시고
만일 해당 시간에 메시지가 발생했다면 $ALERTCMD로 지정된 명령어가 잘 동작하는지
수동으로 확인해 보는게 좋겠네요.

------------------------------
좋은 하루 되세요.

boolsee의 이미지

argares wrote:

$ALERTCMD
-r CRITICAL -m "$MSG $SYSDESC" hostname=${HOST} origin=${IP} OracleInstance_rdbmsstate OracleInstance

$ALERTCMD 란 것이 문자를 보내주는 실행 프로그램인 것 같습니다만 Script 어디에도 해당 변수가 의미하는 실제 프로그램이 보이지 않네요.
이 프로그램을 찾아서 지정을 해 주세요.
예를 들어, $ALERTCMD 란 것이 실제로는 /bin/abc 란 이름이라면

ALERTCMD='/bin/abc'

와 같이 Script 앞쪽에 정의(?)해 주시면 됩니다.

잘 살아보세~~~

pynoos의 이미지

shell script debugging은

sh -x 스크립트명

과 같은 방식으로 합니다.

또는 맨위에

#!/bin/sh -x

라고 써주시면됩니다.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.