标签:int 登陆脚本 grep -v mail -s tool kill 新疆 模拟 for
#!/bin/bash date=`date +%Y%m%d-%H%M` count=0 ip1=124.117.246.195 ip2=124.117.246.194 port1=(443 80 6051 22101 11194) port2=(443 80) for (( k=0; k<5; k++ )) ; do sleep 1 for i in ${port1[@]} ; do nc -w 40 $ip2 -z ${i} >> /dev/null if [ $? != 0 ];then count=$(($count+1)) fi if [ "$count" == "3" ]; then echo "$date $ip2 ${i} 异常 !!!" | mail -s "新疆正式环境异常" team_cloud_service@syberos.com count=0 break fi done done sleep 1 count=0 for (( k=0; k<5; k++ )) ; do sleep 1 for i in ${port2[@]} ; do nc -w 40 $ip1 -z ${i} >> /dev/null if [ $? != 0 ];then count=$(($count+1)) fi if [ "$count" == "3" ]; then echo "$date $ip1 ${i} 异常 !!!" | mail -s "新疆正式环境异常" team_cloud_service@syberos.com echo send mail count=0 break fi done done sleep 1 count=0 for (( k=0; k<5; k++ )) ; do sleep 2 ps aux | grep multimech-run | grep -v grep | awk ‘{print $2}‘ | xargs kill -9 cd /usr/local/src/python-scripts/pmtool multimech-run my_send_login > /usr/local/src/scripts/xinjiang.txt sed -i ‘20,$d‘ /usr/local/src/scripts/xinjiang.txt diff /usr/local/src/scripts/xinjiang.txt /usr/local/src/scripts/xinjiang_ok.txt > /dev/null if [ $? != 0 ];then count=$(($count+1)) fi if [ "$count" == "3" ]; then multimech-run my_send_login > /usr/local/src/scripts/xinjiang.txt cat /usr/local/src/scripts/xinjiang.txt | mail -s "新疆正式环境异常" team_cloud_service@syberos.com count=0 break fi done
标签:int 登陆脚本 grep -v mail -s tool kill 新疆 模拟 for
原文地址:https://www.cnblogs.com/wangmo/p/8985659.html