Sponsored Content
Full Discussion: PING broken check
Operating Systems Solaris PING broken check Post 302533629 by ygemici on Friday 24th of June 2011 09:27:52 AM
Old 06-24-2011
you are right , ping test takes long time..i modified and defined some defaults(for exa ping test about send 4 echo packet check in script)..
now you can give a ping try count for first parameter and then see the results..(actually 50 try requires more times but if you want to test in long time period then maybe you must specify 50 100 or 200 or more than parameter..)
so in script , ping tries transmit packets to target with 2 seconds intervals and 4 packets
first(prestart control) ping test takes about four seconds(normally about 1 second per packet or under 1 second ,, of course it may vary depending on various factors however) if target is avaliable and must must not be resulotion problem [ default timeout is 20 second ].but we defined packet size then it takes about 10 seconds + 4*1 second (per packet) = about 14 seconds.
lets look belows.

# if you dont have access to host..(some waits target host is non-accessable)
Code:
# time ping -s 192.168.56.112 56 4
PING 192.168.56.112: 56 data bytes
----192.168.56.112 PING Statistics----
4 packets transmitted, 0 packets received, 100% packet loss
real    0m13.069s
user    0m0.020s
sys     0m0.043s

# if you have access to host..(no wait target host is accessable)
Code:
# time ping -s 192.168.56.111 56 10
PING 192.168.56.111: 56 data bytes
64 bytes from solaris (192.168.56.111): icmp_seq=0. time=1.42 ms
64 bytes from solaris (192.168.56.111): icmp_seq=1. time=0.704 ms
64 bytes from solaris (192.168.56.111): icmp_seq=2. time=0.722 ms
........................
64 bytes from solaris (192.168.56.111): icmp_seq=9. time=0.795 ms
----192.168.56.111 PING Statistics----
10 packets transmitted, 10 packets received, 0% packet loss
round-trip (ms)  min/avg/max/stddev = 0.381/0.8182/1.42/0.260
real    0m9.092s
user    0m0.027s
sys     0m0.051s

at the now,you must you can try and use to a specifying parameter with new script..
for example
Code:
# ./testping.sh 2 hostlist

this means that you want to try for Number of 4-pack counts[this is defaul in script] * 2 count..
Code:
#!/usr/bin/bash
## justdoit ## ping test on SunOS ##
if [ $# != 2 ] ; then echo "usage $0 'packetcount' hostlistfile" ; exit 0 ; fi
if [[ $(echo $1|grep [^0-9]) ]] ; then echo "first parameter '$1' is not digit!!";exit 1;fi
sleep=2 ; c=$1 ; control=4 ; # count for packets
while read -r host ; do
printf "%s" "testing access to $host ...? "
(sleep $sleep;ping -s $host 56 $control > /dev/null 2>&1) &
pid=$! ; wait $pid
if [ $? -ne 0 ] ; then
printf "%s\n" "FAIL!! "
else
>tmppg
printf "%s\n" "SUCCESS "
## pinging try ##
printf "%s" "pinging try "
for((j=0;j<$c;j++)); do printf "%c" ".";sleep $sleep; ping -s $host 56 $control >>tmppg;done;
printf "%s\n" " OK"
nawk -F, -v c=$1 -v host=$host -v sleep=$sleep '/packets/{sub("% packet loss","",$3)}{t+=$3}
END{if(t>50*c) {system("opcmsg object=PING a=OS msg_grp=OpC severity=critical msg_text=\"PING BROKEN on "host"\"");
print "ping problem in \""host"\" !!\nping loss \"%"t" of %"100*c"\" for at "c" packet tries in "sleep" seconds intervals"}
else {print "\""host"\" is alive with \"%"t" of %"100*c" loss rate\" at "c" packet tries in "sleep" seconds intervals"}}' tmppg
fi;echo;done<"$2"

good lucks Smilie
regards
ygemici
This User Gave Thanks to ygemici For This Post:
 

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Broken

Ok i am running Linux, or rather was. I can not longer do anything. This was a dns server amoungst other things. It will no longer boot. I have used a startup disk, but how can i recover the OS? I need help and urgently. Please someone thanks (3 Replies)
Discussion started by: ollyparkhouse
3 Replies

2. Debian

./configure is broken - /lib/cpp fails sanity check

Hi, I first wanted to install my NIC drivers but it said: Makefile:62: *** Linux kernel source not found. Stop. So I installed the kernel source: linux-source-2.6.18_2.6.18.dfsg.1-13etch5_all.deb 1) cd /usr/src 2) -xjvf linux-source.2.6.18.extension (forget what it was) 3) ln -s... (12 Replies)
Discussion started by: Virtuality
12 Replies

3. Solaris

How to check disk broken

Dear all, I have system that have 2 disk, and 1 off disk is broken, how can I check if the disk is broken or other problem. I'm using Solaris 10 x86. Thank you, Best Regards, Heru (4 Replies)
Discussion started by: heru_90
4 Replies

4. UNIX for Dummies Questions & Answers

ping is blocked hwo to check connection

Hi How to check connection with another IP/Server not using ping? Thanks (5 Replies)
Discussion started by: miojamo
5 Replies

5. Shell Programming and Scripting

[ASK] How to check whether ipv4 or ipv6 and ping those IP

I have perl script that I use to check and ping a list of ip, The problem is, I didnt understand how to ping ipv6 on perl, Could I use Ping::External??And how could I get the ping result (reply or not)? This is my code #!/usr/bin/perl -- use Net::Ping; use Data::Validate::IP; use... (3 Replies)
Discussion started by: franzramadhan
3 Replies

6. Shell Programming and Scripting

Animation Ping on Solaris Like Cisco Ping

Hi, I develop simple animation ping script on Solaris Platform. It is like Cisco ping. Examples and source code are below. bash-3.00$ gokcell 152.155.180.8 30 Sending 30 Ping Packets to 152.155.180.8 !!!!!!!!!!!!!.!!!!!!!!!!!!!!!. % 93.33 success... % 6.66 packet loss...... (1 Reply)
Discussion started by: gokcell
1 Replies

7. Linux

Ping check failed from Nagios master server on windows hosts in the same subnet

Hello All, We have added a windows host and its config files to Nagios master server and wanted to do a ping check alone at the moment however, the nagios master server identifies the host in its GUI and immediately disappears can anyone let me know the right approach to this one, We want to... (2 Replies)
Discussion started by: lovesaikrishna
2 Replies

8. Shell Programming and Scripting

How to get reason for ping failure using perls Net::Ping->new("icmp");?

Hi I am using perl to ping a list of nodes - with script below : $p = Net::Ping->new("icmp"); if ($p->ping($host,1)){ print "$host is alive.\n"; } else { print "$host is unreacheable.\n"; } $p->close();... (4 Replies)
Discussion started by: tavanagh
4 Replies

9. Programming

Ping test sends mail when ping fails

help with bash script! im am working on this script to make sure my server will stay online, so i made this script.. HOSTS="192.168.138.155" COUNT=4 pingtest(){ for myhost in "$@" do ping -c "$COUNT" "$myhost" &&return 1 done return 0 } if pingtest $HOSTS #100% failed... (4 Replies)
Discussion started by: mort3924
4 Replies
All times are GMT -4. The time now is 01:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy