LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 05-04-2002, 04:58 AM   #1
saavik
Member
 
Registered: Nov 2001
Location: NRW, Germany
Distribution: SLES / FC/ OES / CentOS
Posts: 614

Rep: Reputation: 32
check if server is alive by ping


hy!
is it possible to check if my server is up by ping ?

yes it is ofcause!

but is it also possible to send me an email if:


From xx.xx.xx.xxx icmp_seq=2613 Destination Host Unreachable

and can this be done for serveral servers?

Don`t want to use snmp!
 
Old 05-06-2002, 09:36 AM   #2
Mik
Senior Member
 
Registered: Dec 2001
Location: The Netherlands
Distribution: Ubuntu
Posts: 1,316

Rep: Reputation: 47
How about something like this:

Code:
#!/bin/bash

checkhost()
{
  ping -c 2 $1 &> /dev/null

  if [ $? != 0 ]
  then

mail root <<EOS
Host $1 is down
EOS

  fi
}

for host in host1 host2 host3
do
  checkhost $host
done
I haven't checked the code so if it contains any spelling mistakes you'll have to fix them yourself.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Keep Alive Ping Script Apollo77 Linux - Networking 8 05-19-2006 12:29 PM
Is my server alive? jbhanc0125 Programming 1 06-28-2005 10:03 PM
hosting and ping samba server name as well as mail server name simultaneously cbekannan Linux - General 2 01-11-2005 12:11 AM
windows 98 m/c ping to ip address of red hat server but fails to ping hostname ravilohot Linux - Networking 2 09-07-2004 04:57 AM
minimum live cd distro to check ping mehargags Linux - Distributions 2 05-04-2004 06:14 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 05:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration