如何批量ping地址查看网络是否畅通
测试环境搬迁后,需要批量去ping所有机器的IP,看网络是否畅通
测试思路:
[weblogic@pays03pre_BankVerify luyantest]$ ping -c 1 172.29.111.118
PING 172.29.111.118 (172.29.111.118) 56(84) bytes of data.
--- 172.29.111.118 ping statistics ---
1 packets transmitted, 0 received, 100% packet loss, time 10000ms
[weblogic@pays03pre_BankVerify luyantest]$ ping -c 1 172.29.111.118 | grep loss
1 packets transmitted, 0 received, 100% packet loss, time 10000ms
[weblogic@pays03pre_BankVerify luyantest]$ ping -c 1 172.29.111.118 | grep loss | awk '{print $6}'
100%
[weblogic@pays03pre_BankVerify luyantest]$ ping -c 1 172.29.111.118 | grep loss | awk '{print $6}' | awk -F "%" '{print $1}'
100
如上发现,如果ping一个ip地址没有通过,那么丢包率就是100%。这样我们可以循环去ping所有的地址,然后截取丢包率,去对比
脚本如下:
#! /bin/bash
#set -x
for i in `cat iplist`
do
ping=`ping -c 1 $i|grep loss|awk '{print $6}'|awk -F "%" '{print $1}'`
if [ $ping -eq 100 ]
then
echo ping $i fail
else
echo ping $i ok
fi
done
#set +x
最新文章
- .NET文件跨服务器上传下载
- backbone库学习-Router
- Http常用状态码
- Spring回调方法DisposableBean接口
- HTML5新增Canvas标签及对应属性、API详解(基础一)
- JS 之DOM range对象
- Android 学习
- CentOS学习笔记--Tomcat安装
- vim 快捷键大全
- Visual Studio调试技巧 -- Attach to Process #Reprinted#
- 20190421-那些年使用过的CSS预处理器(CSS Preprocessor)之Sass and Less
- HTTP的基本原理
- 【SVN】关于钩子的一些使用
- opencv wlsfilter depth refinement demo
- OpenStack中的虚拟机(/dev/mapper/centos-root)进行磁盘扩容
- Eureka Client的使用
- linux sqlplus查询数据中文乱码解决方法记录
- Hash表(hash table ,又名散列表)
- AJAX的前世今生与未来
- JDBC中,用于表示数据库连接的对象是。(选择1项)
热门文章
- POJ——T2553 The Bottom of a Graph
- cogs 141. [USACO Jan08] 奶牛的选举
- hadoop-03-安装java
- thinkphp命名空间
- hdoj--2709--Sumsets(数位dp)
- rest_framework-节流-总结完结篇
- [NOIP2015模拟10.27] [JZOJ4270] 魔道研究 解题报告(动态开点+权值线段树上二分)
- C++字节对齐与结构体大小计算
- BZOJ 1001 平面图与对偶图的转化 最短路Or最大流
- 提高realm存储速率