ogg監控指令碼
本機
/home/oracle/ogg_moni/oggchk.sh
# /bin/sh
# Setup the environment variables
# Set the public environment variable
export ORACLE_BASE=/oracle/app/oracle
export GI_HOME=/oracle/app/11.2.0/grid
export ORACLE_HOME=/oracle/app/oracle/product/11.2.0/db_1
export NLS_LANG=American_America.ZHS16GBK
export TMP=/tmp
export TMPDIR=/tmp
export ORACLE_TERM=vt100
OPATCH_PLATFORM_ID=212
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$GI_HOME/bin:$PATH:/usr/ccs/bin:/usr/bin/X11:/usr/java5/bin
#
# Determine the even in the computer name
now_date=`date +"%y-%m-%d %T"`
host_name=`uname -n`
#prefix_host=`echo $host_name | sed 's/\(.*\)\(.\)$/\1/'`
((postfix_host=`echo $host_name | sed 's/\(.*\)\(.\)$/\2/'`))
if [ `expr $postfix_host % 2` -eq 0 ];then even=y;else even=n;fi
#
# Set up private environment variables
((i=`ps -ef|grep ora_ckpt|grep -v grep|wc -l`))
case $i in
0)
echo "There is no database running"
exit 0
;;
1)
((postfix_sid=`ps -ef|grep ora_ckpt|grep -v grep|awk '{print $NF}'|awk -F "_" '{print $3}'|sed 's/\(.*\)\(.\)$/\2/'`))
if [ $postfix_sid -eq 1 ]
then
export ORACLE_SID=`ps -ef|grep ora_ckpt|grep -v grep|awk '{print $NF}'|awk -F "_" '{print $3}'`
export OGG_HOME=$ORACLE_BASE/ogg
export LIBPATH=$OGG_HOME:$ORACLE_HOME/lib
else
echo "GoldenGate under normal circumstances is not running on this computer nodes"
exit 0
fi
;;
2)
if [ $even = "n" ]
then
export ORACLE_SID=`ps -ef|grep ora_ckpt|grep -v grep|awk -F "_" '{print $3}'|sort|awk 'NR==1 {print}'`
export OGG_HOME=$ORACLE_BASE/ogg
export LIBPATH=$OGG_HOME:$ORACLE_HOME/lib
else
if [ $even = "y" ]
then
export ORACLE_SID=`ps -ef|grep ora_ckpt|grep -v grep|awk -F "_" '{print $3}'|sort|awk 'NR==2 {print}'`
export OGG_HOME=$ORACLE_BASE/ogg2
export LIBPATH=$OGG_HOME:$ORACLE_HOME/lib
else
echo "Application error"
exit 0
fi
fi
;;
*)
echo "Application error"
exit 0
;;
esac
#echo $ORACLE_BASE
#echo $ORACLE_HOME
#echo $ORACLE_SID
#echo $OGG_HOME
#echo $LIBPATH
cd $OGG_HOME
$OGG_HOME/ggsci </home/oracle/ogg_moni/ogginfo.txt
info all >>/home/oracle/ogg_moni/ogginfo.txt
exit
EOF
cd /home/oracle
# The working state of the GoldenGate
sed '/^$/d' /home/oracle/ogg_moni/ogginfo.txt >/home/oracle/ogg_moni/tempinfo.txt
num_temp=`cat -n /home/oracle/ogg_moni/tempinfo.txt|grep MANAGER|awk '{print $1}'`
let num_start=num_temp+1
num_end=`cat /home/oracle/ogg_moni/tempinfo.txt|wc -l`
let num_end=num_end-0
awk 'NR=='$num_start', NR=='$num_end' {print}' /home/oracle/ogg_moni/tempinfo.txt>/home/oracle/ogg_moni/temp_ogg.txt
#
# Determine the working state of the GoldenGate
run_all=`cat /home/oracle/ogg_moni/tempinfo.txt|grep MANAGER| awk '{print $0}'`
run_name=`cat /home/oracle/ogg_moni/tempinfo.txt|grep MANAGER|awk '{print $3}'`
run_staus=`cat /home/oracle/ogg_moni/tempinfo.txt|grep MANAGER|awk '{print $2}'`
if [ $run_staus = "RUNNING" ]
then
echo "$now_date $host_name $run_all normal-work"
else
echo "$now_date $host_name $run_all NOT-WORK"
fi
num_end=`cat /home/oracle/ogg_moni/temp_ogg.txt|wc -l`
i=1
until [[ $i -gt $num_end ]]; do
run_all=`awk 'NR=='$i' {print $0}' /home/oracle/ogg_moni/temp_ogg.txt`
run_name=`awk 'NR=='$i' {print $3}' /home/oracle/ogg_moni/temp_ogg.txt`
run_staus=`awk 'NR=='$i' {print $2}' /home/oracle/ogg_moni/temp_ogg.txt`
if [ $run_staus = "RUNNING" ]
then
((run_check=`awk 'NR=='$i' {print $4}' /home/oracle/ogg_moni/temp_ogg.txt|sed 's/://g'`))
if [ $run_check -gt 1500 ]
then
echo "$now_date $host_name $run_all normal-work ckpt-abnormal"
else
echo "$now_date $host_name $run_all normal-work ckpt-normal"
fi
else
echo "$now_date $host_name $run_all NOT WORK"
fi
let i=i+1
# To prevent the infinite loop
if [ $i -eq 50 ]
then
break
fi
done
多個機器監控
/home/oracle/ogg_moni/oggchk_all.sh
ssh 10.161.2.86 /home/oracle/ogg_moni/oggchk.sh
ssh 10.161.2.41 /home/oracle/ogg_moni/oggchk.sh
ssh 10.161.2.42 /home/oracle/ogg_moni/oggchk.sh
ssh 10.161.2.46 /home/oracle/ogg_moni/oggchk.sh
ssh 10.161.2.47 /home/oracle/ogg_moni/oggchk.sh
ssh 10.161.2.51 /home/oracle/ogg_moni/oggchk.sh
ssh 10.161.2.52 /home/oracle/ogg_moni/oggchk.sh
ssh 10.161.2.56 /home/oracle/ogg_moni/oggchk.sh
ssh 10.161.2.57 /home/oracle/ogg_moni/oggchk.sh
ssh 10.161.2.61 /home/oracle/ogg_moni/oggchk.sh
ssh 10.161.2.62 /home/oracle/ogg_moni/oggchk.sh
ssh 10.161.2.66 /home/oracle/ogg_moni/oggchk.sh
ssh 10.161.2.67 /home/oracle/ogg_moni/oggchk.sh
/home/oracle/ogg_moni/oggchk.sh
# /bin/sh
# Setup the environment variables
# Set the public environment variable
export ORACLE_BASE=/oracle/app/oracle
export GI_HOME=/oracle/app/11.2.0/grid
export ORACLE_HOME=/oracle/app/oracle/product/11.2.0/db_1
export NLS_LANG=American_America.ZHS16GBK
export TMP=/tmp
export TMPDIR=/tmp
export ORACLE_TERM=vt100
OPATCH_PLATFORM_ID=212
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$GI_HOME/bin:$PATH:/usr/ccs/bin:/usr/bin/X11:/usr/java5/bin
#
# Determine the even in the computer name
now_date=`date +"%y-%m-%d %T"`
host_name=`uname -n`
#prefix_host=`echo $host_name | sed 's/\(.*\)\(.\)$/\1/'`
((postfix_host=`echo $host_name | sed 's/\(.*\)\(.\)$/\2/'`))
if [ `expr $postfix_host % 2` -eq 0 ];then even=y;else even=n;fi
#
# Set up private environment variables
((i=`ps -ef|grep ora_ckpt|grep -v grep|wc -l`))
case $i in
0)
echo "There is no database running"
exit 0
;;
1)
((postfix_sid=`ps -ef|grep ora_ckpt|grep -v grep|awk '{print $NF}'|awk -F "_" '{print $3}'|sed 's/\(.*\)\(.\)$/\2/'`))
if [ $postfix_sid -eq 1 ]
then
export ORACLE_SID=`ps -ef|grep ora_ckpt|grep -v grep|awk '{print $NF}'|awk -F "_" '{print $3}'`
export OGG_HOME=$ORACLE_BASE/ogg
export LIBPATH=$OGG_HOME:$ORACLE_HOME/lib
else
echo "GoldenGate under normal circumstances is not running on this computer nodes"
exit 0
fi
;;
2)
if [ $even = "n" ]
then
export ORACLE_SID=`ps -ef|grep ora_ckpt|grep -v grep|awk -F "_" '{print $3}'|sort|awk 'NR==1 {print}'`
export OGG_HOME=$ORACLE_BASE/ogg
export LIBPATH=$OGG_HOME:$ORACLE_HOME/lib
else
if [ $even = "y" ]
then
export ORACLE_SID=`ps -ef|grep ora_ckpt|grep -v grep|awk -F "_" '{print $3}'|sort|awk 'NR==2 {print}'`
export OGG_HOME=$ORACLE_BASE/ogg2
export LIBPATH=$OGG_HOME:$ORACLE_HOME/lib
else
echo "Application error"
exit 0
fi
fi
;;
*)
echo "Application error"
exit 0
;;
esac
#echo $ORACLE_BASE
#echo $ORACLE_HOME
#echo $ORACLE_SID
#echo $OGG_HOME
#echo $LIBPATH
cd $OGG_HOME
$OGG_HOME/ggsci <
info all >>/home/oracle/ogg_moni/ogginfo.txt
exit
EOF
cd /home/oracle
# The working state of the GoldenGate
sed '/^$/d' /home/oracle/ogg_moni/ogginfo.txt >/home/oracle/ogg_moni/tempinfo.txt
num_temp=`cat -n /home/oracle/ogg_moni/tempinfo.txt|grep MANAGER|awk '{print $1}'`
let num_start=num_temp+1
num_end=`cat /home/oracle/ogg_moni/tempinfo.txt|wc -l`
let num_end=num_end-0
awk 'NR=='$num_start', NR=='$num_end' {print}' /home/oracle/ogg_moni/tempinfo.txt>/home/oracle/ogg_moni/temp_ogg.txt
#
# Determine the working state of the GoldenGate
run_all=`cat /home/oracle/ogg_moni/tempinfo.txt|grep MANAGER| awk '{print $0}'`
run_name=`cat /home/oracle/ogg_moni/tempinfo.txt|grep MANAGER|awk '{print $3}'`
run_staus=`cat /home/oracle/ogg_moni/tempinfo.txt|grep MANAGER|awk '{print $2}'`
if [ $run_staus = "RUNNING" ]
then
echo "$now_date $host_name $run_all normal-work"
else
echo "$now_date $host_name $run_all NOT-WORK"
fi
num_end=`cat /home/oracle/ogg_moni/temp_ogg.txt|wc -l`
i=1
until [[ $i -gt $num_end ]]; do
run_all=`awk 'NR=='$i' {print $0}' /home/oracle/ogg_moni/temp_ogg.txt`
run_name=`awk 'NR=='$i' {print $3}' /home/oracle/ogg_moni/temp_ogg.txt`
run_staus=`awk 'NR=='$i' {print $2}' /home/oracle/ogg_moni/temp_ogg.txt`
if [ $run_staus = "RUNNING" ]
then
((run_check=`awk 'NR=='$i' {print $4}' /home/oracle/ogg_moni/temp_ogg.txt|sed 's/://g'`))
if [ $run_check -gt 1500 ]
then
echo "$now_date $host_name $run_all normal-work ckpt-abnormal"
else
echo "$now_date $host_name $run_all normal-work ckpt-normal"
fi
else
echo "$now_date $host_name $run_all NOT WORK"
fi
let i=i+1
# To prevent the infinite loop
if [ $i -eq 50 ]
then
break
fi
done
多個機器監控
/home/oracle/ogg_moni/oggchk_all.sh
ssh 10.161.2.86 /home/oracle/ogg_moni/oggchk.sh
ssh 10.161.2.41 /home/oracle/ogg_moni/oggchk.sh
ssh 10.161.2.42 /home/oracle/ogg_moni/oggchk.sh
ssh 10.161.2.46 /home/oracle/ogg_moni/oggchk.sh
ssh 10.161.2.47 /home/oracle/ogg_moni/oggchk.sh
ssh 10.161.2.51 /home/oracle/ogg_moni/oggchk.sh
ssh 10.161.2.52 /home/oracle/ogg_moni/oggchk.sh
ssh 10.161.2.56 /home/oracle/ogg_moni/oggchk.sh
ssh 10.161.2.57 /home/oracle/ogg_moni/oggchk.sh
ssh 10.161.2.61 /home/oracle/ogg_moni/oggchk.sh
ssh 10.161.2.62 /home/oracle/ogg_moni/oggchk.sh
ssh 10.161.2.66 /home/oracle/ogg_moni/oggchk.sh
ssh 10.161.2.67 /home/oracle/ogg_moni/oggchk.sh
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29337971/viewspace-1142979/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 監控指令碼指令碼
- mysql監控指令碼MySql指令碼
- DBA監控指令碼指令碼
- session指令碼監控Session指令碼
- 埠監控指令碼指令碼
- oracle 監控指令碼Oracle指令碼
- listener監聽監控指令碼指令碼
- 【SQL監控】SQL完全監控的指令碼SQL指令碼
- stap監控IO指令碼指令碼
- 【shell】磁碟監控指令碼指令碼
- mysql 的一個監控指令碼,監控heartbeatMySql指令碼
- mysql mon 的一個監控指令碼,監控heartbeatMySql指令碼
- PostgreSQL之鎖監控指令碼SQL指令碼
- Oracle DBA常用監控指令碼Oracle指令碼
- memcached程式埠監控指令碼指令碼
- Nagios 監控ESXI指令碼iOS指令碼
- 監控cpu與memory指令碼指令碼
- 資料庫監控指令碼資料庫指令碼
- (Datagurad)監控指令碼指令碼
- 監控session數量指令碼Session指令碼
- 監控硬碟空間指令碼硬碟指令碼
- 監控sqlldr執行指令碼SQL指令碼
- 監控資料庫指令碼資料庫指令碼
- cacti自定義監控指令碼指令碼
- 監控系統告警指令碼集合指令碼
- 監控oracle表空間指令碼Oracle指令碼
- Goldengate for nrpe監控指令碼Go指令碼
- systemtap的網路監控指令碼指令碼
- stap監控cpu指令碼小結指令碼
- 指令碼監控MySQL伺服器指令碼MySql伺服器
- [zt]資料庫監控指令碼資料庫指令碼
- LINUX主機監控指令碼Linux指令碼
- 資料庫監控指令碼(一)資料庫指令碼
- 資料庫監控指令碼(二)資料庫指令碼
- 資料庫監控指令碼(三)資料庫指令碼
- oracle會話監控shell指令碼Oracle會話指令碼
- oracle空間使用監控指令碼Oracle指令碼
- linux監控,單行指令碼Linux指令碼