Emails are not being sent in 2011R2.0

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
User avatar
Mitchell
Posts: 130
Joined: Thu Jan 05, 2012 2:33 am

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

Post 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
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

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

Post 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
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
User avatar
Mitchell
Posts: 130
Joined: Thu Jan 05, 2012 2:33 am

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

Post 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)
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

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

Post by scottwilkerson »

Try

Code: Select all

yum install mailx
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
User avatar
Mitchell
Posts: 130
Joined: Thu Jan 05, 2012 2:33 am

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

Post 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?
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

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

Post 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
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
User avatar
Mitchell
Posts: 130
Joined: Thu Jan 05, 2012 2:33 am

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

Post by Mitchell »

Thank you. This worked.
Just FYI, I had to use (- r) for it to work.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

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

Post by scottwilkerson »

Glad you got it working. It kind of depends on the mail version...
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked