首页 > 其他 > 详细

监控pptp拨号服务器是否正常

时间:2014-12-02 17:29:25      阅读:598      评论:0      收藏:0      [点我收藏+]

由于工作需要,编写了一个监控pptp拨号服务器是否正常脚本,希望可以帮到大家。


脚本如下:

#!/bin/bash

#清除上一回结果

##################

. /etc/profile

. ~/.bash_profile

#################

>/etc/ppp/peers/bj01_01.txt

>/etc/ppp/peers/gbr01_01.txt

>/etc/ppp/peers/gd01_01.txt

>/etc/ppp/peers/hk01_01.txt

>/etc/ppp/peers/sh01_01.txt

>/etc/ppp/peers/usa01_01.txt

for node in `cat /etc/ppp/peers/node.txt`

do

   /usr/bin/pon $node

   /bin/sleep 13

###检测拨号是否成功

   checkppp0=`/sbin/ifconfig|grep ppp0|awk ‘{print $1}‘`

   if [ $checkppp0 == ppp0 ]

   then 

       echo "0" >> /etc/ppp/peers/$node.txt

####添加路由到ppp0接口,使其走pptp

       /bin/sh /etc/ppp/peers/route.sh

####开始ping并检测节点ping是否ok           

       for ip in `cat /etc/ppp/peers/testip.txt|awk ‘{print $2}‘`

       do

         for name in `cat /etc/ppp/peers/testip.txt|awk ‘{print $1}‘`

         do

           loss=`/bin/ping -c 4 $ip|grep received|awk ‘{print $4}‘`

           if [ $loss = 0 ]

           then

               /bin/sed -i "s/1/& $name/" /etc/ppp/peers/$node.txt

               echo -e "1\t$name" >> /etc/ppp/peers/$node.txt

               /bin/sed -i ‘$d‘ /etc/ppp/peers/$node.txt

           fi

           /bin/sleep 1

         done

         break

       done

       /usr/bin/poff $node

       /bin/sleep 3

   else

       echo -e "1\t$node" >> /etc/ppp/peers/$node.txt

       continue

   fi

done


本文出自 “流星” 博客,请务必保留此出处http://461884.blog.51cto.com/451884/1585531

监控pptp拨号服务器是否正常

原文:http://461884.blog.51cto.com/451884/1585531

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!