Nagios & Email notifications using sendEmail for use with an authenticated SMTP server

From NagiosCommunity

Jump to: navigation, search

> opensuse10.3 install of nagios 3.0 rc2

by default, nagios uses 'mail' or 'mailx' to send it's email. The actual mail command is found in the default commands.cfg file /usr/local/nagios/etc/objects/command.cfg

there are two definitions by default 'notify-host-by-email' and 'notify-service-by-email'

in each of these definitions, there is a "command_line"; this is what nagios executes in order to send mail using the mail or mailx system (varies from system to system) and it *may* need to be changed in order to work - although I must admit to not having much success so far with it myself :( (see forum thread --> http://www.meulie.net/portal_plugins/forum/forum_viewtopic.php?10126)

my command_line reads:-

/usr/bin/printf "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | mailx -A mpl -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$

As you can see, there are macro commands ($EXAMPLE$) which are replaced with data from Nagios - the admin guide has a very comprehensive list of macro commands so I won't go into it here. But the theory behind it seems to be when Nagios encounters a situation, the individual cfg files specify who and how to notify (by adding 'contct' or 'contact_groups' into the service/host definition), the specified command is then executed which in my example would send an email to the recipients of $CONTACTEMAILS$ Please note that the "-A mpl" from the command line above is specific to my installation, it calls the Account "mpl" from a .mailrc file which seems to be required (in the ~ folder) for mailx to work. Regards

Richard

Personal tools
news feeds