标签:image png http 统计 change date result host res
最近需要做一个实时统计网络情况并统计误包率的脚本,下面是StackExchange上的一个剽窃,虽然不完全满足,但只可以输出一些信息
#!/bin/bash host=$1 if [ -z $host ]; then echo "Usage: `basename $0` [HOST]" exit 1 fi while :; do result=`ping -W 1 -c 1 $host | grep ‘bytes from ‘` if [ $? -gt 0 ]; then echo -e "`date +‘%Y/%m/%d %H:%M:%S‘` - host $host is \033[0;31mdown\033[0m" else echo -e "`date +‘%Y/%m/%d %H:%M:%S‘` - host $host is \033[0;32mok\033[0m -`echo $result | cut -d ‘:‘ -f 2`" sleep 1 # avoid ping rain fi done
标签:image png http 统计 change date result host res
原文地址:http://www.cnblogs.com/aaronLinux/p/7074602.html