You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Jochen Kächelin <jk...@linux.amsjk.de> on 2002/10/31 02:17:25 UTC

[users@httpd] Testing if a Webserver is down

What is the most reliable way to test if a Webserver died
(httpd died, network down, no longer reachable) using a bash-script
running a loop?

If the bash-script recognized that the webserver is down I wan't
a  backup-server  to  shutdown  the  ip  and  restart  with the died
webservers' ip to his job until the original webserver is restored.

-- 
Jochen Kaechelin


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: Re[2]: [users@httpd] Testing if a Webserver is down

Posted by timuel <ti...@voicenet.com>.
Check these out:

http://stein.cshl.org/~lstein/talks/perl_conference/cute_tricks/sos3.html
(will restart a dead apache on localhost... very easy to customize)

AND

http://www.backhand.org/wackamole/
(will bring up an IP on one machine when it dies on another... not as easy to
customize)

--
Tim Wesemann


----- Original Message -----
From: "Jacob Coby" <jc...@listingbook.com>
To: <us...@httpd.apache.org>; <jk...@linux.amsjk.de>
Sent: Thursday, October 31, 2002 11:01 AM
Subject: Re: Re[2]: [users@httpd] Testing if a Webserver is down


| > AST> You could ping the domain in a loop
| > AST> ping <IP> -t
| >
| > Yes, I know, but how can I check it with a bash script?
| >
| > I  pipe  the  output  of  the ping comand through grep and count the
| > returned lines? But I really no nothing about bash-programming!
|
| Using ping is a bad idea, it won't give you meaningful results, unless the
| server is on fire or turned off.  I've had a webserver here go down (kernel
| panic), and it still responds to ping.
|
| Bash is really pretty easy to program for, using wget you can do:
|
| #!/bin/bash
|
| wget -t 1 -T 30 -q www.asdfjklsadfsdf.com
|
| if [ $? == 0 ]; then
|   echo 'server is up!';
| else
|   echo 'server is down!';
| fi
| ----
|
| from there, it's just a matter of plugging in your own scripts on what to do
| when the server is down :)
|
| Another option is nagios, a daemon that runs on one server and monitors
| other servers.  Comes with a web interface with nice features, and can email
| or page people responsable for bringing the downed server back up.
|
| -Jacob
|
|
| ---------------------------------------------------------------------
| The official User-To-User support forum of the Apache HTTP Server Project.
| See <URL:http://httpd.apache.org/userslist.html> for more info.
| To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
|    "   from the digest: users-digest-unsubscribe@httpd.apache.org
| For additional commands, e-mail: users-help@httpd.apache.org
|
|


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: Re[2]: [users@httpd] Testing if a Webserver is down

Posted by Jacob Coby <jc...@listingbook.com>.
> AST> You could ping the domain in a loop
> AST> ping <IP> -t
>
> Yes, I know, but how can I check it with a bash script?
>
> I  pipe  the  output  of  the ping comand through grep and count the
> returned lines? But I really no nothing about bash-programming!

Using ping is a bad idea, it won't give you meaningful results, unless the
server is on fire or turned off.  I've had a webserver here go down (kernel
panic), and it still responds to ping.

Bash is really pretty easy to program for, using wget you can do:

#!/bin/bash

wget -t 1 -T 30 -q www.asdfjklsadfsdf.com

if [ $? == 0 ]; then
  echo 'server is up!';
else
  echo 'server is down!';
fi
----

from there, it's just a matter of plugging in your own scripts on what to do
when the server is down :)

Another option is nagios, a daemon that runs on one server and monitors
other servers.  Comes with a web interface with nice features, and can email
or page people responsable for bringing the downed server back up.

-Jacob


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


RE: Re[2]: [users@httpd] Testing if a Webserver is down

Posted by Gilles Gros <gi...@whitepj.com>.
use ping -c 5 IP

man ping :

     -c count
             Stop after sending (and receiving) count packets. After the
pack-
             ets are sent, ping will wait up to ten seconds for replies to
             arrive, then exit.
Gilles


