Email Notifications

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
aston
Posts: 29
Joined: Fri Nov 18, 2011 9:45 am

Email Notifications

Post by aston »

Hi Guys Hope your well

i have configured email notifications for some time now and happy how its works, im looking to add a little more information to the emails and hopefully somebody can help :)

here are the current email commands im using im sure there pritty much standard and im using sendmail if that helps any one

# 'notify-host-by-email' command definition
define command{
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress:$HOSTADDRESS$\nInfo:$HOSTOUTPUT$\\nDate/Time:$LONGDATETIME$\n" | /usr/sbin/sendmail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
}

# 'notify-service-by-email' command definition
define command{
command_name notify-service-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/$Time:$LONGDATETIME$\n" | /usr/sbin/sendmail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
}

currently i receive an email from nagios@localhost.localdomain which was fine for initial testing but i would like to have this a little more appropriate now for example nagios@domain.com

the other thing is that there is no subject on the email, it would be great if this showed the Host and the issue

any advice would be greatly appreciated
User avatar
jsmurphy
Posts: 989
Joined: Wed Aug 18, 2010 9:46 pm

Re: Email Notifications

Post by jsmurphy »

Check out /etc/postfix/main.cf and look at the myhostname command, should give you what you are looking for :)
aston
Posts: 29
Joined: Fri Nov 18, 2011 9:45 am

Re: Email Notifications

Post by aston »

Nice one m8 im learning and learning alot but still need a bit of help every now and then, not bad at all tho considering ive got no experiance with linux previously :)
aston
Posts: 29
Joined: Fri Nov 18, 2011 9:45 am

Re: Email Notifications

Post by aston »

Hi mate ive had a quick look but i dont think those settings will effect me as im using sendmail unless u can tell me otherwise lol
User avatar
jsmurphy
Posts: 989
Joined: Wed Aug 18, 2010 9:46 pm

Re: Email Notifications

Post by jsmurphy »

oh yes sendmail... I tend to avoid it like the plague, welcome to the 7th layer of configuration hell. Working from very hazy memory you need to edit /etc/mail/sendmail.mc and add:
MASQUERADE_DOMAIN(domainname)dnl
FEATURE(masquerade_entire_domain)dnl

then recreate the config file: m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
/etc/init.d/sendmail restart

I think that's how you change it with sendmail.
aston
Posts: 29
Joined: Fri Nov 18, 2011 9:45 am

Re: Email Notifications

Post by aston »

Appreciate the Help mate

in the end i made the switch to postfix :)
User avatar
jsmurphy
Posts: 989
Joined: Wed Aug 18, 2010 9:46 pm

Re: Email Notifications

Post by jsmurphy »

Probably the easiest solution ;)
Locked