linux 拨号+squid监控脚本
客户端
#!/bin/bash
#get_memory-info
a=`free -m|grep Mem|awk '{print$2}'` #total-memory
b=`free -m|grep Mem|awk '{print$3}'` #used-memory
mem_percent=`awk 'BEGIN{printf "%.2f%\n",('$b'/'$a')*100}'` #used-memory-%
#echo $mem_percent
#get_network_info
ping -W -c >&
];then
net_status="
else
net_status="
fi
#echo $net_status
#get_squid_process_status
squid_status=`systemctl status squid|grep Active|awk '{print$2}'`
if [ "$squid_status" = "active" ];then
squid_status_code="
else
squid_status_code="
fi
#echo $squid_status_code
echo "\"memory\":\""$mem_percent"\",\""net_status\":\""$net_status"\",\""squid_status\":\""$squid_status_code"\""
服务端:
#!/bin/bash
machine_ip=$
machine_port=$
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.txt
touch /tmp/.$f1.txt /tmp/.$f2.txt /tmp/.$f3.txt
{
#echo "get machine_status"
machine_status=`ssh -o ConnectTimeout= -p $machine_port root@$machine_ip 'sh /root/get_machine_info.sh'`
len=`echo $machine_status|wc -c`
];then
echo $machine_status > /tmp/.$f1.txt
else
echo "\"" > /tmp/.$f1.txt
fi
}&
{
#echo "get wan ip"
host=`ssh -o ConnectTimeout= -p $machine_port root@$machine_ip 'sh /root/get_wan_ip.sh'|awk -F: '{print$1}'`
#echo $host
#ssh -o ConnectTimeout= root@$host "date" > /dev/null
#echo "test wan ip for 22"
ping -W -c $host > /dev/>&
];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= -p $machine_port root@$machine_ip 'sh /root/get_wan_ip.sh'`
] && [ "$proxy_ip_port" != "null" ];then
#echo "get curl result"
result=`curl -I -m -x $proxy_ip_port -o /dev/null -s -w %{http_code} map.baidu.com`
];then
proxy_ip_port_status=`echo "\"proxy_ip\":\"0\",\""proxy_port\":\"0\"`
else
#echo "get wan ip"
#host=`ssh -o ConnectTimeout= -p $machine_port root@$machine_ip 'sh /root/get_wan_ip.sh'|awk -F: '{print$1}'`
#ssh -o ConnectTimeout= 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`
))
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_status
echo "{"$machine_status","$proxy_ip_port_status"}"
linux 拨号+squid监控脚本的更多相关文章
- Linux 服务器系统监控脚本 Shell【转】
转自: Linux 服务器系统监控脚本 Shell - 今日头条(www.toutiao.com)http://www.toutiao.com/i6373134402163048961/ 本程序在Ce ...
- Linux Shell 网络层监控脚本(监控包括:连接数、句柄数及根据监控反馈结果分析)
脚本监控: 获取最大句柄数的进程: 链接分析: 脚本片段: case "$handle" in 2) echo "The handle of the process : ...
- Linux系统性能统计工具Sar和实时系统性能监控脚本
sar(System Activity Reporter系统活动情况报告)是目前 Linux 上最为全面的系统性能分析工具之一,可以从多方面对系统的活动进行报告,包括:文件的读写情况.系统调用的使用情 ...
- 用 Python 脚本实现对 Linux 服务器的监控
目前 Linux 下有一些使用 Python 语言编写的 Linux 系统监控工具 比如 inotify-sync(文件系统安全监控软件).glances(资源监控工具)在实际工作中,Linux 系统 ...
- 【不积跬步,无以致千里】五个常用的Linux监控脚本代码
为大家提供五个常用Linux监控脚本(查看主机网卡流量.系统状况监控.监控主机的磁盘空间,当使用空间超过90%就通过发mail来发警告.监控CPU和内存的使用情况.全方位监控主机),有需要的朋友不妨看 ...
- linux系统CPU,内存,磁盘,网络流量监控脚本
前序 1,#cat /proc/stat/ 信息包含了所有CPU活动的信息,该文件中的所有值都是从系统启动开始累积到当前时刻 2,#vmstat –s 或者#vmstat 虚拟内存统计 3, #cat ...
- Python 脚本实现对 Linux 服务器的监控
本文来自我的github pages博客http://galengao.github.io/ 即www.gaohuirong.cn 摘要: 原文地址 由于原文来自微信公众号,并且脚本都是图片,所以这里 ...
- Linux下针对服务器网卡流量和磁盘的监控脚本
1)实时监控网卡流量的通用脚本: [root@ceph-node1 ~]# cat /root/net_monit.sh #!/bin/bash PATH=/bin:/usr/bin:/sbin:/u ...
- 几个常用的Linux监控脚本
几个常用的Linux监控脚本 几个常用的Linux监控脚本下面是几个主机监控的脚本,大家可以根据自己的情况再进行修改,希望能给大家一点帮助.1.查看主机网卡流量#!/bin/bash#network# ...
随机推荐
- Struts2之Struts2-2.5.5 Interceptor
Struts2-2.5.5版本是目前为止最新的版本了,相对于之前的2.3版本以及再之前的版本而言,新版本改动了很多. 好了,废话不多说,GO CODE! 基本jar包: web.xml核心配置,这里要 ...
- 高频sql语句汇总。不断更新。。
操作 语句 创建数据库 CREATE DATABASE dbname/* DEFAULT CHARSET utf8 COLLATE utf8_general_ci;*/ 删除数据库 DROP DATA ...
- selenium + python自动化测试环境搭建
selenium的在python平台的搭建: 搭建平台windows 准备工具如下: --------------------------------------------------------- ...
- eclipse提示:This tag and its children can be replaced by one <TextView/> and a compound drawable
今天在学习android开发的时候,写了这样的一段代码: <?xml version="1.0" encoding="utf-8"?> <Li ...
- 【前端盲点】DOM事件流论证CSS盒模型是否具有厚度
前言 很久没有扯淡了,我们今天来扯淡吧. 我今天思考了一个问题,我们页面的dom树到底是如何渲染的,而CSS盒模型与javascript是否有联系,于是便想到一个问题: CSS的盒模型具有厚度么??? ...
- mysql支持IOS的Emoji表情
原因: UTF-8编码有可能是两个.三个.四个字节.Emoji表情是4个字节,而Mysql的utf8编码最多3个字节,所以数据插不进去. 解决办法: 将Mysql的编码从utf8转换成utf8mb4 ...
- SQLServer ForXmlPath应用
SQLServer ForXmlPath应用 一:ForXmlPath介绍 forXmlPath 是SQL中的forXml语法的一部分,本文主要讲Path模式 ---SQL中FOR XML子句的 ...
- 对称密码-DES和3DES
最近在看信息安全的知识,就总结了一下自己所学到知识. 先说一下什么是对称密码算法,什么是对称密码算法呢?对称密码算法是指有了加密密钥就可以推算出解密密钥,有了解密密钥就可以推算出加密密钥的的算法. 那 ...
- clang编译mysql(Ubuntu10 64位)
编译安装mysql(Ubuntu10 64位) http://www.cnblogs.com/2018/p/3482259.html 这个介绍了gcc形式编译安装mysql 那我们使用clang进行编 ...
- ZeroMq安装包的生成【ubuntu10】
生成方法添加源sudo add-apt-repository ppa:chris-lea/zeromqsudo add-apt-repository ppa:chris-lea/libpgmsudo ...