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.
ruffsense
Posts: 140 Joined: Thu Apr 11, 2013 12:40 am
Post
by ruffsense » Tue Apr 23, 2013 6:06 am
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...
gshergill
Posts: 231 Joined: Tue Aug 07, 2012 5:08 am
Post
by gshergill » Tue Apr 23, 2013 7:07 am
Hi ruffsense,
Can you run the command below and post the output please:
Was your mail working fine before? Which mail server did you install?
Thank you.
Kind Regards,
Gary Shergill
ruffsense
Posts: 140 Joined: Thu Apr 11, 2013 12:40 am
Post
by ruffsense » Tue Apr 23, 2013 8:23 am
Code: Select all
ls: cannot access /bin/mail: No such file or directory
I installed sendmail
gshergill
Posts: 231 Joined: Tue Aug 07, 2012 5:08 am
Post
by gshergill » Tue Apr 23, 2013 8:28 am
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
ruffsense
Posts: 140 Joined: Thu Apr 11, 2013 12:40 am
Post
by ruffsense » Tue Apr 23, 2013 8:46 am
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?
ruffsense
Posts: 140 Joined: Thu Apr 11, 2013 12:40 am
Post
by ruffsense » Tue Apr 23, 2013 9:02 am
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
gshergill
Posts: 231 Joined: Tue Aug 07, 2012 5:08 am
Post
by gshergill » Tue Apr 23, 2013 9:04 am
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:
Post
by scottwilkerson » Tue Apr 23, 2013 12:14 pm
or you can just type
to know for sure what one you have...
ruffsense
Posts: 140 Joined: Thu Apr 11, 2013 12:40 am
Post
by ruffsense » Thu Apr 25, 2013 2:26 am
scottwilkerson wrote: or you can just type
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
ruffsense
Posts: 140 Joined: Thu Apr 11, 2013 12:40 am
Post
by ruffsense » Thu Apr 25, 2013 5:47 am
Problem is solved.
I added the nagios user to the group: snmsp
thnx for the fast respaonce and help!