Page 2 of 2

Re: Emails are not being sent in 2011R2.0

Posted: Mon Feb 20, 2012 12:46 pm
by Mitchell

Code: Select all

[root@### ~]# su nagios -c '/usr/bin/printf "%b" "***** Nagios Monitor XI Alert *****\n"'
***** Nagios Monitor XI Alert *****
You have new mail in /var/spool/mail/root
however I didnt see the mail if there was supposed to be one... here is the last email in mails for root user...
###### WARNING ######
Errors reported during AutoMySQLBackup execution.. Backup failed
Error log below..
mysqldump: Got error: 1044: Access denied for user 'root'@'localhost' to database 'information_schema' when using LOCK TABLES

From root@###.###.com Mon Feb 20 08:00:03 2012
Return-Path: <root@###.###.com>
X-Original-To: root
Delivered-To: root@###.###.com
Received: by root@###.###.com (Postfix, from userid 0)
id 5FE4F2213C; Mon, 20 Feb 2012 08:00:03 -0800 (PST)
From: root@###.###.com (Cron Daemon)
To: root@###.###.com
Subject: Cron <root@###> /root/scripts/autopostgresqlbackup
Content-Type: text/plain; charset=UTF-8
Auto-Submitted: auto-generated
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/root>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=root>
X-Cron-Env: <USER=root>
Message-Id: <20120220160003.5FE4F2213C@###.###.com>
Date: Mon, 20 Feb 2012 08:00:03 -0800 (PST)

/root/scripts/autopostgresqlbackup: line 491: mail: command not found

Re: Emails are not being sent in 2011R2.0

Posted: Mon Feb 20, 2012 12:56 pm
by scottwilkerson
It is ironic that you showed me the mail message because even though it wasn't related, the last line I think says the problem
Mitchell wrote:/root/scripts/autopostgresqlbackup: line 491: mail: command not found
The full command that notify-host-by-email and notify-service-by-email run looks like this:

Code: Select all

/usr/bin/printf "%b" "***** Nagios Monitor XI Alert *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
So, it also pipes the output to /bin/mail
can I have you run the following to see if it can find mail on your system

Code: Select all

which mail

Re: Emails are not being sent in 2011R2.0

Posted: Mon Feb 20, 2012 1:10 pm
by Mitchell

Code: Select all

[root@pnagios02lxv mail]# which mail
/usr/bin/which: no mail in (/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)

Re: Emails are not being sent in 2011R2.0

Posted: Mon Feb 20, 2012 2:13 pm
by scottwilkerson
Try

Code: Select all

yum install mailx

Re: Emails are not being sent in 2011R2.0

Posted: Mon Feb 20, 2012 3:06 pm
by Mitchell
okay. this solved the email not being sent issue.
however have another issue now... the FROM email address. mailx is taking the FROM email address nagios@###.###.com (user@hostname). I want to change it to our standards.

on a side note: would you be including the mailx package with next version of XI VM appliance?

Re: Emails are not being sent in 2011R2.0

Posted: Mon Feb 20, 2012 3:44 pm
by scottwilkerson
You may want to check the man page of your mail version, but you may be able to modify the send commands to add a from header like so

Code: Select all

/usr/bin/printf "%b" "***** Nagios Monitor XI Alert *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$ -- -f [email protected]
Adding to the end of the commands

Re: Emails are not being sent in 2011R2.0

Posted: Mon Feb 20, 2012 5:20 pm
by Mitchell
Thank you. This worked.
Just FYI, I had to use (- r) for it to work.

Re: Emails are not being sent in 2011R2.0

Posted: Mon Feb 20, 2012 7:58 pm
by scottwilkerson
Glad you got it working. It kind of depends on the mail version...