tuxedo服务检查脚本

应用系统的中间件是tuxedo,而服务进程会挂掉,人工很难查到哪些服务已经挂掉,因此编写了以下的脚本可以快速进行服务检查。

#!/bin/sh

. $HOME/.profile

if [ ! -f "ServersDetail.txt" ]; then
   touch "ServersDetail.txt"
else
   cat /dev/null >ServersDetail.txt
fi

#导出UBBCONFIG文件
tmunloadcf > UBBCONFIG

sed -n '/\*SERVERS/,/\*MODULES/p' UBBCONFIG > ServerName.txt

linenum=0
ServerFlag=0

while read ServerName
do
##从第一行开始读起
linenum=$(($linenum + 1))

   if [ $ServerFlag -eq 0 ];then
      #检查这行是否是服务名称的那行,如果是,那么返回值应该是1
      num1=$(echo $ServerName| grep SRVGRP |wc -l )
      if [ $num1 -eq 1 ];then
         #输出这行的第一列,并且去掉 双引号“,剩下的就是服务名称
         ResultServerName=$(echo $ServerName|awk '{print $1}'|sed 's/"//g')
                 ServerFlag=1
                 continue
      fi
        fi
   if [ $ServerFlag -eq 1 ];then
      lineflag=${linenum}"p"
          #取到 ”MIN=**“这部分
          numflag=$(echo $ServerName| grep "MIN=" |wc -l )
          if [ $numflag -eq 1 ];then
             #读取最小服务数
                 MinServerNum=$(echo ${ServerName#*MIN\=}|awk '{print $1}')
             #把服务名称和最小服务数输出到ServersDetail.txt文件中
         echo $ResultServerName $MinServerNum  >> ServersDetail.txt

             ##标识服务名、最小服务数都去到
             ServerFlag=0
           fi
   fi
done < ServerName.txt

#输出目前正在运行的服务
echo psr|tmadmin 2>&-|sed -e "/SHUTDOWN/d" -e "/^> $/d" -e "s/> //g" |awk '{print $1}' > RunningServer.txt
ErrCount=0
while read ServerName MinServerNum
do
        if [[ $ServerName == "GetRealRqrjFile" ]];then
           continue
        fi
        num1=0
        num1=$(cat RunningServer.txt|grep $ServerName|wc -l)
        if [ "$num1" -lt "$MinServerNum" -a "$num1" -ne 0 ];then
           echo "${ServerName}服务挂一部分了,准备重启!"
           ErrCount=$(($ErrCount + 1))
           #tmboot -s $ServerName
           #sleep 10
           #tmboot -s $ServerName
           #sleep 10
        elif [ "$num1" -eq 0 ];then
           echo "${ServerName}服务完全挂了,需要重启!"
           ErrCount=$(($ErrCount + 1))
           #tmshutdown -s $ServerName
           #sleep 10
           #tmshutdown -s $ServerName
           #sleep 10
       #tmboot -s $ServerName
           #sleep 10
           #tmboot -s $ServerName
           #sleep 10
           #tmboot -s $ServerName
           #sleep 10
        fi
done < ServersDetail.txt

echo "检查完毕,总共${ErrCount}个服务挂了!"

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

5448698yy

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值