#!/bin/bash while [ 1 ] do rtt=`ping -c 3 15.0.160.18 |grep rtt |awk '{print $4}' |awk -F'/' '{print $2}'` rtt=${rtt:-'0'} echo $rtt >> /tmp/jianhang_tunnel_monitor.log if [ $rtt -eq 0 ];then ps -fe|grep tunnel|grep -v grep|awk '{print $2}'|xargs kill -9 echo "jianhang tunnel is not stable " >> /tmp/jianhang_tunnel_monitor.log fi sleep 60 done
若专线对端ping 的延时 rtt 为0 , 脚本自动kill 掉自己的 montior进程, 通过阿里云的云监控进程监控来触发报警
阿里云云监控 进程监控 文档 https://www.cnblogs.com/weifeng1463/p/11591796.html