- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: ping problem
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
04-05-2002 10:58 AM
04-05-2002 10:58 AM
I have a little script that run every 30 min to see if the system is up or down. So I used this command in my script :
variable=ping hostname(s) -n 2 |grep 0% |awk '{print $7}'
and if the $variable != 0 then it'll send a message to said that system fail. This had been running fine for the last couple of months but this month I keep getting emailx saying that system1 or system2 ... systemn fail and when I went to investigate (manually pinging the system or log into the system - it's OK). I had this running on 5 systems and randomly each one send false report. It even happens when I'm currently working in system. Any help is appreciated.
TIA
Thi
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2002 11:06 AM
04-05-2002 11:06 AM
Re: ping problem
ping hostname -n 2 | grep 0% | awk '{print $7}' is producing the output 0%
i.e your variable is set to a value = 0%
If your $variable != 0 ( here it is 0% ) it will e-mail you a failure message. Since 0 and o% are not equal you are getting a failure message.
To avoid this the in the comaprison line use
$variable != 0% then send an e-mail informing you of a failure.
Regds
Ramesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2002 11:11 AM
04-05-2002 11:11 AM
Re: ping problem
Thi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2002 11:13 AM
04-05-2002 11:13 AM
Re: ping problem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2002 11:20 AM
04-05-2002 11:20 AM
Re: ping problem
Thi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2002 11:23 AM
04-05-2002 11:23 AM
SolutionDo you have any network issues at all? because from what you are saying, if $variable != 0% , the script will send an email, what if you are losing some network packets?
One way to check would be to send the $variable in the email.
-HTH
Ramesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2002 11:29 AM
04-05-2002 11:29 AM
Re: ping problem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2002 12:36 PM
04-05-2002 12:36 PM
Re: ping problem
I use and it works great. You can makethe then and else statements do do whatever you want. And iphosts.file can is a file with the hostnames or ip address in one colum.
#!/bin/sh
LANG=C
HOSTNAME_FILE=iphosts.file
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
Richard
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2002 01:15 PM
04-05-2002 01:15 PM
Re: ping problem
I think like this , if your script was working fine there should be nothing wrong with it except that there are changes in the ports where the servers are connected or there are really errors.You may want to try this
export A=`ping $HOSTNAME -n 2 | grep 0% | awk '{print $7}'|cut -c 1 `
though I know this is not right .
Manoj Srivastava
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2002 01:40 PM
04-05-2002 01:40 PM
Re: ping problem
When you run the program in the foreground (sh -vx xyzutil) -- what is the output?
I jotted down a test script and ran it like so
hostname=$1
variable=`ping $hostname -n 10 |grep 0% |awk '{print $7}'`
if [ $variable != 0% ]
then
echo "failure -- $hostname lost $variable of the packets"
else
echo "success -- $hostname appears to be up"
fi
and it functions as I would expect.
hth
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2002 07:39 PM
04-05-2002 07:39 PM
Re: ping problem
You may also have some network congestion issues, noise on WAN links, duplex mismatches, queue drops in routers etc which would kill a ping but which get shrugged off by telnet since it uses TCP which simply resends a lost packet.
You might want to check netstat -s and see if you see any problems. Do this several times and look for increases in retransmissions and errors.
Also
lanadmin
lan
display
will show any Ethernet problems (especially not the second page).
Do this at both ends of the circuit.
Ron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2002 05:20 PM
04-06-2002 05:20 PM
Re: ping problem
Or maybe you can mark that node as 'posibly faulty' when the first ping fails, ping it again a minute or two before.
Hope it'll work...
Regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2002 04:53 AM
04-08-2002 04:53 AM
Re: ping problem
Thi