PING broken check


 
Thread Tools Search this Thread
Operating Systems Solaris PING broken check
# 15  
Old 06-22-2011
ygemici,
please also include this statement passed within your script provided whenever i get ping broken
i.e If ping response is not responding(i.e when hostname is not alive) then this cmd to be executed :

opcmsg object=PING a=PING msg_grp=win-ping severity=critical msg_text="PING BROKEN on $line"
# 16  
Old 06-22-2011
Quote:
Originally Posted by mjoshi87
ygemici,
please also include this statement passed within your script provided whenever i get ping broken
i.e If ping response is not responding(i.e when hostname is not alive) then this cmd to be executed :

opcmsg object=PING a=PING msg_grp=win-ping severity=critical msg_text="PING BROKEN on $line"
Code:
#!/usr/bin/bash
if [ $# != 2 ] ; then echo "usage $0 'packetcount' hostlistfile" ; exit 0 ; fi
sleep=2 ; c=$1 # count for packets
while read -r host ; do
(sleep $sleep;ping -s $host 56 $c >/dev/null) &
pid=$! ; wait $pid
if [ $? -eq 0 ] ; then
PL=$(i=1;while [ $i -le $c ] ; do sleep $sleep;ping -s $host 56 $c ;((i++));done)
echo "$PL"|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\n"}
else {print "\""host"\" is alive with \"%"t" of %"100*c" loss rate\" at "c" packet tries in "sleep" seconds intervals\n"}}'
else echo -e "ping failed while sending 'echo_request(s)' to \"$host\"\n\
check!! host access (/network or firewall or route(ing) settings/) or \ncheck!! resolution (/hosts/dns/nsswitch)!!\n\
or \ncheck!! be sure host is power up or \ncheck!! is ping enabled in o.s or switch(s) or router(s)\n"
fi;done<$2

regards
ygemici
This User Gave Thanks to ygemici For This Post:
# 17  
Old 06-23-2011
root@emsnew39 # sh pingtest.sh 50 hostlistfile.txt
pingtest.sh: syntax error at line 8: `PL=$' unexpected
root@emsnew39 #
# 18  
Old 06-24-2011
Quote:
Originally Posted by mjoshi87
root@emsnew39 # sh pingtest.sh 50 hostlistfile.txt
pingtest.sh: syntax error at line 8: `PL=$' unexpected
root@emsnew39 #
use bash dont sh..try like this Smilie
Code:
# ./pingtest.sh 50 hostlistfile.txt

or
Code:
# bash pingtest.sh 50 hostlistfile.txt

regards
ygemici
# 19  
Old 06-24-2011
Dear thanks the script is working now,,But my point is now:

For valid host which are pinging, your script is still running..Does that mean the server is still pinging the source ip continuously?

I tried this way also to cross check:

bash pingtest.sh 50 hostlistfile.txt >/tmp/test.txt

but the /tmp/test.txt file is empty
# 20  
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:
# 21  
Old 07-16-2011
Hello,

Quote:
#!/bin/sh while read i do sleep 5; ping $i | grep -w "alive" && echo "$i is OK" || opcmsg object=PING a=OS msg_grp=OpC severity=critical msg_text="PING BROKEN on $i" done < cat /tmp/PingStatus.txt
I found this post interesting cause I want to check some ip addresses throught ping, traceroute or telnet+port


1.I dont need

Quote:
opcmsg object=PING a=OS msg_grp=OpC severity=critical msg_text="PING BROKEN on $i" done < cat /tmp/PingStatus.txt
but an if condition so that I can

Quote:
echo "$i is OK"
2. Each test (ping,trace or telnet) is towards different ip address so I just have to cancel

Quote:
while read i
and each time specify the host something like this?

Quote:
web="10.33.22.5"
gateway="10.22.11.1"
proxy="10.22.11.88"

telnet ${web} 80 | grep -q "Connected" && echo ${web} " is OK"
sleep 5; ping ${gateway} | grep -w "alive" && echo ${gateway} " is OK" ..
traceroute ${proxy} | grep -w "???" && echo ${proxy} " is OK" ..
Kind regards
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

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. 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

7. 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

8. 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

9. 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
Login or Register to Ask a Question