OGG运维优化脚本(十三)-信息同步类--进程信息上传

文件:pcsinfoupload.sh

路径:$HOME/ggscript/ggupload

功能:用于查询所有进程的部署时填写好的详细配置注释信息,进程状态,生成以HTML格式的文件,并通过上传脚本定时上传至某台目标机器,通过其他脚本整合形成网页

以网页信息浏览所有进程的监控信息

日志路径:$HOME/gglog/ggupload

#!/bin/bash
cd #HOME
if [ -f .profile ];then
        . .profile
fi

if [ -f .bash_profile ];then 
        . .bash_profile
fi

echo "This sciprt is write by RenYi"
mydate=`date +20%y-%m-%d-%H`
hn=`echo $HOSTNAME`
usr=`echo $USER`
echo $hn-$usr
alterdate=`date +"%Y-%m-%d %H:%M:%S"`
echo "HOSTNAME:" $hn"<br>" > $HOME/ggscript/ggupload/$hn-$usr.gginfo
echo "user:" $usr"<br>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
echo "date:" $mydate"<br>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
echo "<table border="1">" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
cd $HOME/ggserver
(echo info all;echo exit)|./ggsci|grep -E "EXTRACT|REPLICAT" |awk ‘BEGIN {FS=" +"} {print $3}‘ > $HOME/ggscript/ggupload/temp

cd $HOME/ggscript/ggupload
cat temp |tr A-Z a-z > temp2
sed ‘s/$/.prm/‘ temp2 > temp3
rm -f temp2
i=1
num=`sed -n ‘$=‘ temp3`

echo "<tr>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
echo "<td>PROCESS</td>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
echo "<td>SOURCE</td>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
echo "<td>SOURCEIP</td>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
echo "<td>TARGET</td>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
echo "<td>TARGETIP</td>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
echo "<td>DEFSFILE</td>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
echo "<td>DEFPRM</td>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
echo "<td>Status</td>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
echo "<td>LagAtChkpt</td>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
echo "<td>TimeSinceChkpt</td>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
echo "</tr>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
 echo "        " >> $HOME/ggscript/ggupload/$hn-$usr.gginfo

cd $HOME/ggserver
pro=`(echo info all;echo exit)|./ggsci|grep -E "MANAGER"|awk ‘BEGIN {FS=" +"} {print $1}‘`
status=`(echo info all;echo exit)|./ggsci|grep -E "MANAGER"|awk ‘BEGIN {FS=" +"} {print $2}‘`
echo $pro
echo $status
if [ "$status" == "STOPPED" ];then
   (echo start mgr;echo exit)|./ggsci
        echo "mgr starting"
else    
        echo $status
fi

echo  "<tr>" >> $HOME/ggscript/ggruntime/$hn-$usr.gginfo
echo "<td>$pro</td>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
echo "<td>&nbsp;</td>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
echo "<td>&nbsp;</td>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
echo "<td>&nbsp;</td>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
echo "<td>&nbsp;</td>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
echo "<td>&nbsp;</td>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
echo "<td>&nbsp;</td>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
echo "<td>$status</td>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
echo "<td>&nbsp;</td>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
echo "<td>&nbsp;</td>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
echo  "</tr>" >>  $HOME/ggscript/ggupload/$hn-$usr.gginfo

(echo info all;echo exit)|./ggsci|grep -E "EXTRACT|REPLICAT" |awk ‘BEGIN {FS=" +"} {print $2}‘ > $HOME/ggscript/ggupload/Status
(echo info all;echo exit)|./ggsci|grep -E "EXTRACT|REPLICAT" |awk ‘BEGIN {FS=" +"} {print $4}‘ > $HOME/ggscript/ggupload/LagAtChkpt
(echo info all;echo exit)|./ggsci|grep -E "EXTRACT|REPLICAT" |awk ‘BEGIN {FS=" +"} {print $5}‘ > $HOME/ggscript/ggupload/TimeSinceChkpt 

