- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Ping Script
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
12-18-2004 04:32 AM
12-18-2004 04:32 AM
I have a list of IP addresses. All I want is to ping the each and every IP address from the list/file and should able to send me an SMS message/email in case of ping failure.
Could you please let me know the script for this.
"ping
Thanks,
Nikee
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2004 06:48 AM
12-18-2004 06:48 AM
Re: Ping Script
IP_LIST="192.168.0.1 192.168.0.2 192.168.0.3"
for ip in $IP_LIST
do
ping $ip -n 1 | grep -q "100% packet loss"
if [ $? -eq 0 ]
then
mailx -s "Can't ping $ip" mail@company.com
fi
done
Ofcourse, you need to test the above script and
check for syntax errors as I did not run it on an
actual machine. Note that you could use hostname
instead of IP address in the IP_LIST, but make
sure that nslookup on the hostname returns
success; otherwise the above script will return
ping success for non-existing hostnames. Handling
non-existing hostname should be the enhancement
to this script.
- Biswajit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2004 11:21 PM
12-19-2004 11:21 PM
SolutionFar more flexible then just ping.
Software can be found here http://hpux.cs.utah.edu/
Something we use to check routers, switches and servers.
Basic script
/opt/fping/sbin/fping -u -f {file of hosts} > /tmp/ping_errors
VAR=`cat /tmp/ping_errors |wc -l`
if [ $VAR -gt 1 ]
then
mailx -s "ping Alert" pager@myairmail.com < /tmp/ping_errors
else
echo "Everything on line" > /tmp/ping_errors
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2004 12:38 AM
12-20-2004 12:38 AM
Re: Ping Script
I have attached you a small example, using Net:Ping
and two hosts to ping.
Regards,Stan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2004 01:03 AM
12-20-2004 01:03 AM
Re: Ping Script
the Net::Ping module that Stanimir mentioned is well worth noting.
Other than scripts that use the system ping command that use ICMP packages and thus require root privileges (have a look at the setuid bit of /usr/sbin/ping) the Net::Ping is much more flexible.
Therefore I would rather chose TCP or UDP (the default of net::Ping) for transport.
Just specify the transport as an argument in the constructor call.
We for instance have many hosts in firewalled LANs, and the firewalls silently drop everything that isn't 22/tcp (and other required services like Domain, NTP etc.)
So there's never an echo reply on an ICMP echo request.
With Net::Ping you can specify the SSH port 22 and chose TCP as transport, and can "ping" all those hosts (together with a control that an sshd is responding.
If you require more sophistication to "Fool" your firewalls then I'd suggest to use nmap
(http://www.insecure.org/nmap/)
It lets you chose all sorts of handshakes or only send SYN packets.
See its manpage for details.