PING broken check


 
Thread Tools Search this Thread
Operating Systems Solaris PING broken check
# 1  
Old 06-20-2011
PING broken check

Dear All,

Required a script which will check the PING response from my source file(tmp/PingStatus.txt) containing the hostnames.

If ping response is not responding(i.e when hostname is not alive) then this cmd to be executed :

opcmsg object=PING a=OS msg_grp=win-ping severity=critical msg_text="PING BROKEN on $line"


With regards,
Mjoshi
# 2  
Old 06-20-2011
Code:
for i in `cat tmp/PingStatus.txt`
do
ping -c 5 -w 5 -n $i | grep -q "bytes from" && echo "$i is OK" || opcmsg object=PING a=OS msg_grp=win-ping severity=critical msg_text="PING BROKEN on $line"
done

# 3  
Old 06-20-2011
Dear its failing..........

Code:
root@ggnems21 # cat testping.sh
#!/bin/sh
for i in `cat tmp/PingStatus.txt`
do
ping -c 5 -w 5 -n $i | grep -q "bytes from" && echo "$i is OK" || opcmsg object=PING a=OS msg_grp=OpC severity=critical msg_text="PING BROKEN on $line"
done
root@ggnems21 # ls -l PingStatus.txt
-rwxrwxrwx   1 root     root           7 Jun 20 17:32 PingStatus.txt
root@ggnems21 # sh testping.sh
cat: cannot open tmp/PingStatus.txt

---------- Post updated at 07:07 AM ---------- Previous update was at 07:06 AM ----------

Code:
root@ggnems21 # cat testping.sh
#!/bin/sh
for i in `cat tmp/PingStatus.txt`
do
ping -c 5 -w 5 -n $i | grep -q "bytes from" && echo "$i is OK" || opcmsg object=PING a=OS msg_grp=OpC severity=critical msg_text="PING BROKEN on $line"
done
root@ggnems21 # ls -l PingStatus.txt
-rwxrwxrwx   1 root     root           7 Jun 20 17:32 PingStatus.txt
root@ggnems21 # sh testping.sh
cat: cannot open tmp/PingStatus.txt


Last edited by fpmurphy; 06-21-2011 at 10:54 AM.. Reason: Code tags please!
# 4  
Old 06-20-2011
use /tmp instead of tmp
# 5  
Old 06-21-2011
Code:
#!/bin/sh
for i in `cat /tmp/PingStatus.txt`
do
ping -c 5 -w 5 -n $i | grep -q "bytes from" && echo "$i is OK" || opcmsg object=PING a=OS msg_grp=OpC severity=critical msg_text="PING BROKEN on $line"
done
root@ggnems21 # sh testping.sh
grep: illegal option -- q
Usage: grep -hblcnsviw pattern file . . .
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]


Last edited by fpmurphy; 06-21-2011 at 10:55 AM.. Reason: Code tags please!!
# 6  
Old 06-21-2011
just execute the below command and give the result

ping anyhostname

is it showing like "hostname is alive" ?
or is it keep on pinging ?
# 7  
Old 06-21-2011
root@ggnems21 # ping ggnems01
ggnems01 is alive

I also required it to wait for some time because for some occasions the network is slow and i get delay in response of about 5-10 seconds...
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