cd $HOME/ggserver/dirprm
while [ "$i" -le "$num" ]
do
        echo "<tr>" >>  $HOME/ggscript/ggupload/$hn-$usr.gginfo
        fname=`sed -n $i‘p‘ $HOME/ggscript/ggupload/temp3`
        pname=`sed -n $i‘p‘ $HOME/ggscript/ggupload/temp`
        source=`cat $fname|grep -w "source" |cut -d ‘:‘ -f 2`
        status=`sed -n $i‘p‘ $HOME/ggscript/ggupload/Status`
        lag=`sed -n $i‘p‘ $HOME/ggscript/ggupload/LagAtChkpt`
	echo $lag > txm
	lag2=`sed ‘s/://g‘ txm`
        time=`sed -n $i‘p‘ $HOME/ggscript/ggupload/TimeSinceChkpt`
	echo $time > txm
	time2=`sed ‘s/://g‘ txm`
        echo "<td>$pname</td>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo

     while [ ${#source} -le 2 ]
        do
                source=none
     done
        if [ "$source" == "none" ];then
                echo "<td>&nbsp;</td>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
        else
                echo "<td>$source</td>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
        fi

        sourceip=`cat $fname|grep -w "sourceIP" |cut -d ‘:‘ -f 2`
        while [ ${#sourceip} -le 2 ]
        do
               sourceip=none
        done
         if [ "$sourceip" == "none" ];then
                echo "<td>&nbsp;</td>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
        else
                echo "<td>$sourceip</td>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
        fi
        target=`cat $fname|grep -w "target" |cut -d ‘:‘ -f 2`
        while [ ${#target} -le 2 ]
        do
               target=none
        done
         if [ "$target" == "none" ];then
                echo "<td>&nbsp;</td>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
        else
                echo "<td>$target</td>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
        fi
        targetip=`cat $fname|grep -w "targetIP" |cut -d ‘:‘ -f 2`
         while [ ${#targetip} -le 2 ]
        do
               targetip=none
        done
         if [ "$targetip" == "none" ];then
                echo "<td>&nbsp;</td>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
        else
                echo "<td>$targetip</td>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
        fi
        defsfile=`cat $fname|grep -w "defsfile" |cut -d ‘:‘ -f 2`
         while [ ${#defsfile} -le 2 ]
        do
               defsfile=none
        done
         if [ "$defsfile" == "none" ];then
                echo "<td>&nbsp;</td>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
        else
                echo "<td>$defsfile</td>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
        fi
        defprm=`cat $fname|grep -w "defprm" |cut -d ‘:‘ -f 2`
         while [ ${#defprm} -le 2 ]
        do
               defprm=none
        done
         if [ "$defprm" == "none" ];then
                echo "<td>&nbsp;</td>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
        else
                echo "<td>$defprm</td>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
        fi
     
        while [ ${#status} -le 2 ]
        do
               status=none
        done
         if [ "$status" == "none" ];then
                echo "<td>&nbsp;</td>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
        elif [ "$status" == "ABENDED" ];then
	echo "$alterdate GGS-ERROR $pname has been  already ABENDED! (alert by Ren‘s Monitor Script)" >> $HOME/ggserver/ggserr.log
		status=`echo "<font size="3" color="red">$status</font>"` 
		echo "<td>$status</td>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
	elif [ "$status" == "STOPED" ];then
		echo "$alterdate GGS-ERROR $pname has been already STOPED! (alert by Ren‘s Monitor Script)" >> $HOME/ggserver/ggserr.log
                status=`echo "<font size="3" color="blue">$status</font>"`
                echo "<td>$status</td>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
	else
                echo "<td>$status</td>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
        fi

        while [ ${#lag} -le 2 ]
        do
               lag=none
        done
         if [ "$lag" == "none" ];then
                echo "<td>&nbsp;</td>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
   #     else
  #              echo "<td>$lag</td>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
        fi
	if [ $lag2 -ge 020000  ];then
		 echo "$alterdate GGS-ERROR $pname LagAtChkpt has been delay for $lag! (alert by Ren‘s Monitor Script)" >> $HOME/ggserver/ggserr.log
		lag=`echo "<font size="3" color="red">$lag</font>"`
		echo "<td>$lag</td>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
	else
		echo "<td>$lag</td>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
	fi	

        while [ ${#time} -le 2 ]
        do
               time=none
        done
         if [ "$time" == "none" ];then
                echo "<td>&nbsp;</td>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
  #      else
 #               echo "<td>$time</td>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
        fi
	if [ $time2 -ge 020000  ];then
		echo "$alterdate GGS-ERROR $pname TimeSinceChkpt has been delay for $time! (alert by Ren‘s Monitor Script)" >> $HOME/ggserver/ggserr.log
                time=`echo "<font size="3" color="red">$time</font>"`      
                echo "<td>$time</td>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo                 
        else
                echo "<td>$time</td>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
        fi 

        echo "</tr>" >>  $HOME/ggscript/ggupload/$hn-$usr.gginfo
        echo "        " >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
       ((i++));
done
cd $HOME/ggscript/ggupload
echo "</table>" >>$hn-$usr.gginfo
echo "&nbsp;<br>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
echo "&nbsp;<br>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
echo "&nbsp;<br>" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo
cd $HOME/ggscript/ggupload
 exec ./upload.sh host149 $hn-$usr.gginfo sysinfo
时间: 2024-12-29 11:21:50

OGG运维优化脚本(十三)-信息同步类--进程信息上传的相关文章

OGG运维优化脚本(十二)-信息同步类--信息上传

文件: upload.sh 路径:$HOME/ggscript/ggupload 功能:该脚本不会直接使用,为满足其他脚本进行信息上传而设计,在脚本内直接调用上传相应的文件信息 他会读取系统信息配置文件sysinfo内的系统配置信息 范例 [detest#] Ip-MTMyLjEyMS4xMDEuODYK UserName-Z2dzCg== PassWord-Z2dzxxxxxx Port-MjIK path-L2RhdGExL2dncy9nZ3NlcnZlci9kaXJkZWYK [#dete

OGG运维优化脚本(八)-查询维护类--批量查询

文件名:search.sh 路径:$HOME/ggscript/ggsearch 功能:该脚本用于满足检查goldengate进程具体配置情况的需求而设计 通过edit脚本选择调用 #!/bin/bash echo "This script is used to search the specified table!(created by renyi)" echo $dir dir=$PWD  cd $HOME/ggserver echo "Please select the

OGG运维优化脚本(十五)-信息同步类--错误日志同步

文件:logtitle.sh  log.sh 路径:$HOME/ggscript/gginfo 该脚本主要用于每小时检查ggserr.log内包含error关键字的信息(具体可调整) 然后拼接成html格式文件发送给监控网站 该脚本需要配合crontab计划任务使用 logtile.sh  每月月初执行一次,生成文件头 #!/bin/bash cd $HOME if [ -f .profile ];then         . .profile fi if [ -f .bash_profile 

OGG运维优化脚本(十四)-信息同步类--定义文件自动下发

文件: resend.sh 路径:$HOME/ggscript/ggdef 功能:该脚本为用于应对目标端因为定义文件失效导致的进程异常中断所设计 因源端业务经常未通知目标端以及系统组自行修改表结构 因此设计该脚本自动生成定义文件,并发送至指定目标机器的相应路径,以用于目标机器REPLICATE进程的正常读取 日志路径:$HOME/gglog/ggupload #!/bin/bash cd $HOME if [ -f .profile ];then         . .profile fi if

OGG运维优化脚本(十)-查询维护类--进程详细信息查询

文件:processinfo.sh 路径:$HOME/ggscript/ggupload 功能:该脚本为满足维护配置时检查所有goldengate进程的详细源端目标端,定义文件等信息而设计 #!/bin/bash export PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin"  echo "This sciprt is write by RenYi" hn=`e

OGG运维优化脚本(二. 五)-信息修改类--快速加表

文件名:add.sh 所在路径:$HOME/ggadd 功能:批量加表脚本的优化版,用于针对少量加表需求,包括重复配置表过滤功能以及附加日志自动增加功能 该脚本通过alias方式写入账户系统配置文件.profile 和.bash_profile通过命令使用 日志路径:$HOME/ggscript/ggadd 具体脚本内容 #!/bin/bash if [ $# -eq 0 ]; then         echo "info EXTRACT TABLE AREA user"      

OGG运维优化脚本(七)-信息修改类--快速注释

文件名:note.sh 路径:$HOME/ggscript/ggnote 功能:该脚本用于注释指定行的配置表,配合重复值检查脚本repeat.sh使用 通过alias初始化入.profile或.bash_profile文件,通过指令note使用 日志路径:$HOME/gglog/ggnote #!/bin/bash if [ $# -eq 0 ]; then         echo "note EXTRACT rowsnum"         exit 2 fi if [ $# -e

OGG运维优化脚本(三)-信息修改类--附加日志增加

文件名: addtrandata.sh 所在路径:$HOME/ggscript/gginsert 功能:用于批量增加表附加日志,属于从加表脚本中独立出来的功能,用于应对表附加日志丢失以及加表附加日志增加失败的情况 #!/bin/bash echo "This script will add trandata( by RenYi)" ls -lrt $HOME/ggserver/dirprm/e*.prm echo "The EXTRACT process:" cd 

OGG运维优化脚本(六)-信息修改类--批量取消注释

文件名:recomment.sh 路径: $HOME/ggscript/ggcomment 功能:该脚本用于批量取消注释,配合批量注释脚本使用,基本功能相反,操作步骤完全一致.通过edit脚本选择使用 日志路径:$HOME/gglog/ggcomment #!/bin/bash backuptime=`date +%Y%m%d-%H%M` echo "This script is used to reannotate the specified table!(created by renyi)&