文件:pcsinfoupload.sh

路径:$HOME/ggscript/ggupload

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

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

日志路径:$HOME/gglog/ggupload

#!/bin/bashcd #HOMEif [ -f .profile ];then        . .profilefiif [ -f .bash_profile ];then         . .bash_profilefiecho "This sciprt is write by RenYi"mydate=`date +20%y-%m-%d-%H`hn=`echo $HOSTNAME`usr=`echo $USER`echo $hn-$usralterdate=`date +"%Y-%m-%d %H:%M:%S"`echo "HOSTNAME:" $hn"
" > $HOME/ggscript/ggupload/$hn-$usr.gginfoecho "user:" $usr"
" >> $HOME/ggscript/ggupload/$hn-$usr.gginfoecho "date:" $mydate"
" >> $HOME/ggscript/ggupload/$hn-$usr.gginfoecho "
" >> $HOME/ggscript/ggupload/$hn-$usr.gginfocd $HOME/ggserver(echo info all;echo exit)|./ggsci|grep -E "EXTRACT|REPLICAT" |awk 'BEGIN {FS=" +"} {print $3}' > $HOME/ggscript/ggupload/tempcd $HOME/ggscript/gguploadcat temp |tr A-Z a-z > temp2sed 's/$/.prm/' temp2 > temp3rm -f temp2i=1num=`sed -n '$=' temp3`echo "" >> $HOME/ggscript/ggupload/$hn-$usr.gginfoecho "PROCESS" >> $HOME/ggscript/ggupload/$hn-$usr.gginfoecho "SOURCE" >> $HOME/ggscript/ggupload/$hn-$usr.gginfoecho "SOURCEIP" >> $HOME/ggscript/ggupload/$hn-$usr.gginfoecho "TARGET" >> $HOME/ggscript/ggupload/$hn-$usr.gginfoecho "TARGETIP" >> $HOME/ggscript/ggupload/$hn-$usr.gginfoecho "DEFSFILE" >> $HOME/ggscript/ggupload/$hn-$usr.gginfoecho "DEFPRM" >> $HOME/ggscript/ggupload/$hn-$usr.gginfoecho "Status" >> $HOME/ggscript/ggupload/$hn-$usr.gginfoecho "LagAtChkpt" >> $HOME/ggscript/ggupload/$hn-$usr.gginfoecho "TimeSinceChkpt" >> $HOME/ggscript/ggupload/$hn-$usr.gginfoecho "" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo echo "        " >> $HOME/ggscript/ggupload/$hn-$usr.gginfocd $HOME/ggserverpro=`(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 $proecho $statusif [ "$status" == "STOPPED" ];then   (echo start mgr;echo exit)|./ggsci        echo "mgr starting"else            echo $statusfiecho  "" >> $HOME/ggscript/ggruntime/$hn-$usr.gginfoecho "$pro" >> $HOME/ggscript/ggupload/$hn-$usr.gginfoecho " " >> $HOME/ggscript/ggupload/$hn-$usr.gginfoecho " " >> $HOME/ggscript/ggupload/$hn-$usr.gginfoecho " " >> $HOME/ggscript/ggupload/$hn-$usr.gginfoecho " " >> $HOME/ggscript/ggupload/$hn-$usr.gginfoecho " " >> $HOME/ggscript/ggupload/$hn-$usr.gginfoecho " " >> $HOME/ggscript/ggupload/$hn-$usr.gginfoecho "$status" >> $HOME/ggscript/ggupload/$hn-$usr.gginfoecho " " >> $HOME/ggscript/ggupload/$hn-$usr.gginfoecho " " >> $HOME/ggscript/ggupload/$hn-$usr.gginfoecho  "" >>  $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/dirprmwhile [ "$i" -le "$num" ]do        echo "" >>  $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 "$pname" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo     while [ ${#source} -le 2 ]        do                source=none     done        if [ "$source" == "none" ];then                echo " " >> $HOME/ggscript/ggupload/$hn-$usr.gginfo        else                echo "$source" >> $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 " " >> $HOME/ggscript/ggupload/$hn-$usr.gginfo        else                echo "$sourceip" >> $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 " " >> $HOME/ggscript/ggupload/$hn-$usr.gginfo        else                echo "$target" >> $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 " " >> $HOME/ggscript/ggupload/$hn-$usr.gginfo        else                echo "$targetip" >> $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 " " >> $HOME/ggscript/ggupload/$hn-$usr.gginfo        else                echo "$defsfile" >> $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 " " >> $HOME/ggscript/ggupload/$hn-$usr.gginfo        else                echo "$defprm" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo        fi             while [ ${#status} -le 2 ]        do               status=none        done         if [ "$status" == "none" ];then                echo " " >> $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 "
$status"`  echo "$status" >> $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 "
$status"`                echo "$status" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo else                echo "$status" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo        fi        while [ ${#lag} -le 2 ]        do               lag=none        done         if [ "$lag" == "none" ];then                echo " " >> $HOME/ggscript/ggupload/$hn-$usr.gginfo   #     else  #              echo "$lag" >> $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 "
$lag"` echo "$lag" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo else echo "$lag" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo fi         while [ ${#time} -le 2 ]        do               time=none        done         if [ "$time" == "none" ];then                echo " " >> $HOME/ggscript/ggupload/$hn-$usr.gginfo  #      else #               echo "$time" >> $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 "
$time"`                      echo "$time" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo                         else                echo "$time" >> $HOME/ggscript/ggupload/$hn-$usr.gginfo        fi         echo "" >>  $HOME/ggscript/ggupload/$hn-$usr.gginfo        echo "        " >> $HOME/ggscript/ggupload/$hn-$usr.gginfo       ((i++));donecd $HOME/ggscript/gguploadecho "" >>$hn-$usr.gginfoecho " 
" >> $HOME/ggscript/ggupload/$hn-$usr.gginfoecho " 
" >> $HOME/ggscript/ggupload/$hn-$usr.gginfoecho " 
" >> $HOME/ggscript/ggupload/$hn-$usr.gginfocd $HOME/ggscript/ggupload exec ./upload.sh host149 $hn-$usr.gginfo sysinfo