- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Script for Network Ping 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
Discussions
Discussions
Forums
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
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
тАО06-28-2009 11:22 PM
тАО06-28-2009 11:22 PM
I am not good in script writing, Can anyone help me out to write a script for network ping status i.e. i want to ping for 15 servers and if ping replies back with"relpy from server" then i don't want that output to be e-mailed, but if ping replies back with "request timed out" then it should send me and mail for that host unreachable.
Thanks,
Narendra
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-29-2009 01:13 AM
тАО06-29-2009 01:13 AM
Re: Script for Network Ping Status.
# all the system to ping:
ALLSYSTEM="192.168.0.1 " \
"192.168.0.2 " \
"192.168.0.3 "
monmail="myaddress@mystystem"
pingit()
{
ping $1 -n 1 -m 1 >/dev/null
curval=$?
echo "$1 not responding" |mailx -s "system monitoring: $1 status" $2
return $curval
}
for i in $ALLSYSTEM
do
pingit $i $monmail
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-29-2009 02:18 AM
тАО06-29-2009 02:18 AM
Re: Script for Network Ping Status.
I tried ur script getting error as below,
hostname:[/home]# ./pingstatus
./pingstatus[3]: 10.133.12.6: not found
hostname:[/home]# cat pingstatus
#!/usr/bin/ksh
# all the system to ping:
ALLSYSTEM="10.133.12.29" \
"10.133.12.6" \
"10.133.12.26"
monmail="narendra.uttekar@xxxx.com"
pingit()
{
ping $1 -n 1 -m 1 >/dev/null
curval=$?
echo "$1 not responding" |mailx -s "system monitoring: $1 status" $2
return $curval
}
for i in $ALLSYSTEM
do
pingit $i $monmail
done
I also tried with giving space between "10.133.12.6 " \ ,But still result same.
Thanks,
Narendra
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-29-2009 02:41 AM
тАО06-29-2009 02:41 AM
Re: Script for Network Ping Status.
it is ALLSYSTEM="sys1 \
sys2 \
sys3 \
sys4"
or ALLSYSTEM="sys1 sys2 sys3 sys4"
when doing ALLSYSTEM="x " \
"y "
there is a space between "x " and "y "
so it tries to execute "y "
when doing
"x"\
"y"\
"z"
it is like "xyz"
so the 3 possibilities are
"x "\
"y "\
"z "
or
"x \
y \
y"
or "x y z"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-29-2009 03:16 AM
тАО06-29-2009 03:16 AM
Re: Script for Network Ping Status.
A very interesting document on this topic:
http://www.docs.hp.com/en/J5683-90002/J5683-90002.pdf
Also, ping has a timeout feature that you should build into the script to make it more tolerant of temporary network issues.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-29-2009 05:39 AM
тАО06-29-2009 05:39 AM
Re: Script for Network Ping Status.
After modification the script as suggested by you. The script is running but even though i am able to ping the servers. It is sending me the mail "10.133.12.6 not responding"
#!/usr/bin/ksh
# all the system to ping:
ALLSYSTEM="10.133.12.29 10.133.12.6"
monmail="narendra.uttekar@xxxx.com"
pingit()
{
ping $1 -n 1 -m 1 >/dev/null
curval=$?
echo "$1 not responding" |mailx -s "system monitoring: $1 status" $2
return $curval
}
for i in $ALLSYSTEM
do
pingit $i $monmail
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-29-2009 05:48 AM
тАО06-29-2009 05:48 AM
Re: Script for Network Ping Status.
This thread may help.
http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=103638
http://hpux.connect.org.uk/hppd/hpux/Networking/Misc/ping-99.10/man.html
try adding -t
The default timeout does not give sufficient time for the answer to return to your ping command.
Also, put a set -x in the script and lets get some diagnostic data.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-29-2009 06:03 AM
тАО06-29-2009 06:03 AM
Solutionnotifyemail=narendra.uttekar@xxxx.com
for server in $syslist
do
rand=$RANDOM
ping $server -n 3 -m 1 > /var/tmp/tempfile.$ran} 2>&1
grep "100% packet loss" /var/tmp/tempfile.$ran}
r=${?}
if [ $r -eq 0 ]
then
echo "Server ${server} failed ping test}|mailx -s "Ping Test Status" $notifyemail
fi
rm /var/tmp/tempfile.$ran}
done
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-29-2009 06:05 AM
тАО06-29-2009 06:05 AM
Re: Script for Network Ping Status.
ran}
should have been
{ran}
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-29-2009 06:20 AM
тАО06-29-2009 06:20 AM
Re: Script for Network Ping Status.
pingit()
{
ping $1 -n 1 -m 1 >/dev/null 2>&1
if [ $? = 0 ]
then
return
fi
echo "$1 not responding" |mailx -s "system monitoring: $1 status" $2
}
-m 1 parameter will put a timeout of 1 second.