Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2517710
  • 博文数量: 540
  • 博客积分: 11289
  • 博客等级: 上将
  • 技术积分: 6160
  • 用 户 组: 普通用户
  • 注册时间: 2008-02-11 20:27
个人简介

潜龙勿用,见龙在田

文章分类

全部博文(540)

文章存档

2018年(2)

2013年(5)

2012年(24)

2011年(104)

2010年(60)

2009年(217)

2008年(128)

分类:

2010-08-24 16:06:04

[root@SHCTC-GAME5-151 release1]# cat router-conn-chk.sh
#!/bin/bash
SSHD="/app/oslinkd/bin/ssh -T"
BASE_DIR=`pwd`
SRV_FILE="$BASE_DIR/serversdmz.txt"
SRV_LIST="$BASE_DIR/checklist.txt"
SRV_TYPE=`awk '!/^#/{print $1}' $SRV_LIST|egrep -i -v "router|profile|ue|pt|centercatalog|catalog"`
#for srv_type in tunnel logic hall market account gm pay ui dbcache act misc state rank task syn family ap
for srv_type in $SRV_TYPE
do
#/app/oslinkd/bin/ssh  "netstat -anp|awk '\$5~/:5102[1-4]/&&/EST/{t++}'END'{printf "%d",t}'"
ALL_IP=`awk '!/(^#|mysql)/&&/\<'$srv_type'\>/{print $2}' $SRV_FILE`
for sip in $ALL_IP
do
fun_conn(){
conn_proc="`$SSHD $sip "$RCMD"`"
string=`echo $srv_type|awk -F- '{print $1}'`
statu_proc="`$SSHD $sip "ps aux|grep $string|grep dmz|grep -v grep"`"
    if [ "$conn_proc" -eq 0 ] && [ -z "$statu_proc" ];then
        #echo "Perhaps $srv_type process is not running. | `grep $srv_type $SRV_FILE|egrep -v "^#"`";
        cmd=`grep "\<$srv_type\>" $SRV_FILE|egrep -v "^#"`
        awk 'BEGIN{printf "%-43s","Perhaps '$srv_type' process is not running.";printf "\n"}'
    else
    mod=`expr $conn_proc % 4`;
    case $mod in
    0)
        #echo "conn count: $conn_proc  |  `grep $srv_type $SRV_FILE|egrep -v "^#"`"  
        cmd=`grep "\<$srv_type\>" $SRV_FILE|egrep -v "^#"`
        awk 'BEGIN{printf "%-12s","'$srv_type'";printf "%-16s","conn count: '$conn_proc'";printf "\n"}'
        ;;
    *)
        echo "Abnormal! |  `grep $srv_type $SRV_FILE`"
    ;;
    esac
    fi
}
string=`echo $srv_type|awk -F- '{print $1}'`
    if [ x"$string" = x"dbcache" ];then
        RCMD="netstat -anp|awk '\$5~/:5102[1-4]/&&/EST/&&/(dmdb|frienddb|gamedb|itemdb|namedb|maildb)/'|grep -v conn|wc -l"
        statu_proc="`$SSHD $sip "ps aux|egrep 'dmdb|frienddb|gamedb|itemdb|namedb|maildb'|grep dmz|grep -v grep"`"
        fun_conn;
     else
    #判断连接数为4的整数倍正常;其他情况报异常.
    RCMD="netstat -anp|awk '\$5~/:5102[1-4]/&&/EST/&&/'$string'/'|grep -v conn|wc -l"
        fun_conn
    fi
done
done
阅读(760) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~