监控memcache tomcat脚本

[root@SOA ~]# more monitor.sh 
#!/bin/bash

P1=`ping -c1 192.168.2.115 |grep 192.168.2.115 |grep -c ttl`

if [ "$P1" == "1" ];then

          echo "2.115 is active"

   mem=`ssh 192.168.2.115 'ps -ef|grep memcached |grep "${mm_ports[$i]}"|grep -v grep|wc -l'`
   admin=`ssh 192.168.2.115 'ps -ef|grep tomcat-admin |grep "${mm_ports[$i]}"|grep -v grep|wc -l'`

    if [ "$admin" == "1" -a "$mem" == "1" ];then

               echo "all services is running"

      elif [ "$admin" == "0" -a "$mem" == "1" ];then

               echo "tomcat-admin is down,memcache is up"
                  cd /ServyouAPP/tomcat-admin/bin
                  nohup  ./catalina.sh  run & 
                  tail -20 nohup.out
      elif [ "$admin" == "1" -a "$mem" == "0" ];then

         echo "tomcat-admin is UP,memcache is DOWN"
	 echo "replace 2.115 memcache-config-file"
	 echo "startup 2.135 memcache"
	 sh /memStartUp.sh
	 #sh 192.168.2.115  /relace.sh
            
           
	   #ssh 192.168.2.115  'sh tomcatStop.sh'
	   kill -9 `ps aux|grep java|grep -v grep|awk '{print $2}'`
	   ssh 192.168.2.115  'sh /tomcatStart.sh'
           sleep 20
           sh  replace.sh
 	   kill -9 `ps aux|grep java|grep -v grep|awk '{print $2}'`
	   sh '/tomcatStart.sh'
           
      elif [ "$admin" == "0" -a "$mem" == "0" ];then

               echo "all service is down "

	 echo "replace 2.115 memcache-config-file"
	 echo "startup 2.135 memcache"
	 sh /memStartUp.sh
	 sh 192.168.2.115  '/relace.sh'
            
	   #ssh 192.168.2.115  'sh tomcatStop.sh'
	   ssh 192.168.2.115 'kill -9 `ps aux|grep java|grep -v grep|awk '{print $2}'`'
	   ssh 192.168.2.115  'sh /tomcatStart.sh'
           sleep 20
           sh replace.sh  
           kill -9 `ps aux|grep java|grep -v grep|awk '{print $2}'`
	   sh '/tomcatStart.sh'
           echo "service is STOP!"

fi
else
echo " 2.115 is NOT ACTIVE "
	   #ssh 192.168.2.115  'sh tomcatStop.sh'
	   ssh 192.168.2.115 'kill -9 `ps aux|grep java|grep -v grep|awk '{print $2}'`'
	   ssh 192.168.2.115  'sh /tomcatStart.sh'
           sleep 20
           sh replace.sh
	   kill -9 `ps aux|grep java|grep -v grep|awk '{print $2}'`
	   sh '/tomcatStart.sh'


fi

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值