linux 拨号+squid监控脚本

发布时间:2017-5-26 2:35:14 编辑:www.fx114.net 分享查询网我要评论
本篇文章主要介绍了"linux 拨号+squid监控脚本 ",主要涉及到linux 拨号+squid监控脚本 方面的内容,对于linux 拨号+squid监控脚本 感兴趣的同学可以参考一下。

客户端

#!/bin/bash#get_memory-infoa=`free -m|grep Mem|awk '{print$2}'`                    #total-memoryb=`free -m|grep Mem|awk '{print$3}'`                    #used-memorymem_percent=`awk 'BEGIN{printf "%.2f%\n",('$b'/'$a')*100}'`     #used-memory-%#echo $mem_percent#get_network_infoping -W 5  -c 1 114.114.114.114 > /dev/null 2>&1if [ $? -eq 0 ];then        net_status="0"else        net_status="1"fi#echo $net_status#get_squid_process_statussquid_status=`systemctl status squid|grep Active|awk '{print$2}'`if [ "$squid_status" = "active" ];then        squid_status_code="0"else        squid_status_code="1"fi#echo $squid_status_codeecho "\"memory\":\""$mem_percent"\",\""net_status\":\""$net_status"\",\""squid_status\":\""$squid_status_code"\""

服务端:

#!/bin/bashmachine_ip=$1machine_port=$2 f1=`cat /proc/sys/kernel/random/uuid` f2=`cat /proc/sys/kernel/random/uuid` f3=`cat /proc/sys/kernel/random/uuid`rm -rf /tmp/.$f1.txt /tmp/.$f2.txt /tmp/.$f3.txttouch /tmp/.$f1.txt /tmp/.$f2.txt /tmp/.$f3.txt{ #echo "get machine_status" machine_status=`ssh -o ConnectTimeout=6 -p $machine_port root@$machine_ip 'sh /root/get_machine_info.sh'`  len=`echo $machine_status|wc -c` if [ $len -gt 10  ];then     echo $machine_status >  /tmp/.$f1.txt else        echo "\"memory\":\""1"\",\""net_status\":\""1"\",\""squid_status\":\""1"\""    > /tmp/.$f1.txt fi}&{        #echo "get wan ip"        host=`ssh -o ConnectTimeout=3 -p $machine_port root@$machine_ip 'sh /root/get_wan_ip.sh'|awk -F: '{print$1}'`        #echo $host        #ssh -o ConnectTimeout=3  root@$host "date" > /dev/null        #echo "test wan ip for 22"            ping -W 3  -c 1 $host > /dev/null 2>&1        if [ $? -eq 0  ];then            #proxy_ip_port_status=`echo "\"proxy_ip\":\"0\",\""proxy_port\":\"1\"`            echo "\"proxy_ip\":\"0\",\""proxy_port\":\"1\" > /tmp/.$f3.txt        else            #proxy_ip_port_status=`echo "\"proxy_ip\":\"1\",\""proxy_port\":\"0\"`            echo echo "\"proxy_ip\":\"1\",\""proxy_port\":\"1\" > /tmp/.$f3.txt        fi}&{ #echo "get proxy_ip_port" proxy_ip_port=`ssh -o ConnectTimeout=3 -p $machine_port root@$machine_ip 'sh /root/get_wan_ip.sh'`  if [ $? -eq 0  ] && [ "$proxy_ip_port" != "null"  ];then    #echo "get curl result"     result=`curl  -I  -m 5 -x $proxy_ip_port -o  /dev/null -s -w %{http_code} map.baidu.com`            if [ $result -eq 200 ];then        proxy_ip_port_status=`echo "\"proxy_ip\":\"0\",\""proxy_port\":\"0\"`        else        #echo "get wan ip"        #host=`ssh -o ConnectTimeout=3 -p $machine_port root@$machine_ip 'sh /root/get_wan_ip.sh'|awk -F: '{print$1}'`                #ssh -o ConnectTimeout=3  root@$host "date" > /dev/null        #echo "test wan ip for 22"        #if [ $? -eq 0  ];then        #    proxy_ip_port_status=`echo "\"proxy_ip\":\"0\",\""proxy_port\":\"1\"`        #else        #    proxy_ip_port_status=`echo "\"proxy_ip\":\"1\",\""proxy_port\":\"0\"`        #fi        f3v=`cat /tmp/.$f3.txt|wc -c`        while (($f3v < 4))        do            f3v=`cat /tmp/.$f3.txt|wc -c`        done        proxy_ip_port_status=`cat /tmp/.$f3.txt`    fi else      proxy_ip_port_status=`echo "\"proxy_ip\":\"1\",\""proxy_port\":\"1\"`   fi echo $proxy_ip_port_status > /tmp/.$f2.txt}&wait proxy_ip_port_status=`cat /tmp/.$f2.txt` machine_status=`cat /tmp/.$f1.txt` rm -rf /tmp/.$f1.txt /tmp/.$f2.txt /tmp/.$f3.txt#echo $machine_status#echo $proxy_ip_port_statusecho "{"$machine_status","$proxy_ip_port_status"}"

上一篇:Know How To Use Check Box Mapping Of Other Values Property In Oracle Forms
下一篇:札记:Fragment基础

相关文章

相关评论

本站评论功能暂时取消,后续此功能例行通知。

一、不得利用本站危害国家安全、泄露国家秘密,不得侵犯国家社会集体的和公民的合法权益,不得利用本站制作、复制和传播不法有害信息!

二、互相尊重,对自己的言论和行为负责。