LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 01-14-2011, 08:10 AM   #1
claushoyer
LQ Newbie
 
Registered: Jan 2011
Location: Copenhagen, Denmark
Posts: 2

Rep: Reputation: 0
Nagios email notification sendmail fails - extra $ is added


I have a setup with Centos 5.5, Nagios 3.2.3, sendmail 8.13.8. When a insident is happening Nagios notify-by-mail is triggered and Nagios sends via sendmail. Unfortunately there is a trailing $-sign added to the $CONTACTEMAIL. Sendmail cannot mail to xxx@mail.address$
A hack is to insert mailaddress in misccommands.cfg but I would like to have a more clean way.
Looking forward for a solution :-) - Thanks
 
Old 01-14-2011, 10:52 AM   #2
MensaWater
Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 5,950
Blog Entries: 5

Rep: Reputation: 755Reputation: 755Reputation: 755Reputation: 755Reputation: 755Reputation: 755Reputation: 755
What exactly is in your host-by-mail command definition? I use host-by-email in misccommands.cfg and don't have a problem with a trailing $ and send tons of email via sendmail from Nagios.

Note that Nagios variables use $VAR$ rather than shell variable format $VAR. The Nagios variable you need is $CONTACTEMAIL$ and NOT simply $CONTACTEMAIL.

My notify-by-email definition is:

Code:
define command{
       command_name    notify-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\nAdditional Info:\n\n$SERVICEOUTPUT$" | /usr/bin/mail -s "EMA $NOTIFICATIONTYPE$ ALERT! - $HOSTALIAS$ $SERVICEDESC$ is $SERVICESTATE$" $CONTACTEMAIL$
       }
 
Old 01-18-2011, 05:54 AM   #3
claushoyer
LQ Newbie
 
Registered: Jan 2011
Location: Copenhagen, Denmark
Posts: 2

Original Poster
Rep: Reputation: 0
Here's a copy of notify-by-mail from misccommands.cfg:

# 'notify-by-email' command definition
define command{
command_name notify-by-email
command_line /bin/echo -e "***** Nagios *****\n\nNotification Type: $NAGIOS_NOTIFICATIONTYPE\n\nService: $NAGIOS_SERVICEDESC\nHost: $NAGIOS_HOSTALIAS\nAddress: $NAGIOS_HOSTADDRESS\nState: $NAGIOS_SERVICESTATE\n\nDate/Time: $DATE$ $TIME$\n\nAdditional Info:\n\n$NAGIOS_HOSTOUTPUT " | /bin/mail -s $NAGIOS_CONTACTEMAIL
}

I also tried a notify-by-mail like this:
# 'notify-by-email' command definition
define command{
command_name notify-by-email
command_line /bin/echo -e "***** Nagios *****\n\nNotification Type: $NAGIOS_NOTIFICATIONTYPE$\n\nService: $NAGIOS_SERVICEDESC$\nHost: $NAGIOS_HOSTALIAS$\nAddress: $NAGIOS_HOSTADDRESS$\nState: $NAGIOS_SERVICESTATE$\n\nDate/Time: $DATE$ $TIME$\n\nAdditional Info:\n\n$NAGIOS_HOSTOUTPUT$ " | /bin/mail -s $NAGIOS_CONTACTEMAIL$
}

And like this:
# 'notify-by-email' command definition
define command{
command_name notify-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NAGIOS_NOTIFICATIONTYPE$\n\nService: $NAGIOS_SERVICEDESC$\nHost: $NAGIOS_HOSTALIAS$\nAddress: $NAGIOS_HOSTADDRESS$\nState: $NAGIOS_SERVICESTATE$\n\nDate/Time: $DATE$ $TIME$\n\nAdditional Info:\n\n$NAGIOS_HOSTOUTPUT$ " | /bin/mail -s $NAGIOS_CONTACTEMAIL$
}

but I get this kind of records in maillog: (having x-ed out real mailaddress). Look at the to=XXXX@xxxxxx.yyy chich gets a tailing $ sign.

Jan 17 13:57:59 nagios-2 sendmail[26558]: p0HCvxJw026558: from=nagios, size=256, class=0, nrcpts=1, msgid=<201101171257.p0HCvxJw026558@xxxxxx.yyy>, relay=nagios@localhost
Jan 17 13:58:00 nagios-2 sendmail[26558]: p0HCvxJw026558: to=XXX@xxxxxx.yyy$, ctladdr=nagios (500/500), delay=00:00:01, xdelay=00:00:01, mailer=relay, pri=30256, relay=mail01.xxxxxx.yyy. [192.168.119.20], dsn=2.0.0, stat=Sent (p0HCw0R1009730 Message accepted for delivery)

Mailing from commandline is succesfull. Sendmail delivers correctly. I'm still confused.

Refering to the above, the first notify-by-mail command is the command which works best. Try to look at this mail which is generated by the 2nd notify-by-mail described above.

***** Nagios *****
Notification Type: RECOVERY$
Service: NTP$
Host: asic204$
Address: asic204$
State: OK$
Date/Time: 18-01-2011 13:46:40
Additional Info:
PING OK - Packet loss = 0%, RTA = 2.02 ms$

I get tailing $ on every Nagios macro!!

Last edited by claushoyer; 01-18-2011 at 06:53 AM. Reason: Adding to old record
 
Old 04-14-2011, 06:16 AM   #4
OdinnBurkni
Member
 
Registered: Feb 2007
Location: Iceland
Distribution: Fedora 14, CentOS, FreeNAS
Posts: 126

Rep: Reputation: 20
Nagios emailing

I have the same setup as MensaWater and my emailing works. Only problem I am facing is that I want to send email to another ISP and they stop it because of the ctladdr. I haven't figured out how to change that to something else than the machine's name.
Like Mensawater pointed out, you have to have $var$. But from what you have shown us you have a different variable name then the standard Nagios does. What is the reason for that?

Last edited by OdinnBurkni; 04-14-2011 at 06:18 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Nagios Email Notification Assistance deibertine Linux - Newbie 7 10-05-2012 12:19 PM
Nagios has stopped sending email notification s deibertine Linux - Software 7 05-06-2010 08:22 PM
Nagios email notification unable to work with Nail Mail fabbie Linux - Server 3 10-22-2009 11:01 PM
Email change notification in SendMail. thekillerbean Linux - Software 0 10-12-2005 02:23 PM
cant send email (using sendmail) to newly added domain user sirjosi Linux - Newbie 0 10-22-2003 01:12 AM


All times are GMT -5. The time now is 03:45 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration