Chinaunix首页 | 论坛 | 博客
  • 博客访问: 19912093
  • 博文数量: 679
  • 博客积分: 10495
  • 博客等级: 上将
  • 技术积分: 9308
  • 用 户 组: 普通用户
  • 注册时间: 2006-07-18 10:51
文章分类

全部博文(679)

文章存档

2012年(5)

2011年(38)

2010年(86)

2009年(145)

2008年(170)

2007年(165)

2006年(89)

分类:

2006-12-06 11:12:39

检查ip地址通不通

#!/bin/sh
#ping all
#grab /etc/hosts and ping each address
source="$1"
cat $source |grep 10.5 | while read LINE
do
        ADDR=`awk '{print $1}'`
        for MACHINE in $ADDR
        do
                ping  -c2 $MACHINE
        done
done

注意以下等号的左右不要有空格
source="$1"
以下的-s要去掉

 ping -s -c1 10.50.100.51

执行结果类似如下:
[root@Meil89 meil]# ./ping_all ip_stress.cfg
PING 10.50.100.52 (10.50.100.52) 56(84) bytes of data.
64 bytes from 10.50.100.52: icmp_seq=1 ttl=62 time=0.166 ms
64 bytes from 10.50.100.52: icmp_seq=2 ttl=62 time=0.272 ms

--- 10.50.100.52 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 999ms
rtt min/avg/max/mdev = 0.166/0.219/0.272/0.053 ms
PING 10.50.100.53 (10.50.100.53) 56(84) bytes of data.
64 bytes from 10.50.100.53: icmp_seq=1 ttl=62 time=0.148 ms
64 bytes from 10.50.100.53: icmp_seq=2 ttl=62 time=0.198 ms

--- 10.50.100.53 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 999ms
rtt min/avg/max/mdev = 0.148/0.173/0.198/0.025 ms
PING 10.50.100.54 (10.50.100.54) 56(84) bytes of data.
64 bytes from 10.50.100.54: icmp_seq=1 ttl=62 time=0.191 ms

--- 10.50.100.54 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.191/0.191/0.191/0.000 ms
PING 10.50.100.55 (10.50.100.55) 56(84) bytes of data.
64 bytes from 10.50.100.55: icmp_seq=1 ttl=62 time=0.523 ms
64 bytes from 10.50.100.55: icmp_seq=2 ttl=62 time=0.119 ms


另:配置文件如下:
[root@Meil89 meil]# vi ip_stress.cfg

10.50.100.51
10.50.100.52
10.50.100.53
10.50.100.54
10.50.100.55
10.50.100.56
10.50.100.57
10.50.100.58
10.50.100.59
10.50.100.60
10.50.100.61
10.50.100.62
10.50.100.63
10.50.100.64
10.50.100.65
10.50.100.66
10.50.100.67
10.50.100.68

阅读(3354) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~