Saturday, January 7, 2023

#!/bin/sh ############################################################## # Create_Time: 2012-9-20 # # Author: ftc # # Function : check dataguard database synchronic status # ############################################################## . /home/oracle/.bash_profile cd /home/oracle/monitor_dg export NLS_LANG="SIMPLIFIED CHINESE_CHINA.ZHS16GBK" DATE=$(date +%Y%m%d-%H%M%S) TO_MAIL_ADDRESS=fengtc@app.moonbasagroup.com send_log() { env MAILRC=/dev/null \ from="admin@app.moonbasagroup.com" \ smtp="10.0.65.29" \ smtp-auth-user="admin@app.moonbasagroup.com" \ smtp-auth-password="h+isJb)y3My3" \ smtp-auth=login \ nail -n -s "Check dataguard status On $CHECK_TIME $(hostname)" $TO_MAIL_ADDRESS < /home/oracle/monitor_dg/dg_warning.log } work_dir=`dirname $0` ##Ö÷±¸¿âsysÕ˺ÅÃÜÂëºÍÁ¬½Ó×Ö·û´®ÅäÖÃÎļþ,¸ñʽΪ2ÐÐ3ÁÐ config_file=config/.monitor_dg_config ##¶¨ÒåÏÔʾѲ¼ìÊý¾Ý¿âÃû³Æ config_check_dbname='SHWMS7APP' #ÑéÖ¤Êý¾Ý¿âÁ¬½ÓÅäÖÃÎļþ¸ñʽ,·Ç¹æ¶¨¸ñʽÅ×Òì³£,ÖÕֹѲ¼ì if [ -r ${work_dir}/${config_file} ] && [ `awk '{printf NF}' ${work_dir}/${config_file}` -eq 33 ] then i=0 while read line do ###»ñµÃdb_name,db_passwordºÍdb_string set $line db_name[$i]=$1 db_passwd[$i]=$2 db_string[$i]=$3 #echo ${db_name[$i]} ##»ñµÃÊý¾Ý¿â״̬£º 1ÐÐ4ÁУ¬ÒÔ"|"×ö·Ö¸ô·û Dg_status_total[$i]=`sqlplus -S -l "${db_name[$i]}/${db_passwd[$i]}@${db_string[$i]}" <