아래는 간단히 유닉스 파일시스템을 읽어 Config.ini에 정해놓은 용량보다 크게되면
SMS를 전송하는 쉘스크립트이다.
#! /bin/ksh -f MANPATH=/usr/man:/usr/share/man:/opt/SUNWspro/man # Set up the oracle variables: ORACLE_HOME=/rtd_orahome ORACLE_SID=XXXX ORACLE_TERM=vt100 ORAWEB_HOME=$ORACLE_HOME/ows/3.0 ORAWEB_SITE=web ORA_NLS32=$ORACLE_HOME/ocommon/nls/admin/data TNS_ADMIN=$ORACLE_HOME/network/admin ORACLE_OWNER=AAAA LANG=korean NLS_LANG=American_America.KO16KSC5601 # Set up the search paths: PATH=/opt/SUNWspro/bin:/usr/ccs/bin:/usr/bin:/usr/ucb:/etc:/usr/sbin:/usr/openwin/bin:$ORACLE_HOME/bin:$ORAWEB_HOME/bin:. LD_LIBRARY_PATH=/opt/SUNWspro/lib:/usr/lib:/usr/ccs/lib:/usr/openwin/lib:/usr/ucblib:$ORACLE_HOME/lib export PATH ORACLE_HOME ORACLE_SID ORACLE_TERM LANG LD_LIBRARY_PATH ORAWEB_HOME MANPATH ORA_NLS32 TNS_ADMIN ORACLE_OWNER #============================================================================================================= SMS_CLIENT=/rtd_home/monitor/bin/SmsSender CONFIG_FILE=/rtd_home/monitor/cfg/config.ini HOST_NAME=`hostname` #let intCnt=0 grep -w "FILESYSTEM" $CONFIG_FILE | while read strCategory strFileSystemNm intDangerCapacity do intCurCapacity=`df -k $strFileSystemNm |tail -1|awk '{print $5}' |cut -d % -f 1` if (( intCurCapacity > intDangerCapacity )) then intCurCapacity=`df -k $strFileSystemNm |tail -1|awk '{print $5}' |cut -d % -f 1` if (( intCurCapacity > intDangerCapacity )) then grep -w "FILESYSTEM_NOTIFY_PHONE_NUMBER" $CONFIG_FILE | while read strCategory NOTIFY_PHONE_NUMBER do $SMS_CLIENT 'Moramcnt' $NOTIFY_PHONE_NUMBER 021234567 "$HOST_NAME Server['FILE SYSTEM $strFileSystemNm'] exceeded $intDangerCapacity%. Current : $intCurCapacity%" sleep 1 done print `date '+%Y-%m-%d %T'` "$HOST_NAME :FILE SYSTEM $strFileSystemNm'이 $intDangerCapacity%를 넘었습니다. 현재 : $intCurCapacity%" >> /rtd_home/monitor/logs/check_filesystem_err.log #let intCnt=intCnt+1 else print `date '+%Y-%m-%d %T'` "$HOST_NAME : File System 정상 $strFileSystemNm : $intCurCapacity%" >> /rtd_home/monitor/logs/check_filesystem.log fi else print `date '+%Y-%m-%d %T'` "$HOST_NAME : File System 정상 $strFileSystemNm : $intCurCapacity%" >> /rtd_home/monitor/logs/check_filesystem.log fi done exit 0
Config.ini파일의 내용은 다음과 같다.
[FILE_SYSTEM] FILESYSTEM / 90 FILESYSTEM /tmp 90 FILESYSTEM /rtd_orahome 90 FILESYSTEM /rtd_home 92 FILESYSTEM /rtd_data1 90 FILESYSTEM /rtd_data2 90 FILESYSTEM /rtd_data3 90 FILESYSTEM /rtd_data4 90 FILESYSTEM /rtd_data5 90 FILESYSTEM /rtd_data6 90 FILESYSTEM /rtd_data7 90 FILESYSTEM /rtd_data8 90 FILESYSTEM /rtd_data9 90 FILESYSTEM /rtd_data10 90 FILESYSTEM /backup 95
그리고, SMSSender프로그램은 이전글 “오라클 Alert Log에 에러 발생시 SMS로 전송하는 쉘 스크립트” 을 참고하면된다.