码迷,mamicode.com
首页 > 其他好文 > 详细

监控端口,新疆模拟用户登录脚本

时间:2018-05-10 14:19:17      阅读:169      评论:0      收藏:0      [点我收藏+]

标签:port   team   bash   null   style   cal   nbsp   log   mail   

#!/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

 

监控端口,新疆模拟用户登录脚本

标签:port   team   bash   null   style   cal   nbsp   log   mail   

原文地址:https://www.cnblogs.com/wangmo/p/9019248.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!