- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: scripting help
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
тАО09-14-2006 08:38 PM
тАО09-14-2006 08:38 PM
I have been asked to write a script that will constantly ping 14 devices ( shop tills ) and record the response time,host address and actual time.
Because this will create a huge logfile I have suggested we run the ping and only alert when the response is over a certian limit.
I have no problem with writing the ping check and limits however I am struggling to get my head around how I can ping 14 devices simaltaniously from one script - any ideas?
cheers
Solved! Go to Solution.
- Tags:
- ping
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-14-2006 08:53 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-14-2006 08:53 PM
тАО09-14-2006 08:53 PM
Re: scripting help
What about:
( ping $HOST1 &
ping $HOST2 &
ping $HOST3 &
) | do_something
rgds
HGH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-15-2006 09:14 PM
тАО09-15-2006 09:14 PM
Re: scripting help
a flexible way for me seems to be to write
- one script, monitoring one host supplied as parameter, printing an alert after n unsuccesful attempts to reach this host
- another script, calling script one for all hosts to monitor in a loop as background processes, like
trap 'kill $pidlist' '1 2 3 15' # to be customized
for h in $allhosts
do
./one $h &
pidlst="$pidlst $!"
done
So you have control over your child processes via $pidlist.
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-15-2006 09:54 PM
тАО09-15-2006 09:54 PM
Re: scripting help
You can use the subroutine:
#################################################
spng() {
P=$(/etc/ping $1 64 1 |
awk 'NR==3||NR==4 {if($7=="100%") {printf("NO");exit}}
NR==5 {printf("OK") }')
if [ $P != "OK" ]; then
return 1
else
return 0
fi
}
#################################################
cat listfile | while read ADDR; do
if spng $ADDR; then
:
# The host answers
else
(/etc/ping $ADDR 1500 10
fi
done > logfile
BTW, I'm not sure that ping is a good tool for the purpose.
HTH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-16-2006 02:52 AM
тАО09-16-2006 02:52 AM
Re: scripting help
So you must process the messages reported by ping. Also, ping may hang under some conditions so you'll need to put the ping in the background, then monitor the status every second to see if the ping completes. Naturally, you need to ping just once to see if the host responds -- using multiple pings per host makes parsing tricky. If the ping doesn't complete, kill the ping process and report on the problem.
I have attached a simple script that will take an unlimited list of IP or hostnames (comments ignored) and reports on success or failure. You'll need to modify the script for reporting.
As mentioned, ping is a trivial test for functionality. pings may be fine but the system has big problems. That's why you need a separate monitoring system that queries the system about overall status -- HP OpenView products can do this as well as freeware like Nagios. These products cover both the network health as well as system health.
Bill Hassell, sysadmin