Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reduce the Ping response waiting time 1

Status
Not open for further replies.

viadisky

Technical User
Jun 19, 2003
110
GB
Hi,

I have this script that pings range of addresses, basically the output I get is like this:

172.24.58.1 is alive
172.24.58.2 is alive
172.24.58.3 is alive
no answer from 172.24.58.4
no answer from 172.24.58.5
no answer from 172.24.58.6
no answer from 172.24.58.7
no answer from 172.24.58.8
no answer from 172.24.58.9
172.24.58.10 is alive
no answer from 172.24.58.11
no answer from 172.24.58.12

I want to reduce the waiting time for those devices that didn't respond to ping. It's taking almost 20 seconds for the "no answer from <IP Address>" to appear in the screen.

Is it possible to reduce the waiting time to just at least 5 sec?

Hope somebody can help me.

Many thanks,
Maria
 
Hi,

man ping tells you the correct flag for your ping command.
On RH Linux its -W5, on AIX its -w5 for 5 seconds

Stefan
 
Hi Feherke,

ping -w <deadline> worked on the command-line in my windows XP but it's saying illegal option when I issued the same command in Unix (please refer to the error mesage below)

zen:/u/mviado/ADD_RANGE$ ping -w 1 172.24.58.16
ping: illegal option -- w
usage: ping host [timeout]
usage: ping -s [-l | U] [adLnRrv] [-A addr_family] [-c traffic_class]
[-g gateway [-g gateway ...]] [-F flow_label] [-I interval]
[-i interface] [-P tos] [-p port] [-t ttl] host [data_size] [npackets]


When I did man ping in Unix, I didn't see the "-w" option ...

Cheers!
 
Hi Stefan,

Did I issue the correct ping command?

ping -w 1 172.24.58.16 ?

Thank you.

Maria
 
Hi Feherke,

I saw the function you wrote to resolve those devices that can hang the script.

###########################################################
function pingw()
{
ping="ping"
while [ $# -ne 0 ]; do
test "$1" == "-w" && { shift; deadline="${1:-1}"; } || ping="$ping $1"
shift
done
$ping &
pid=$!
sec=0
while ps $pid > /dev/null; do
sleep 1
test $((++sec)) -ge "0$deadline" && break
done
ps $pid > /dev/null && kill -SIGINT $pid
}
######################################################

I have no idea how to use this or incorporate this in my script ... my knowledge in unix scripting is quite limited. Can you please give me more info regarding this?

I really appreciate your help ...

Maria
 
Hi Stefan,

Your suggestion is brilliant !!!

This will complete my script definitely!

Thank you very ... very much!

Maria
 
It was already suggested by the ping "usage" messages, but only Stefan noticed it.

zen:/u/mviado/ADD_RANGE$ ping -w 1 172.24.58.16
ping: illegal option -- w
usage: ping host [timeout]
usage: ping -s [-l | U] [adLnRrv] [-A addr_family] [-c traffic_class]
[-g gateway [-g gateway ...]] [-F flow_label] [-I interval]
[-i interface] [-P tos] [-p port] [-t ttl] host [data_size] [npackets]

Good catch Stefan!


HTH,

p5wizard
 
Hi

Actually not only. But while I worked on an longer answer including a example script for the suggested [tt]pingw[/tt] function, Stefan already posted his question.

Hmm... I should change my style. Long answers works well only on mailing lists with daily digest delivery.

Feherke.
 
Hi Feherke,

The suggestion you provided (introducing the function) is quite interesting.Can you recommend some reading materials on this topic? I would like to increase my level of knowledge but it somehow confusing where to start ...

Maria
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top