Goldengate for nrpe監控指令碼
Goldengate for nrpe監控指令碼
/usr/bin/sudo /usr/local/nagios/libexec/check_gghealth -d ebpdb -w 60 -c 180
最新版:增加對時間判斷
/usr/bin/sudo /usr/local/nagios/libexec/check_gghealth -d ebpdb -w 60 -c 180
最新版:增加對時間判斷
點選(此處)摺疊或開啟
-
#!/bin/bash
-
# ========================================================================================
-
# goldengate health plugin for Nagios
-
#
-
# Written by : dudong
-
# Release : 1.0.0
-
# Creation date : 2015-02-11
-
# Description : Nagios plugin (script) to check goldengate health .
-
# This script has been designed and written on Linux System.
-
#
-
# USAGE : ./check_gg_health.sh [-d (disk)]
-
#
-
# Exemple: ./check_cpu_stats.sh
-
#
-
#
-
# HISTORY :
-
# Release | Date | Authors | Description
-
# --------------+---------------+----------------------+-----------------------------------
-
# 1.0.0 | 2015.02.11 | | Create the script
-
# -----------------------------------------------------------------------------------------
-
# NOTICE:
-
#-----------------------------------------------------------------------------------------
-
# You should have the root Permissions ,You can use sudo to realize .
-
# -----------------------------------------------------------------------------------------
-
-
# Nagios return codes
-
DATABASE=
-
WARNING=
-
CRITICAL=
-
-
BRIEF=0
-
SILENT=0
-
-
#定義 nagios返回的狀態變數
-
STATE_OK=0
-
STATE_WARNING=1
-
STATE_CRITICAL=2
-
STATE_UNKNOWN=3
-
-
# 外掛描述資訊
-
PROGNAME=\"check_gghealth\"
-
RELEASE=\"Revision 1.0.0\"
-
AUTHOR=\"(c) 2015 \"
-
-
# Functions plugin usage
-
# 外掛的使用方法函式
-
-
print_release() {
-
echo \"$RELEASE $AUTHOR\"
-
}
-
-
print_usage() {
-
echo \"\"
-
echo \"$PROGNAME $RELEASE - Goldengate health check script for Nagios\"
-
echo \"\"
-
echo \"Usage: check_gghealth\"
-
echo \"\"
-
echo \" -d database\"
-
echo \"\"
-
echo \" -w warning\"
-
echo \"\"
-
echo \" -c critical\"
-
echo \"\"
-
echo \" -h Show this page\"
-
echo \"\"
-
echo \"\"
-
echo \" -v check the version\"
-
echo \"Usage: $PROGNAME\"
-
echo \"Usage: $PROGNAME --help\"
-
echo \"\"
-
exit 0
-
}
-
-
print_help() {
-
print_usage
-
echo \"\"
-
echo \"This plugin will check gg health \"
-
echo \"\"
-
exit 0
-
}
-
-
-
# 傳遞引數
-
-
# process args
-
while [ ! -z \"$1\" ]; do
-
case $1 in
-
-b) BRIEF=1 ;;
-
-s) SILENT=1 ;;
-
-d) shift; DATABASE=$1; DATABASE=${1////!} ;;
-
-w) shift; WARNING=$1 ;;
-
-c) shift; CRITICAL=$1 ;;
-
-h) show_help; exit 1 ;;
-
esac
-
shift
-
done
-
-
-
# 生效變數檔案
-
#SIDNAME=ebpdb
-
cd /home/oracle
-
. ./prof_$DATABASE
-
cd $OGG_HOME
-
-
mkdir -p /tmp/ggcheck/
-
echo \"info all\" | ./ggsci |grep -E \"MANAGER|EXTRACT|REPLICAT\" > /tmp/ggcheck/gginfo.tmp
-
chmod 776 /tmp/ggcheck/gginfo.tmp
-
cd /tmp
-
filename_tmp=/tmp/ggcheck/gginfo.tmp
-
-
awk -F\':|[ ]+|[ ][ ]+\' \'{sum=($4+$7)*3600+($5+$8)*60+($6+$9);print $0,sum}\' $filename_tmp > /tmp/ggcheck/gginfo.sum
-
-
filename=/tmp/ggcheck/gginfo.sum
-
-
#獲取manage程式狀態資訊
-
#head -1 $filename > /tmp/ggcheck/manage_message
-
#manage_status=$(cat /tmp/ggcheck/manage_message | grep \"RUNNING\" | wc -l)
-
manage_status=$( head -1 $filename | grep \"RUNNING\" | wc -l)
-
-
-
#獲取所有程式時間資訊
-
sed -i \'1d\' $filename
-
message_ok=$(awk -F\':|[ ]+|[ ][ ]+\' \'{print $3\"=\" $10\"s\"\" \"}\' $filename)
-
#echo $message_ok |sed \'N;s/\\n//g\' > /tmp/ggcheck/ok_msg
-
#ok_msg=$(cat /tmp/ggcheck/ok_msg)
-
ok_msg=$(echo $message_ok |sed \'N;s/\\n//g\')
-
-
#len= sed -n \'$=\' $filename
-
-
-
#獲取時間資訊
-
#awk -F\':|[ ]+|[ ][ ]+\' \'{print $10}\' $filename > /tmp/ggcheck/time_msg
-
-
-
#
-
NUM1=$(cat $filename | grep \"ABENDED\" | wc -l)
-
NUM2=$(cat $filename | grep \"STOPPED\" | wc -l)
-
-
#程式掛起資訊
-
#find $filename |xargs grep -ri \"ABENDED\" > /tmp/ggcheck/abended.msg
-
#ABENDED_MSG=$(awk \'{print $3, \"is abended, and lag time is \" $6\"!\"}\' /tmp/ggcheck/abended.msg)
-
ABENDED_MSG=$(find $filename |xargs grep -ri \"ABENDED\" |awk \'{print $3, \"is abended, and lag time is \" $6\"!\"}\')
-
-
MESSAGE2=$(find $filename |xargs grep -ri \"STOPPED\")
-
MESSAGE3=$(find $filename |xargs grep -ri \"RUNNING\")
-
-
-
#echo \"$WARNING\"
-
#echo \"$CRITICAL\"
-
#echo \"$DATABASE\"
-
-
#時間檔案內是否有大於warning和critical的數字
-
#WARNING_STATUS=$( cat /tmp/ggcheck/time_msg | while read i; do if [[ \"$i\" -ge \"$WARNING\" ]]; then echo $i; fi; done | wc -l)
-
#CRITICAL_STATUS=$( cat /tmp/ggcheck/time_msg | while read i; do if [[ \"$i\" -ge \"$CRITICAL\" ]]; then echo $i; fi; done | wc -l)
-
WARNING_STATUS=$( awk -F\':|[ ]+|[ ][ ]+\' \'{print $10}\' $filename | while read i; do if [[ \"$i\" -ge \"$WARNING\" ]]; then echo $i; fi; done | wc -l)
-
CRITICAL_STATUS=$( awk -F\':|[ ]+|[ ][ ]+\' \'{print $10}\' $filename | while read i; do if [[ \"$i\" -ge \"$CRITICAL\" ]]; then echo $i; fi; done | wc -l)
-
-
-
if [ \"$manage_status\" = \"0\" ]; then
-
echo \"Critical - Goldengate Manage process is stopped!!\"
-
exit $STATE_CRITICAL
-
-
elif [ \"$NUM1\" -ne \"0\" ]; then
-
echo \"CRITICAL - Goldengate status is critical,\" \"$ABENDED_MSG | \" \"$ok_msg\"
-
exit $STATE_CRITICAL
-
-
else
-
# cat /tmp/ggcheck/time_msg | while read i
-
# for i in \'cat /tmp/ggcheck/time_msg\'
-
# do
-
# if [[ \"$i\" -lt \"$WARNING\" ]]; then
-
# if [ `echo $i | awk -v bi=$WARNING \'{print($1<bi)?\"1\":\"0\"}\'` -eq \"1\" ]; then
-
# echo \"OK - Goldengate status is ok | \" \"$ok_msg\"
-
# exit $STATE_OK
-
# elif [[ \"$i\" -ge \"$WARNING\" && \"$i\" -le \"$CRITICAL\" ]]; then
-
# echo \"WARNING - Goldengate status is WARNING | \" \"$ok_msg\"
-
# exit $STATE_WARNING
-
# else
-
# echo \"CRITICAL - Goldengate status is CRITICAL | \" \"$ok_msg\"
-
# exit $STATE_CRITICAL
-
# fi
-
# done
-
if [ \"$CRITICAL_STATUS\" -ne \"0\" ]; then
-
echo \"CRITICAL - Goldengate status is CRITICAL | \" \"$ok_msg\"
-
exit $STATE_CRITICAL
-
-
elif [ \"$WARNING_STATUS\" -ne \"0\" ]; then
-
echo \"WARNING - Goldengate status is WARNING | \" \"$ok_msg\"
-
exit $STATE_WARNING
-
-
else
-
echo \"OK - Goldengate status is ok | \" \"$ok_msg\"
-
exit $STATE_OK
-
-
fi
-
-
fi
-
#
- #
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/30936525/viewspace-2097981/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 使用nrpe監控Goldengate程式指令碼Go指令碼
- 監控指令碼指令碼
- Nrpe 監控Linux系統Linux
- Nrpe for Windows監控檢測命令Windows
- mysql監控指令碼MySql指令碼
- DBA監控指令碼指令碼
- session指令碼監控Session指令碼
- 埠監控指令碼指令碼
- oracle 監控指令碼Oracle指令碼
- listener監聽監控指令碼指令碼
- 【SQL監控】SQL完全監控的指令碼SQL指令碼
- ogg監控指令碼指令碼
- stap監控IO指令碼指令碼
- 【shell】磁碟監控指令碼指令碼
- mysql 的一個監控指令碼,監控heartbeatMySql指令碼
- Windows NRPE監控標準規範(轉)Windows
- mysql mon 的一個監控指令碼,監控heartbeatMySql指令碼
- PostgreSQL之鎖監控指令碼SQL指令碼
- Oracle DBA常用監控指令碼Oracle指令碼
- memcached程式埠監控指令碼指令碼
- Nagios 監控ESXI指令碼iOS指令碼
- 監控cpu與memory指令碼指令碼
- 資料庫監控指令碼資料庫指令碼
- (Datagurad)監控指令碼指令碼
- 監控session數量指令碼Session指令碼
- 監控硬碟空間指令碼硬碟指令碼
- 監控sqlldr執行指令碼SQL指令碼
- 監控資料庫指令碼資料庫指令碼
- cacti自定義監控指令碼指令碼
- 監控系統告警指令碼集合指令碼
- 監控oracle表空間指令碼Oracle指令碼
- systemtap的網路監控指令碼指令碼
- stap監控cpu指令碼小結指令碼
- 指令碼監控MySQL伺服器指令碼MySql伺服器
- [zt]資料庫監控指令碼資料庫指令碼
- LINUX主機監控指令碼Linux指令碼
- 資料庫監控指令碼(一)資料庫指令碼
- 資料庫監控指令碼(二)資料庫指令碼