-- Tạo crontab như sau:
--0,5,10,15,20,25,30,35,40,45,50,55 * * * * /home/oracle/gg_check/check_goldengate.sh >/dev/null 2>&1
#/home/oracle/gg_check/check_goldengate.sh
#!/usr/bin/ksh
#set -x
###################################
### Parameters
###################################
HOSTNAME=""
LOGSDIR="/home/oracle/gg_check/log"
SCRIPTNAME="check_goldengate.sh"
SKIP_GROUP="_MF"
#####################################################
### Oracle Instance on production server
#####################################################
export NLS_DATE_FORMAT="yyyy-mm-dd hh24:mi:ss"
export GGATE=/home/oracle/gg_check/
export LD_LIBRARY_PATH=/u01/app/oracle/product/11.2.0.2/dbhome_1/lib/:/u01/app/oracle/goldengate
export ORACLE_SID=dbaviet1
export ORACLE_BASE=/u01/app/oracle/product/11.2.0.2
export PATH=/usr/bin:/u01/app/oracle/product/11.2.0.2/dbhome_1/bin:/u01/app/11.2.0.2/grid/bin:/opt/mc/bin:/usr/local/bin:/usr/openwin/bin:/usr/ccs/bin:/u01/a
pp/oracle/goldengate
export RDBMS_HOME=/u01/app/oracle/product/11.2.0.2/dbhome_1
export GRID_HOME=/u01/app/11.2.0.2/grid
export ORACLE_HOME=/u01/app/oracle/product/11.2.0.2/dbhome_1
###################################
### Commands and files
###################################
SED="/usr/bin/sed"
AWK="/usr/bin/awk"
UMOUNT="/sbin/umount"
MOUNT="/sbin/mount"
PING="/usr/sbin/ping"
WC="/usr/bin/wc"
FSCK="/usr/sbin/fsck"
DF="/usr/sbin/df"
PS="/usr/bin/ps"
SU="/usr/bin/su"
CURDATE=`/bin/date +%d%b%y`
OUTF="$LOGSDIR/$SCRIPTNAME.$CURDATE"
EMAIL="$LOGSDIR/email.ora"
#/u01/app/oracle/goldengate/dump_scripts/testgg/testgg.sh
#------------------------------------------------------------------------------
# CHECK STATUS GOLDEN GATE
#------------------------------------------------------------------------------
check_status ()
{
echo ""
echo "------------------------------------------------------------------------"
echo "check time: `/bin/date +%d%b%y-%H:%M`"
echo "------------------------------------------------------------------------"
result=`/u01/app/oracle/goldengate/ggsci <<EOF
info all
EOF`
}
#-----------------------------------------------------------------------------
# CHECK ERROR
#-----------------------------------------------------------------------------
check_error ()
{
#original message
original_mess=$(echo "$result"|awk '{if (NR>1 && NR<44) {print $0} }')
echo "$original_mess" >> $OUTF 2>&1
echo "$original_mess"
#save heading for sms
heading=$(echo "$result"|/bin/grep "Program")
#echo "heading:\n$heading"
#cut heading "Program"
result_noheading=$(echo "$result"|/bin/sed '/Program/d')
#find process HANG or BANDED or STOP
err_mess=$(echo "$result_noheading"|awk '{if (NR>10 && NR<40) {print $0} }'|/bin/grep -E -e "STOP|ABENDED" |/bin/grep -v "REP" |/bin/grep -v "$SKIP_GROUP")
#echo "Process bi loi:\n$heading\n$err_mess\n"
#find delay process receive file
err_mess_2=$(echo "$result_noheading"|awk '{if (NR>10 && NR<40) {print $0} }'|awk '$5>"00:15:00" {print}' |/bin/grep -v "REP" |/bin/grep -v "$SKIP_GROUP")
#echo "Process nhan file cham >10phut:\n$heading\n$err_mess_2\n"
#find delay process Extract
err_mess_3=$(echo "$result_noheading"|awk '{if (NR>10 && NR<40) {print $0} }'|awk '$4>"00:15:00" {print}' |/bin/grep -v "REP" |/bin/grep -v "$SKIP_GROUP")
#echo "Process Extract bi cham >10phut:\n$heading\n$err_mess_3\n"
#final_msg="Process bi loi:\n$err_mess\n"
#final_msg="$final_msg\nProcess nhan file cham >10phut:\n$err_mess_2\n"
#final_msg="$final_msg\nProcess cham >10phut:\n$err_mess_3"
#echo "$final_msg"
#-----------------------------------------------------
# reset email content file
#-----------------------------------------------------
echo "" > $EMAIL 2>&1
#-----------------------------------------------------
# make sms & email content
#-----------------------------------------------------
if [ "$err_mess" != "" ];
then
final_msg="Process bi loi:\n$err_mess\n"
echo "---------------------------------------------------------------------" >>$EMAIL 2>&1
echo "<font color='#FF0000'><b>Process bi loi:</font></b>" >>$EMAIL 2>&1
echo "---------------------------------------------------------------------" >>$EMAIL 2>&1
echo -e "<pre><font color='#0000FF'><b>$heading</font></b>\n$err_mess\n</pre>" >>$EMAIL 2>&1
fi
if [ "$err_mess_2" != "" ];
then
final_msg="$final_msg""Process nhan file cham >10phut:\n$err_mess_2\n"
echo "---------------------------------------------------------------------" >>$EMAIL 2>&1
echo "<font color='#FF0000'><b>Process nhan file cham >10phut:</font></b>" >>$EMAIL 2>&1
echo "---------------------------------------------------------------------" >>$EMAIL 2>&1
echo -e "<pre><font color='#0000FF'><b>$heading</font></b>\n$err_mess_2\n</pre>" >>$EMAIL 2>&1
fi
if [ "$err_mess_3" != "" ];
then
final_msg="$final_msg""Process cham >10phut:\n$err_mess_3\n"
echo "---------------------------------------------------------------------" >>$EMAIL 2>&1
echo "<font color='#FF0000'><b>Process cham >10phut:</font></b>" >>$EMAIL 2>&1
echo "---------------------------------------------------------------------" >>$EMAIL 2>&1
echo -e "<pre><font color='#0000FF'><b>$heading</font></b>\n$err_mess_3\n</pre>\n" >>$EMAIL 2>&1
fi
#-------------------------------------------
# just use for debugging
#-------------------------------------------
echo -e "\nFINAL_MESSAGE:\n$final_msg"
#-------------------------------------------
#send SMS when error occured
#-------------------------------------------
if [ "$final_msg" = "" ]; then
echo > /dev/null
else
send_sms_new "'$final_msg'"
#echo >/dev/null
/home/oracle/gg_check/send_mail.pl
#send_mail_new "'$final_msg'"
echo "$final_msg" >> $OUTF 2>&1
fi
}
#------------------------------------------------------------------------------
# SEND SMS BY NEW TOOLS
#------------------------------------------------------------------------------
send_sms_new ()
{
echo ""
echo "-------------------------------------------------------------------------"
echo "SENDING... : `/bin/date +%d%b%y-%H:%M`"
echo "-------------------------------------------------------------------------"
echo " "
$ORACLE_HOME/bin/sqlplus sms_owner/oracle <<EOF >>$OUTF 2>&1
set pagesize 0
set echo off
set feed off
begin
cus_owner.send_sms('901234567','Co loi dong bo tren gold: $final_msg','warning_sms','dbaviet1');
commit;
end;
/
exit
EOF
return 0
}
send_mail_new ()
{
TO_USER="binhtv1\@gmail.com;tranbinh48ca\@gmail.com";
CURDATE=`/bin/date +%d-%b-%y-%H:%M`
$ORACLE_HOME/bin/sqlplus email_owner/oracle <<EOF >>$OUTF 2>&1
set pagesize 0
set echo off
set feed off
begin
email_owner.send_email_html('$TO_USER','[$CURDATE]Canh bao he thong GoldenGate DBAVIET','$final_msg') ;
end;
/
exit
EOF
return 0
}
#-----------------------------------------------------------------------------
###############
# M A I N #
###############
echo "" >> $OUTF 2>&1
echo "-------------------------------------------------------------------------" >> $OUTF 2>&1
echo " Checking GoldenGate: `/bin/date +%d%b%y-%H:%M`" >> $OUTF 2>&1
echo "-------------------------------------------------------------------------" >> $OUTF 2>&1
echo "" >> $OUTF 2>&1
check_status
check_error
/home/oracle/gg_check/log/email.ora
bash-3.2# more email.ora
---------------------------------------------------------------------
<font color='#FF0000'><b>Process nhan file cham >10phut:</font></b>
---------------------------------------------------------------------
<pre><font color='#0000FF'><b>Program Status Group Lag Time Since Chkpt</font></b>
Linux, x64, 64bit (optimized), Oracle 11g on Feb 22 2012 22:42:01
Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.
</pre>
---------------------------------------------------------------------
<font color='#FF0000'><b>Process cham >10phut:</font></b>
---------------------------------------------------------------------
<pre><font color='#0000FF'><b>Program Status Group Lag Time Since Chkpt</font></b>
Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.
</pre>
* KHOÁ HỌC ORACLE DATABASE A-Z ENTERPRISE trực tiếp từ tôi giúp bạn bước đầu trở thành những chuyên gia DBA, đủ kinh nghiệm đi thi chứng chỉ OA/OCP, đặc biệt là rất nhiều kinh nghiệm, bí kíp thực chiến trên các hệ thống Core tại VN chỉ sau 1 khoá học.
* CÁCH ĐĂNG KÝ: Gõ (.) hoặc để lại số điện thoại hoặc inbox https://m.me/tranvanbinh.vn hoặc Hotline/Zalo 090.29.12.888
* Chi tiết tham khảo:
https://bit.ly/oaz_w
=============================
KẾT NỐI VỚI CHUYÊN GIA TRẦN VĂN BÌNH:
📧 Mail: binhoracle@gmail.com
☎️ Mobile/Zalo: 0902912888
👨 Facebook: https://www.facebook.com/BinhOracleMaster
👨 Inbox Messenger: https://m.me/101036604657441 (profile)
👨 Fanpage: https://www.facebook.com/tranvanbinh.vn
👨 Inbox Fanpage: https://m.me/tranvanbinh.vn
👨👩 Group FB: https://www.facebook.com/groups/DBAVietNam
👨 Website: https://www.tranvanbinh.vn
👨 Blogger: https://tranvanbinhmaster.blogspot.com
🎬 Youtube: http://bit.ly/ytb_binhoraclemaster
👨 Tiktok: https://www.tiktok.com/@binhoraclemaster?lang=vi
👨 Linkin: https://www.linkedin.com/in/binhoracle
👨 Twitter: https://twitter.com/binhoracle
👨 Địa chỉ: Tòa nhà Sun Square - 21 Lê Đức Thọ - Phường Mỹ Đình 1 - Quận Nam Từ Liêm - TP.Hà Nội
=============================
oracle tutorial, học oracle database, Tự học Oracle, Tài liệu Oracle 12c tiếng Việt, Hướng dẫn sử dụng Oracle Database, Oracle SQL cơ bản, Oracle SQL là gì, Khóa học Oracle Hà Nội, Học chứng chỉ Oracle ở đầu, Khóa học Oracle online,sql tutorial, khóa học pl/sql tutorial, học dba, học dba ở việt nam, khóa học dba, khóa học dba sql, tài liệu học dba oracle, Khóa học Oracle online, học oracle sql, học oracle ở đâu tphcm, học oracle bắt đầu từ đâu, học oracle ở hà nội, oracle database tutorial, oracle database 12c, oracle database là gì, oracle database 11g, oracle download, oracle database 19c, oracle dba tutorial, oracle tunning, sql tunning , oracle 12c, oracle multitenant, Container Databases (CDB), Pluggable Databases (PDB), oracle cloud, oracle security, oracle fga, audit_trail,oracle RAC, ASM, oracle dataguard, oracle goldengate, mview, oracle exadata, oracle oca, oracle ocp, oracle ocm , oracle weblogic, postgresql tutorial, mysql tutorial, mariadb tutorial, sql server tutorial, nosql, mongodb tutorial, oci, cloud, middleware tutorial, hoc solaris tutorial, hoc linux tutorial, hoc aix tutorial, unix tutorial, securecrt, xshell, mobaxterm, putty