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

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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


本文出自 “netsman” 博客,请务必保留此出处http://netsman.blog.51cto.com/5750076/1939644

以上是关于OGG运维优化脚本(十三)-信息同步类--进程信息上传的主要内容,如果未能解决你的问题,请参考以下文章

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

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

OGG运维优化脚本-信息修改类--长事务跳过

OGG运维优化脚本-查询维护类--进程重复表检查

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

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