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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 【shell】磁碟監控指令碼指令碼
- PostgreSQL之鎖監控指令碼SQL指令碼
- 監控系統告警指令碼集合指令碼
- ORACLE OGG運維及日常監控Oracle運維
- Shell 系統資訊監控指令碼指令碼
- centos 監控web站點是否500 指令碼CentOSWeb指令碼
- shell指令碼:監控MySQL服務是否正常指令碼MySql
- 網路卡流量監控指令碼,python實現指令碼Python
- Shell指令碼監控MySQL主從狀態指令碼MySql
- 監控磁碟使用率的shell指令碼指令碼
- 關於前端指令碼異常監控的思考前端指令碼
- shell指令碼監控啟動停止weblogic服務指令碼Web
- 寫了個監控 ElasticSearch 程式異常的指令碼!Elasticsearch指令碼
- 在 Linux 上用 Bash 指令碼監控 messages 日誌Linux指令碼
- 使用Shell指令碼程式監控網站URL是否正常指令碼網站
- zabbix-mongodb監控指令碼(高效能、低佔用)MongoDB指令碼
- 透過shell指令碼監控日誌切換頻率指令碼
- 基於Ping和Telnet/NC的監控指令碼案例分析指令碼
- 用於自動監控磁碟使用情況的 Shell 指令碼指令碼
- 分享實用監控指令碼:使用Shell檢查程式是否存在指令碼
- 利用 Shell 指令碼來監控 Linux 系統的記憶體指令碼Linux記憶體
- MySQL 5.6大查詢和大事務監控指令碼(Python 2)MySql指令碼Python
- PowerShell 指令碼來監控 CPU、記憶體和磁碟使用情況:指令碼記憶體
- 如何用bash shell 指令碼監控 Linux記憶體、磁碟和 CPU?指令碼Linux記憶體
- sqlserver監控指令碼_發現某個等待就發出郵件SQLServer指令碼
- 用 Bash 指令碼監控 Linux 上的記憶體使用情況指令碼Linux記憶體
- OGG之 各種資料泵初始化指令碼指令碼
- 用 Linux Shell 指令碼來監控磁碟使用情況併傳送郵件Linux指令碼
- Linux下針對伺服器網路卡流量和磁碟的監控指令碼Linux伺服器指令碼
- 黑盒監控、日誌監控
- 案例五:shell指令碼實現定時監控http服務的執行狀態指令碼HTTP
- 【Azure Redis 快取】使用Python程式碼獲取Azure Redis的監控指標值 (含Powershell指令碼方式)Redis快取Python指標指令碼
- 6.prometheus監控--監控dockerPrometheusDocker
- TiDB監控實現--存活監控TiDB
- 寶塔liunx控制皮膚,監控程式斷了以後自動重啟的指令碼指令碼
- 監控
- 聊聊前端監控——錯誤監控篇前端
- 編碼:執行緒執行監控執行緒
- 淺析badjs原始碼(前端監控方案)JS原始碼前端