Monitoring a mail server

Jim Pye jim.pye at pyenet.co.nz
Wed Feb 1 23:32:03 CET 2006


No probs

In the misccommands.cfg I added the following

# 'host-notify-by-sendEmail' send host email via PERL script
define command{
        command_name    host-notify-by-sendEmail
        command_line    /usr/local/bin/sendEmail -f nagios at pyenet.co.nz
-t $CONTACTEMAIL$ -u "Host $HOSTSTATE$ alert for $H
OSTNAME$!" -s mail.pyenet.co.nz -m "***** Nagios  *****\n\nNotification
Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState:
$HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time:
$LONGDATETIME$\n"
        }


This is based on the original send email on host notification default
command. I also created one for the service notification as well.

Email has munged this a bit so synopsis is:

define command{
       command_name   host-notify-by-sendEmail

These 2 are the command defining lines

The command_line below I have broken to make more readable but to work
this all has to be on one line ???

command_line  /usr/local/bin/sendEmail

This bit above will be dependant on where you copy/install the script.

-f is the email from field. This will need to changed to an email
account that the server will allow email to be sent from.

-t is the to email to field. This here uses the $CONTACTEMAILS$ macro.

-u is the subject line. "Host $HOSTSTATE$ alert for $HOSTNAME$!" is
directly from the original send email command.

-s is the server that the email is going to be sent to. Note that this
server must be configured to accept emails from both the -f email
account and the host that this script is running on to avoid relay
denied messages.

-m is the message content. Again taken from the original send email
command. Note that the \n's make the display a bit prettier. "*****
Nagios  *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME
$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n
nDate/Time: $LONGDATETIME$\n"

For other options like attachments etc. just run the sendEmail script
without any options. As the script requires a couple of mandatory
options it prints the help file.

I use this script for all sorts of purposes like emailing log files,
etc. Very handy.

And in the contacts.cfg change the
        service_notification_commands   notify-by-email
        host_notification_commands      host-notify-by-email

to

        service_notification_commands   notify-by-sendEmail
        host_notification_commands      host-notify-by-sendEmail

for each user you wish to use the sendEmail script instead of the built
in email client.


HTH
Jim


On Wed, 2006-02-01 at 16:31 -0500, Robert Fitzpatrick wrote:
> On Thu, 2006-02-02 at 09:51 +1300, Jim Pye wrote:
> > Guys
> > 
> > Jumping in here. I use a PERL script called sendEmail available from:
> > 
> > http://caspian.dotconf.net/menu/Software/SendEmail/
> > 
> > It works from the command line and if you are interested I can give you
> > the nagios command .cfg entries to add.
> > 
> 
> Great thanks, yes, I'd like to see the .cfg entries if you'd be so kind.
> 
> 
-- 
Jim Pye
PyeNet Universal

email: jim.pye at pyenet.co.nz | Phone: +64 4 527 8284 | Fax: +64 4 528 9693
                     web site: http://www.pyenet.co.nz



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list