zoukankan      html  css  js  c++  java
  • 监控端口,新疆模拟用户登录脚本

    #!/bin/bash
    
    date=`date +%Y%m%d-%H%M`
    count=0
    count1=0
    count2=0
    ip1=124.117.246.195 
    ip2=124.117.246.194
    port1=(443 80 6051 22101 11194)
    port2=(443 80)
    
    for (( k=0; k<3; k++ )) ; do
        sleep 300
        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
                continue
            fi
        done
        sleep 1
        for i in ${port2[@]} ; do
            nc -w 40 $ip1 -z ${i} >> /dev/null
            if [ $? != 0 ];then
                count1=$(($count1+1))
            fi
            if [ "$count1" == "3" ]; then
                echo "$date $ip1 ${i} 异常 !!!" | mail -s "新疆正式环境异常" team_cloud_service@syberos.com
                count1=0
                continue
            fi
        done
        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
            count2=$(($count2+1))
        fi
        if [ "$count2" == "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
                count2=0
                continue
        fi
    done
  • 相关阅读:
    NYOJ47 过河问题
    CodeForces1165
    LuoGuP3667
    ZROI#958
    ZROI#957
    KMP小结
    LuoGuP2742[模板]二维凸包
    ZROI#999
    ZROI#997
    ZROI#996
  • 原文地址:https://www.cnblogs.com/wangmo/p/9019248.html
Copyright © 2011-2022 走看看