测试环境搬迁后,需要批量去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

最新文章

  1. .NET文件跨服务器上传下载
  2. backbone库学习-Router
  3. Http常用状态码
  4. Spring回调方法DisposableBean接口
  5. HTML5新增Canvas标签及对应属性、API详解(基础一)
  6. JS 之DOM range对象
  7. Android 学习
  8. CentOS学习笔记--Tomcat安装
  9. vim 快捷键大全
  10. Visual Studio调试技巧 -- Attach to Process #Reprinted#
  11. 20190421-那些年使用过的CSS预处理器(CSS Preprocessor)之Sass and Less
  12. HTTP的基本原理
  13. 【SVN】关于钩子的一些使用
  14. opencv wlsfilter depth refinement demo
  15. OpenStack中的虚拟机(/dev/mapper/centos-root)进行磁盘扩容
  16. Eureka Client的使用
  17. linux sqlplus查询数据中文乱码解决方法记录
  18. Hash表(hash table ,又名散列表)
  19. AJAX的前世今生与未来
  20. JDBC中,用于表示数据库连接的对象是。(选择1项)

热门文章

  1. POJ——T2553 The Bottom of a Graph
  2. cogs 141. [USACO Jan08] 奶牛的选举
  3. hadoop-03-安装java
  4. thinkphp命名空间
  5. hdoj--2709--Sumsets(数位dp)
  6. rest_framework-节流-总结完结篇
  7. [NOIP2015模拟10.27] [JZOJ4270] 魔道研究 解题报告(动态开点+权值线段树上二分)
  8. C++字节对齐与结构体大小计算
  9. BZOJ 1001 平面图与对偶图的转化 最短路Or最大流
  10. 提高realm存储速率