| Author |
Message |
hthb
Joined: 19 Feb 2004
Posts: 14
Location: Iceland
|
| Posted: Wed Jun 23, 2004 7:59 am Post subject: Email notification if server goes down |
|
|
Hi. I just wanted to know if it is possible to get an email notification if hostXX has to be restarted or networks get disconnected (because of host problems)?
I'd like that very much.
BTW, I think linode.com is a great service worthy of my $$
:) |
|
| Back to top |
|
ronpoz
Joined: 05 Jun 2004
Posts: 39
Location: Brooklyn, NY
|
| Posted: Wed Jun 23, 2004 8:21 am Post subject: |
|
|
You could always sign up for a free account at:
http://www.siteuptime.com or http://www.easymonitor.com
Both are free and can send you an SMS message..
Ron |
|
| Back to top |
|
NecroBones
Joined: 16 Mar 2004
Posts: 111
Location: Sterling, VA
|
| Posted: Wed Jun 23, 2004 9:27 am Post subject: |
|
|
A simple solution, at least for the restart part (not bandwidth disconnects) is to have a script that gets run from your rc.local startup script that will e-mail you. Here's an example:
Code:
#!/bin/sh
#
# This file, placed in /etc/rc.d/rc.local, will send an e-mail
# alert when the system boots up.
SYSADMIN=whatever@yourdomain.tld
MAIL="/bin/mail"
HOSTNAME=`hostname`
MSG="$HOSTNAME System restart!"
(
echo "$MSG"
echo " "
/usr/bin/uname -a
echo " "
/usr/bin/uptime
echo " "
/usr/bin/last -10
echo " "
/bin/df -m
echo " "
) | $MAIL -s "$MSG" $SYSADMIN
exit 0
In this example I also have it showing a few system statistics too. You'd of course have to edit paths if they're different on your system, and put your own e-mail address in. (the paths may not even be necessary, it depends on where/how you call the script from your startup scripts). |
|
| Back to top |
|
hthb
Joined: 19 Feb 2004
Posts: 14
Location: Iceland
|
| Posted: Wed Jun 23, 2004 9:36 am Post subject: |
|
|
NecroBones wrote: A simple solution, at least for the restart part (not bandwidth disconnects) is to have a script that gets run from your rc.local startup script that will e-mail you. Here's an example:
Code:
#!/bin/sh
#
# This file, placed in /etc/rc.d/rc.local, will send an e-mail
# alert when the system boots up.
SYSADMIN=whatever@yourdomain.tld
MAIL="/bin/mail"
HOSTNAME=`hostname`
MSG="$HOSTNAME System restart!"
(
echo "$MSG"
echo " "
/usr/bin/uname -a
echo " "
/usr/bin/uptime
echo " "
/usr/bin/last -10
echo " "
/bin/df -m
echo " "
) | $MAIL -s "$MSG" $SYSADMIN
exit 0
In this example I also have it showing a few system statistics too. You'd of course have to edit paths if they're different on your system, and put your own e-mail address in. (the paths may not even be necessary, it depends on where/how you call the script from your startup scripts).
Don't I have to have postfix or something like that installed and configured then? |
|
| Back to top |
|
NecroBones
Joined: 16 Mar 2004
Posts: 111
Location: Sterling, VA
|
| Posted: Thu Jun 24, 2004 9:14 am Post subject: |
|
|
| 'mail' is a mail client program that's fairly common in several distros, I think... most of my experience is with slackware however. I guess if you don't have any MTA installed at all, it might be a tad more difficult. I think you can use a .mailrc file to change it's behaviour, possibly specify another mail relay other than the localhost, but I haven't looked that deeply into it. |
|
| Back to top |
|
SteveG
Joined: 30 Nov 2003
Posts: 221
|
| Posted: Thu Jun 24, 2004 6:53 pm Post subject: |
|
|
/bin/mail is strictly local, it calls /usr/sbin/sendmail to send mail. Now, /usr/sbin/sendmail may be provided by any number of MTAs, such as Sendmail, Postfix, or Exim. If you don't have any of those set up, and have another server you can relay through, you can use 'ssmtp', whichcan do that (and *only* that: no local spool, no reception, no nothing).
OTOH, it's fairly difficult to setup an Linux machine w/o *any* MTA installed, even if it's configured only for local delivery. Check if you already have a /usr/sbin/sendmail (or possibly /usr/lib/sendmail), and use the appropriate distro specific tool to find out what package put it there (e.g. 'dpkg -S /usr/sbin/sendmail) |
|
| Back to top |
|
| |