- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Using Ping to verify status
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2001 06:03 AM
10-30-2001 06:03 AM
Example:
In my script if interface 1 goes down my script captures the ip address & compares it to a static list of ip addresses. If it does not find a match it exits.
On the other hand if interface 2 goes down the same comparison is done, this time there is a match so the script sleeps for 3 minutes. After 3 minutes I want to ping the ip address of interface 2 to verify that it is still down before the rest of the script runs, which sends out a page and popup box.
Foe some reason I can't seem to get the syntax right in the ping statment as well as the results for verification.
Any and all help is appreciated.
Thanks Jeff
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2001 06:13 AM
10-30-2001 06:13 AM
Re: Using Ping to verify status
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2001 06:19 AM
10-30-2001 06:19 AM
Re: Using Ping to verify status
#Determining which interface is down in NNM
HOSTNAME=$1
SERINT=$2
DATE=$3
TIME=$4
#Capturing the right data from Database text file
SERIALIP=`awk -v HOSTNAME="${HOSTNAME}" -F";" '{if($1==HOSTNAME) {print $7}}' /opt/OV/contrib/NNM/ov
alarm/configinfo.txt`
#Verifying that the interface down is the serial interface
if [ "$SERINT" = "$SERIALIP" ] ; then
#Waiting three minutes for true outage
#sleep 180
Here is where I need help!!
#Verifying that interface is still down
#ping $SERINT
if $SERINT unreachable ; then
echo "$SERINT"
fi
else
echo "$DATE | $TIME | Hostname:$HOSTNAME | Interface:$SERINT\n" >> /home/root/scripts/log/ipche
ckdown.log
exit 0
fi
Thanks
Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2001 06:20 AM
10-30-2001 06:20 AM
Re: Using Ping to verify status
Darrell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2001 06:24 AM
10-30-2001 06:24 AM
Re: Using Ping to verify status
'sed' the output of the ping command?
E.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2001 06:28 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2001 06:30 AM
10-30-2001 06:30 AM
Re: Using Ping to verify status
In 10.20, ping has a nice option: -m
So an interesting design for your script would be to start a ping in the background, obtain the PID for that process using something like: PINGPID=$!, then sleep for one second, check the status of that process ID using: ps -p $PINGPID. If the process has disappeared, then it finished and you can break out of the loop.
After some number of loops (perhaps 5 or 10), and ping is still running, just issue: kill $PINGID and report that ping failed. Be sure to use -n to limit the number of test pings (such as -n 1) and perhaps adjust the packet size as appropriate.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2001 06:35 AM
10-30-2001 06:35 AM
Re: Using Ping to verify status
You posted you script before I saw. Oops!
ans=`ping addr -n 1 | grep "100% packet loss"`
if [ X"$ans" != X ] ; then
unreachable
Darrell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2001 08:34 AM
10-30-2001 08:34 AM
Re: Using Ping to verify status
You can modify to make it into a proccess. Or you can make it a cron job. Note that the file hostnames is a seperate file that has a list of the hosts names or IPs you are trying to test. like so
host1
host2
host3
192.xxx.xx.xx
If you are going to do it by host make sure that dns works or you have the hostsname in /etc/hosts
Here is the script
#!/bin/sh
LANG=C
HOSTNAME_FILE=hostnames
for host in $(cat $HOSTNAME_FILE)
do
ping $host -n 1 | grep -q '1 packets received'
if [ $? = 0 ]
then
echo "$host: OK"
else
echo "$host: FAIL"
fi
done
This one will send you an email
#!/bin/sh
LANG=C
HOSTNAME_FILE=hostnames
for host in $(cat $HOSTNAME_FILE)
do
ping $host -n 1 | grep -q '1 packets received'
if [ $? = 0 ]
then
echo "$host: OK"
else
echo "$host: FAIL" | mailx -s "hostdown" user@domain
fi
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2001 08:39 AM
10-30-2001 08:39 AM
Re: Using Ping to verify status
I use like this
if [ -n "`ping $1 64 1 | grep icmp`" ]
then echo "ALIVE"
else echo "DEAD"
fi ;;
-USA..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2001 08:51 AM
10-30-2001 08:51 AM
Re: Using Ping to verify status
Look this thread from yesterday.
Lauri was trying to do may be same thing as you want
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x73bee7726eccd5118ff10090279cd0f9,00.html
Sachin