FreeBSD is just so reliable it's not funny. I mean, it just works.. However every Unix box must rely on surrounding infrastructure, like the state of the network and electricity.
It's good practice to hook up any server to an Uninterruptable Power Supply, which should help against voltage spikes as well as power outages and brown-outs (sounds a bit rude).
Having done all of this, there are still times when a) you've done all of the above and the thing still reboots and b) you couldn't be bothered to do any of the above and the thing reboots. Sometimes it's just circumstances beyond your control.
Whatever the reason, I want to know immediately if my systems have been down. There are a few ways to do this. One is to use a system like Big Brother to monitor services remotely and there are numerous third party apps which will monitor services like HTTP and alert you if the service becomes unavailable.
The system I have developed is based on my Email & SMS Script and works well, provided the server has come up again. Set the Boot/Power options in the system BIOS to the effect that if there is a power interruption, it will attempt to boot up again, rather than stay powered off.
Google for sendEmail-v1.52.tar.gz [22K] or its updated equivalent and download it to your installs directory (here shown as /src). SendEmail is written in PERL so make sure PERL is installed.
Run the following commands..
tar -zxvf sendEmail-v1.52.tar.gz
cp sendEmail /usr/local/sbin
After extracting the tarball, the single sendEmail script is copied to the /usr/local/sbin directory, which being in the system path, can be run from anywhere in the directory tree.
Secondly write a script to alert you of the situation. It may just be an email or if you're after a mobile page, then subscribe to a messaging service such as MessageNet.
Here is an example of my own shell script - sms_reboot.sh, used for sending off an SMS-email..
Log in as root..
#Andy's Server Reboot Alert Script
sendEmail -f email@example.com \
-t firstname.lastname@example.org \
-s sendmail.yoursmtpserver.com \
-xu secure_smtp_username \
-xp secure_smtp_passwd \
-u "66666 Server Alert!" \
-m "Vampyre Server has rebooted.." \
For more details on how to set up this script and use SendEmail
, see Sending SMS and Email Messages
and Email Alerter Script
Test the script by running it..
chmod 755 /root/sms_reboot.sh
Once it's working, make it run at boot time..
..and enter the line..
I have set up all my Unix servers to page me thus, with a slightly different message for each Servername. Nifty!