变量 单引号 企业微信机器人-告警-拨测端口

1.拨测服务端口

[root@VM_0_111_centos shell]# cat check_http_code1.sh 
#!/bin/bash
while true
do
    cat input1.txt| while read line
    do
        return_Code=`$line ;echo $? `
        if [[ $return_Code -ne 0 ]]
        then
            date
            ip=`echo  $line|cut -d ' '  -f 5`
            port=`echo  $line|cut -d ' '  -f 6`
            echo "$line is down"
            curl 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=6200wo77-8sbd-4b0c-ac4d-e931nima267bcd' \
   -H 'Content-Type: application/json' \
   -d '
{
    "msgtype": "markdown",
    "markdown": {
        "content": "<font color=\"warning\">'$ip:$port'</font>  服务端口异常,请快速检查"
    }
}'
        fi
    done
    sleep 30
done
[root@VM_0_111_centos shell]# 

2.拨测对象

[root@VM_0_111_centos shell]# cat input1.txt 
nc -w 1 -z 10.0.0.111 7010
nc -w 1 -z 10.0.0.111 7011
nc -w 1 -z 10.0.0.111 20001

 

posted @ 2020-10-01 16:31  littlevigra  阅读(633)  评论(0编辑  收藏  举报