> -----Original Message-----
> From: Jochen Kächelin [mailto:jk@linux.amsjk.de]
> Sent: Wednesday, October 30, 2002 5:36 PM
> To: users@httpd.apache.org
> Subject: Re[2]: [users@httpd] Testing if a Webserver is down
>
>
> AST> You could ping the domain in a loop
> AST> ping <IP> -t
>
> Yes, I know, but how can I check it with a bash script?
>
> I  pipe  the  output  of  the ping comand through grep and count the
> returned lines? But I really no nothing about bash-programming!
>
> --
> Jochen
>
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re[2]: [users@httpd] Testing if a Webserver is down

Posted by Jochen Kächelin <jk...@linux.amsjk.de>.
AST> You could ping the domain in a loop
AST> ping <IP> -t

Yes, I know, but how can I check it with a bash script?

I  pipe  the  output  of  the ping comand through grep and count the
returned lines? But I really no nothing about bash-programming!

-- 
Jochen


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Testing if a Webserver is down

Posted by "Alex \"Sniper\" Togstad" <sn...@3dretreat.com>.
You could ping the domain in a loop

ping <IP> -t

If you get a response from the domain then its up, if it times out then its
down. . .

Hope that helps

----
Alex Togstad
Web Developer
alextogstad@3dretreat.com


----- Original Message -----
From: "Jochen Kächelin" <jk...@linux.amsjk.de>
To: <va...@redhat.com>
Sent: Wednesday, October 30, 2002 5:17 PM
Subject: [users@httpd] Testing if a Webserver is down


> What is the most reliable way to test if a Webserver died
> (httpd died, network down, no longer reachable) using a bash-script
> running a loop?
>
> If the bash-script recognized that the webserver is down I wan't
> a  backup-server  to  shutdown  the  ip  and  restart  with the died
> webservers' ip to his job until the original webserver is restored.
>
> --
> Jochen Kaechelin
>
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


RE: [users@httpd] Testing if a Webserver is down

Posted by Koen Vingerhoets <ko...@ubench.com>.
Hi,

I made with many help from this list a script that checks whether it can
find a page, restart the webserver if not, and then check again.  Every
error will sent messages.
It's written for Win2000...

Met vriendelijke groet,

Koen Vingerhoets

***** UBench nv *****
http://www.ubench.com
____________________________________________
The information contained in this electronic mail message is privileged and
confidential,
and is intended only for use of the addressee. If you are not the intended
recipient, you
are hereby notified that any disclosure,reproduction, distribution or other
use of this
communication is strictly prohibited.

If you have received this communication in error, please notify the sender
by reply
transmission and delete the message without copying or disclosing it.


-----Original Message-----
From: Jochen Kächelin [mailto:jk@linux.amsjk.de]
Sent: 31 October 2002 02:17
To: valhalla-list@redhat.com
Subject: [users@httpd] Testing if a Webserver is down


What is the most reliable way to test if a Webserver died
(httpd died, network down, no longer reachable) using a bash-script
running a loop?

If the bash-script recognized that the webserver is down I wan't
a  backup-server  to  shutdown  the  ip  and  restart  with the died
webservers' ip to his job until the original webserver is restored.

--
Jochen Kaechelin


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org





---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


RE: [users@httpd] Testing if a Webserver is down

Posted by Kevin Ingolfsland <Ke...@Ingolfsland.net>.
WGET (http://www.gnu.org/software/wget/wget.html) would be a good solution.
You can have it download a page from somewhere on your site.   Then you
could check to see if the page was actually downloaded (or wget might even
return an error code if it couldn't connect... not sure).  If the page
wasn't downloaded you could then perform whatever recovery action you needed
to.

I agree with Boyle Owen that a custom perl script would be a more powerful,
flexible, and all around better solution... but it would not be as easy to
implement.

Kevin Ingolfsland

-----Original Message-----
From: Jochen Kächelin [mailto:jk@linux.amsjk.de]
Sent: Wednesday, October 30, 2002 8:17 PM
To: valhalla-list@redhat.com
Subject: [users@httpd] Testing if a Webserver is down


What is the most reliable way to test if a Webserver died
(httpd died, network down, no longer reachable) using a bash-script
running a loop?

If the bash-script recognized that the webserver is down I wan't
a  backup-server  to  shutdown  the  ip  and  restart  with the died
webservers' ip to his job until the original webserver is restored.

--
Jochen Kaechelin


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org




---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org