Page 1 of 1

Email Notifications

Posted: Tue Dec 06, 2011 12:10 pm
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 [email protected] which was fine for initial testing but i would like to have this a little more appropriate now for example [email protected]

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

Re: Email Notifications

Posted: Tue Dec 06, 2011 4:47 pm
by jsmurphy
Check out /etc/postfix/main.cf and look at the myhostname command, should give you what you are looking for :)

Re: Email Notifications

Posted: Tue Dec 06, 2011 4:51 pm
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 :)

Re: Email Notifications

Posted: Wed Dec 07, 2011 11:55 am
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

Re: Email Notifications

Posted: Wed Dec 07, 2011 4:29 pm
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.

Re: Email Notifications

Posted: Fri Dec 09, 2011 7:48 am
by aston
Appreciate the Help mate

in the end i made the switch to postfix :)

Re: Email Notifications

Posted: Mon Dec 12, 2011 5:11 pm
by jsmurphy
Probably the easiest solution ;)