Mail Stopped working...

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.
User avatar
ruffsense
Posts: 140
Joined: Thu Apr 11, 2013 12:40 am

Re: Mail Stopped working...

Post by ruffsense »

slansing wrote:You can visit the service details page of one of your services and use the "Send custom service notification" button to send a test notification, this will be sent to contacts assigned to the configuration file.

In my nagios.log i get this error...

Code: Select all

[1366714850] EXTERNAL COMMAND: SEND_CUSTOM_SVC_NOTIFICATION;localhost;Swap Usage;0;c.vanaxel;test
[1366714850] SERVICE NOTIFICATION: nagiosadmin;localhost;Swap Usage;CUSTOM (OK);notify-service-by-email;SWAP OK - 100% free (3967 MB out of 3967 MB);c.vanaxel;test
[1366714850] Warning: Attempting to execute the command "/usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: CUSTOM\n\nService: Swap Usage\nHost: localhost\nAddress: 127.0.0.1\nState: OK\n\nDate/Time: Tue Apr 23 13:00:50 CEST 2013\n\nAdditional Info:\n\nSWAP OK - 100% free (3967 MB out of 3967 MB)\n" | /bin/mail -s "** CUSTOM Service Alert: localhost/Swap Usage is OK **" [email protected]" resulted in a return code of 127.  Make sure the script or binary you are trying to execute actually exists...
User avatar
gshergill
Posts: 231
Joined: Tue Aug 07, 2012 5:08 am

Re: Mail Stopped working...

Post by gshergill »

Hi ruffsense,

Can you run the command below and post the output please:

Code: Select all

ls -l /bin/mail
Was your mail working fine before? Which mail server did you install?

Thank you.

Kind Regards,

Gary Shergill
User avatar
ruffsense
Posts: 140
Joined: Thu Apr 11, 2013 12:40 am

Re: Mail Stopped working...

Post by ruffsense »

Code: Select all

ls: cannot access /bin/mail: No such file or directory
I installed sendmail
User avatar
gshergill
Posts: 231
Joined: Tue Aug 07, 2012 5:08 am

Re: Mail Stopped working...

Post by gshergill »

Hi ruffsense,
ls: cannot access /bin/mail: No such file or directory
You need to change your mail command in commands.cfg to the location of your mail.

I'm not entirely sure where it is for sendmail, I used postfix and heirloom-mailx so mine would be different.

The change required is the /bin/mail part of the notification command, maybe try /usr/bin/mail, i.e.

Code: Select all

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$\n\nDate/Time: $LONGDATETIME$\n" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
   register                          1
}   

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\nAdditional Info:\n\n$SERVICEOUTPUT$" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
   register                          1
}   
Maybe wait for one of the Nagios support staff to reply with the exact location though incase mine is wrong.

Good luck!

Kind Regards,

Gary Shergill
User avatar
ruffsense
Posts: 140
Joined: Thu Apr 11, 2013 12:40 am

Re: Mail Stopped working...

Post by ruffsense »

gshergill wrote:Hi ruffsense,
ls: cannot access /bin/mail: No such file or directory
You need to change your mail command in commands.cfg to the location of your mail.

I'm not entirely sure where it is for sendmail, I used postfix and heirloom-mailx so mine would be different.

The change required is the /bin/mail part of the notification command, maybe try /usr/bin/mail, i.e.

Code: Select all

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$\n\nDate/Time: $LONGDATETIME$\n" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
   register                          1
}   

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\nAdditional Info:\n\n$SERVICEOUTPUT$" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
   register                          1
}   
Maybe wait for one of the Nagios support staff to reply with the exact location though incase mine is wrong.

Good luck!

Kind Regards,

Gary Shergill

Is this also possible?

Code: Select all

/usr/sbin/sendmail
User avatar
ruffsense
Posts: 140
Joined: Thu Apr 11, 2013 12:40 am

Re: Mail Stopped working...

Post by ruffsense »

I have to nagios core servers. On both i installed sendmail. On one it works fines.

(this one is good)ls -l /var/spool/mail/

-rw-rw----. 1 nagios mail 1977441 Jun 16 2012 nagios
-rw-------. 1 root root 60686 Mar 31 19:01 root

(this one is wrong)ls -l /var/spool/mail/
-rw-rw----. 1 nagios mail 0 Apr 12 10:52 nagios
-rw------- 1 root root 4547 Apr 23 15:53 root
It stay''s zero
User avatar
gshergill
Posts: 231
Joined: Tue Aug 07, 2012 5:08 am

Re: Mail Stopped working...

Post by gshergill »

Hi ruffsense,

That should be fine, I'm not sure where sendmail is, /usr/bin/mail was just a guess.

If you think it's /usr/sbin/sendmail you should use that, hopefully it works!

Kind Regards,

Gary Shergill
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Mail Stopped working...

Post by scottwilkerson »

or you can just type

Code: Select all

which sendmail
to know for sure what one you have...
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
User avatar
ruffsense
Posts: 140
Joined: Thu Apr 11, 2013 12:40 am

Re: Mail Stopped working...

Post by ruffsense »

scottwilkerson wrote:or you can just type

Code: Select all

which sendmail
to know for sure what one you have...
I finally found an error...

Code: Select all

NOQUEUE: SYSERR(nagios): can not chdir(/var/spool/clientmqueue/): Permission denied
(1/2): sendmail-8.14.4-8.el6.x86_64.rpm
(2/2): sendmail-cf-8.14.4-8.el6.noarch.rpm
User avatar
ruffsense
Posts: 140
Joined: Thu Apr 11, 2013 12:40 am

Re: Mail Stopped working...

Post by ruffsense »

Problem is solved.

I added the nagios user to the group: snmsp

thnx for the fast respaonce and help!
Locked