“Php-worker重启脚本”的版本间的差异

来自linux中国网wiki
跳到导航 跳到搜索
 
(未显示同一用户的3个中间版本)
第37行: 第37行:
 
     salt 'prod-sns-es'  cmd.run 'docker exec  -i  docker-for-services_php-worker_1  supervisorctl restart production1.rabbitmq.recovery.addScoreHigh:production1.rabbitmq.recovery.addScoreHigh_03'
 
     salt 'prod-sns-es'  cmd.run 'docker exec  -i  docker-for-services_php-worker_1  supervisorctl restart production1.rabbitmq.recovery.addScoreHigh:production1.rabbitmq.recovery.addScoreHigh_03'
 
echo  "mq has restart "
 
echo  "mq has restart "
 +
DATE_TIME=`date +"%Y-%m-%d %H:%M.%S"`
 +
echo "${DATE_TIME}"  >>/data/logs/timelist
 
}
 
}
 
restartmq;  
 
restartmq;  
第43行: 第45行:
  
 
</pre>
 
</pre>
 +
 
=基础=
 
=基础=
 
<pre>
 
<pre>
第68行: 第71行:
  
 
</pre>
 
</pre>
 +
=see also=
 +
[https://blog.csdn.net/u014087707/article/details/53976576 shell脚本监控rabbitmq队列消息数量(堵塞情况)]
  
 
+
[https://blog.csdn.net/chihujiang3132/article/details/100929946 RabbitMQ通过HTTP API获取队列消息内容]
 
[[category:ops]]
 
[[category:ops]]

2019年12月27日 (五) 07:21的最新版本

mq_res

#score-addScore-high  队列大于 500 重启phpwork
# php work   and  mq 机器不在同一台上 
#有可能的话 另外两个mq 机器也要check 一下 
[root@mq01 sh]# cat mq_res.sh
#!/bin/bash
#Author: linuxsa.org
docker ps   | grep  rabbitmqCluster01
#if [ $? -eq 0 ]
if [ $? -ne 0 ]
then
echo  "No rabbitmq was found ,exit now"
exit 1
fi

qu=` docker  exec -i rabbitmqCluster01 rabbitmqadmin  --username=admin   --password=886 list queues | grep score-addScore-high |awk '{print $4}'`
#if [ $qu -eq 0 ]
if [ $qu -gt 50 ]
#if [ $qu -gt 500 ]
#if  $qu gt 500    
then
echo " qu  is 500,and then restart the  score-high"
echo "*****"
function restartmq
{
   salt 'prod-sns-es'  cmd.run 'docker ps   | grep  php-worker' 
    if [ $? -ne 0 ]
    then
    echo  "No phpworker was found ,exit now"
    exit 1
    fi
    
  salt 'prod-sns-es'  cmd.run 'docker exec  -i  docker-for-services_php-worker_1   supervisorctl restart production1.rabbitmq.recovery.addScoreHigh:production1.rabbitmq.recovery.addScoreHigh_00'
    salt 'prod-sns-es'  cmd.run 'docker exec  -i  docker-for-services_php-worker_1   supervisorctl restart production1.rabbitmq.recovery.addScoreHigh:production1.rabbitmq.recovery.addScoreHigh_01'
    salt 'prod-sns-es'  cmd.run 'docker exec  -i  docker-for-services_php-worker_1   supervisorctl restart production1.rabbitmq.recovery.addScoreHigh:production1.rabbitmq.recovery.addScoreHigh_02'
     salt 'prod-sns-es'  cmd.run 'docker exec  -i  docker-for-services_php-worker_1   supervisorctl restart production1.rabbitmq.recovery.addScoreHigh:production1.rabbitmq.recovery.addScoreHigh_03'
echo  "mq has restart "
DATE_TIME=`date +"%Y-%m-%d %H:%M.%S"`
echo "${DATE_TIME}"   >>/data/logs/timelist
}
restartmq; 

fi

基础

-eq           //等于

-ne           //不等于

-gt            //大于 (greater )

-lt            //小于  (less)

-ge            //大于等于

-le            //小于等于

命令的逻辑关系:

在linux 中 命令执行状态:0 为真,其他为假

逻辑与: &&
第一个条件为假时,第二条件不用再判断,最终结果已经有;
第一个条件为真时,第二条件必须得判断;
逻辑或: ||
逻辑非: !

see also

shell脚本监控rabbitmq队列消息数量(堵塞情况)

RabbitMQ通过HTTP API获取队列消息内容