通過(guò)shell script做ping循環(huán)測(cè)試
為磁縣等地區(qū)用戶提供了全套網(wǎng)頁(yè)設(shè)計(jì)制作服務(wù),及磁縣網(wǎng)站建設(shè)行業(yè)解決方案。主營(yíng)業(yè)務(wù)為成都網(wǎng)站設(shè)計(jì)、網(wǎng)站制作、磁縣網(wǎng)站設(shè)計(jì),以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠(chéng)的服務(wù)。我們深信只要達(dá)到每一位用戶的要求,就會(huì)得到認(rèn)可,從而選擇與我們長(zhǎng)期合作。這樣,我們也可以走得更遠(yuǎn)!
系統(tǒng)環(huán)境:
操作系統(tǒng): MAC OS
一個(gè)有意思,且有用的系統(tǒng)維護(hù)腳本,通過(guò)shell script 測(cè)試網(wǎng)絡(luò)主機(jī)的連通性:
[tiany@localhost ~]$cat ping.sh
#!/bin/bash
for i in `seq 254`
do
ip=192.168.1.$i
ping -c1 $ip >/dev/null 2>&1
[ $? -eq 0 ] && echo "$ip is alive" || echo "$ip is not alive"
done
[tiany@localhost ~]$sh ping.sh
192.168.1.1 is alive
192.168.1.2 is not alive
192.168.1.3 is not alive
192.168.1.4 is not alive
192.168.1.5 is not alive
192.168.1.6 is not alive
另轉(zhuǎn):
用shell腳本實(shí)現(xiàn)ping網(wǎng)段中的所有主機(jī):
#!/bin/sh
# ping all host
# edit by www.jbxue.com
# find from /etc/hosts for host info,and filter IP address
cat /etc/hosts | grep -v ^# |grep -v ^$ | while read LINE
do
for M in `awk '{print $1}'`
do
if ping -w 1 -c 1 $M | grep "100%" >/dev/null
then
echo "$M is down"
else
echo "$M is up"
fi
done
done