Page 1 of 1

Unable to get e-mail to send

Posted: Mon Jun 10, 2019 7:00 pm
by mijretrop
Hi All,

I'm fairly new to Ubuntu and way new to Nagios. I've done some digging and cant seem to find consistent answers on getting this set up.

I finally got to the point where I was able to send an email from the command line :

Code: Select all

echo "Subject: This Works" | sendmail -v [email protected] -f [email protected] -F "Service Events"
I use office365 cloud as my mail client and the -f with the -F was the only way I could get the e-mail to get past the outlook send from filter.

so I assumed once I got that fixed I could just paste that in the command line like :

Code: Select all

# 'notify-host-by-email' command definition
define command{
	command_name	notify-host-by-email
	command_line echo "Subject: Broke Stuff" | sendmail -v [email protected] -f [email protected] -F "Service Events"
	}

# 'notify-service-by-email' command definition
define command{
	command_name	notify-service-by-email
	command_line echo "Subject: Broke Stuff" | sendmail -v [email protected] -f [email protected] -F "Service Events"
	}
Here is my contacts.cfg file

Code: Select all

define contact{
        contact_name                    nagiosadmin		; Short name of user
	use				generic-contact		; Inherit default values from generic-contact template (defined above)
        alias                           Nagios Admin		; Full name of user
        email                         [email protected]	; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
	service_notifications_enabled	1
	host_notifications_enabled	1
        service_notification_options    w,u,c,r,f,s		; send notifications for all service states, flapping events, and scheduled downtime events
        host_notification_options       d,u,r,f,s		; send notifications for all host states, flapping events, and scheduled downtime events
        service_notification_commands   notify-service-by-email	; send service notifications via email
        host_notification_commands      notify-host-by-email	; send host notifications via email
        register                        10       		
       	service_notification_period	24x7
	host_notification_period	24x7
     }



###############################################################################
###############################################################################
#
# CONTACT GROUPS
#
###############################################################################
###############################################################################

# We only have one contact in this simple configuration file, so there is
# no need to create more than one contact group.

define contactgroup{
        contactgroup_name       admins
        alias                   Nagios Administrators
        members                 nagiosadmin
        }
I don't need to be able to check e-mail on this system, I just need a "Hey, check me out" email.

Let me know which log files you may need, I'll be happy to provide them

Thanks for any help you can give.

Re: Unable to get e-mail to send

Posted: Tue Jun 11, 2019 2:37 pm
by cdienger
Try using the full path. Something like:

Code: Select all

# 'notify-host-by-email' command definition
define command{
   command_name   notify-host-by-email
   command_line echo "Subject: Broke Stuff" | /usr/sbin/sendmail -v [email protected] -f [email protected] -F "Service Events"
   }

# 'notify-service-by-email' command definition
define command{
   command_name   notify-service-by-email
   command_line echo "Subject: Broke Stuff" | /usr/sbin/sendmail -v [email protected] -f [email protected] -F "Service Events"
   }
Verify the location and permissions with "ll `which sendmail`".

Re: Unable to get e-mail to send

Posted: Tue Jun 11, 2019 3:12 pm
by mijretrop
That did it!!!!
Thank you so much, I'd buy you a beer if were here.

Re: Unable to get e-mail to send

Posted: Tue Jun 11, 2019 3:41 pm
by cdienger
Glad to hear!