RE: If The Web Server Shuts Down Send me a Page
by extremely (Priest) on Nov 01, 2000 at 08:29 UTC
|
Assuming you want a page when it restarts, you should be able
to stick a simple Net::SMTP script into the /etc/rc.d/init.d/
directories to send you one.
If you want to know when it quits responding, you are
going to have to monitor it from a computer outside the
house where the power might die. If you have a reliable
computer that you can stick Perl monitoring scripts on
outside of the "danger zone" but that you can't run webservers
on, look into a monitoring package like Mon
or NetSaint. Those
both have the extremely stamp of approval... Mon is more
Perlish and lovey-dovey, NetSaint is a mix of Perl and C
and looks shinier...
--
$you = new YOU;
honk() if $you->love(perl) | [reply] |
Re: If The Web Server Shuts Down Send me a Page
by Adam (Vicar) on Nov 01, 2000 at 08:16 UTC
|
Um... I have a silly question... how are you going to detect that the page is down when your computer is turned off? You would need a second machine. Ok, assuming you get past that problem, you just need to write a script that tries to get data from your web server every-so-often, and have that script e-mail you when it fails. This is not that difficult a task, but requires you to run a speudo-daemon or speudo-service to do the polling. Not exactly the best choice. (There may also be off-the-shelf solutions to do it.)
If you scan through the archives of the monastery you should find example scripts for sending e-mail from a script (using sendmail or SMTP) and hitting your server with a request is relatively straight forward. Good luck. | [reply] |
RE: If The Web Server Shuts Down Send me a Page
by little (Curate) on Nov 01, 2000 at 15:03 UTC
|
I'd suggest you get a Uninterruptible Power Supply (UPS) to protect the server on power cut. When you get a system like a Merlin Gerin (MGE)UPS or other with I-O card (they call that "U-Talk"), the computer will notice the power cut and could take any possible action within the time left (depending on number of accu packs somewhere between 5 upto 20 min.) Btw, some servers such as COMPAQ Prosignia and ProLiant do support messaging to a pager / skyper or making a call through installed modems or other connections on system errors, but there also is power cut truely the problem.
Update: you might follow the link to an APC UPS which might suffice for your needs.
Have a nice day
All decision is left to your taste | [reply] |
RE: If The Web Server Shuts Down Send me a Page
by KM (Priest) on Nov 01, 2000 at 18:24 UTC
|
Well, you would want box B to monitor box A. You can either write a Perl script to try to LWP a page every X minutes, and if it can't, page you.. or use something like Big Brother to watch things for you.
Cheers,
KM | [reply] |
Re: If The Web Server Shuts Down Send me a Page
by cadfael (Friar) on Nov 01, 2000 at 19:37 UTC
|
I really don't think a server power-down is a trappable event...
But an alternative might be placing a mail command in the script
that starts the server. This, of course, would not need to
be done in Perl.
Do you have another server in a more secure location that
could be used instead? If you need 24x7 uptime, or close to it,
then relying on your roommates seems a bit dangerous.
-----
"Computeri non cogitant, ergo non sunt" | [reply] |
Re: If The Web Server Shuts Down Send me a Page
by Anonymous Monk on Nov 01, 2000 at 08:10 UTC
|
the only way you can do anything if your 'puter shuts down is if it is shut down properly, not if the power is cut.
it involves capturing sig's. | [reply] |
Re: If The Web Server Shuts Down Send me a Page
by chromatic (Archbishop) on Nov 01, 2000 at 23:54 UTC
|
I'd write a cron job that periodically checks the httpd.pid file, tests to see if it's valid, restarting the server and sending a mail if not. Monitoring it from another location with LWP is a good idea, but assumes that the network links between the second box and the first are reliable. (That may or may not be an assumption you're comfortable making.)
O'Reilly's Perl for System Administrators suggests not sending mail directly from a monitoring script, if you have more than one. Rather, aggregate all of the responses and just send one e-mail with all of the emergency messages. | [reply] |
Re: If The Web Server Shuts Down Send me a Page
by blogan (Monk) on Nov 01, 2000 at 20:09 UTC
|
Try configuring your computer to automatically turn back on when the power comes back up (check the BIOS) if you have an ATX type power supply. Then when the machine comes up, have a script in /etc/rc.d/rc.5 (or rc.3) that makes sure the web server is running and that your connected to the outside world. | [reply] |
Re: If The Web Server Shuts Down Send me a Page
by spaz (Pilgrim) on Nov 02, 2000 at 01:06 UTC
|
Uhm, you could use Big Brother which will probably do everything you want, and more, a lot better than you could (nothing personal). It does require a second machine as Adam pointed out. | [reply] |