Page 2 of 2

Re: Mail Stopped working...

Posted: Tue Apr 23, 2013 6:06 am
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...

Re: Mail Stopped working...

Posted: Tue Apr 23, 2013 7:07 am
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

Re: Mail Stopped working...

Posted: Tue Apr 23, 2013 8:23 am
by ruffsense

Code: Select all

ls: cannot access /bin/mail: No such file or directory
I installed sendmail

Re: Mail Stopped working...

Posted: Tue Apr 23, 2013 8:28 am
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

Re: Mail Stopped working...

Posted: Tue Apr 23, 2013 8:46 am
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

Re: Mail Stopped working...

Posted: Tue Apr 23, 2013 9:02 am
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

Re: Mail Stopped working...

Posted: Tue Apr 23, 2013 9:04 am
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

Re: Mail Stopped working...

Posted: Tue Apr 23, 2013 12:14 pm
by scottwilkerson
or you can just type

Code: Select all

which sendmail
to know for sure what one you have...

Re: Mail Stopped working...

Posted: Thu Apr 25, 2013 2:26 am
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

Re: Mail Stopped working...

Posted: Thu Apr 25, 2013 5:47 am
by ruffsense
Problem is solved.

I added the nagios user to the group: snmsp

thnx for the fast respaonce and help!