[Solved] Install won't relay off of my Exchange 2007 server

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.
jbruyet
Posts: 235
Joined: Wed Dec 28, 2011 12:14 pm

[Solved] Install won't relay off of my Exchange 2007 server

Post by jbruyet »

Hey all, I had a simple Nagios server running on CentOS and decided to move it over to my FreeBSD 9.1 server. it's running great so now I'm working on notifications and I'm not making any progress. I am able to send an email to myself from the command line so my Exchange server is allowing my Nagios to relay off of it, when I check the maillog I see a bunch of "stat=Sent" lines so I'm pretty sure that the emails are leaving the Nagios server but I'm not seeing anything from it in my Exchange queue. I read several articles that said I needed to install sendEmail so I did that but I can't see where I direct traffic to my Exchange server so I'll get the emails. I'm not sure what my next steps should be so here I am. Does anyone know where I can find a tutorial that will help me get my Nagios alerts sent to me as emails?

Thanks,

Joe B
Last edited by jbruyet on Sat Jan 11, 2014 11:12 am, edited 1 time in total.
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Install won't relay off of my Exchange 2007 server

Post by slansing »

Can you choose one host > service definition to test with and share your host, and service configuration definitions for them as well as the templates that may or may not be assigned? We'd like to take a look at the notification commands that are being used.
jbruyet
Posts: 235
Joined: Wed Dec 28, 2011 12:14 pm

Re: Install won't relay off of my Exchange 2007 server

Post by jbruyet »

Sorry for the slow reply; we're getting a new radio system and that's been my priority. Then I somehow wiped out a bunch of my files. Sigh, everything is backed up now.

Ok, it's a bit long but here goes...

My Workstation:

Code: Select all

# Last Modified: 11-14-2012
###############################################################################
define host {
        name Test
        use generic-host
        check_period 24x7
        check_interval 5
        retry_interval 1
        max_check_attempts 10
        check_command check-host-alive
        notification_period 24x7
        notification_interval 30
        notification_options d,r
        contact_groups MailContacts
        register 1
    }

# HOST DEFINITIONS
###############################################################################

define host {
    use             generic-host
    host_name       IT-2
    alias           Jobeez computer
    address         192.168.2.22
    contact_groups  MailContacts
    }

# HOST GROUP DEFINITIONS
###############################################################################

define hostgroup {
        hostgroup_name          Test_group
                alias           Test Group
                members         IT-2
        }


# Checks
###############################################################################
define service {
    use                 generic-service
    hostgroup           Test_group
    service_description Telephony service check
    check_command       check_nrpe2!CheckServiceState -a ShowAll "Telephony"
    contact_groups      MailContacts
    }
My templates.cfg file:

Code: Select all

# CONTACT TEMPLATE
###############################################################################

define contact{
        name                            generic-contact
        service_notification_period     24x7
        host_notification_period        24x7
        service_notification_options    w,u,c,r,f,s
        host_notification_options       d,u,r,f,s
        service_notification_commands   notify-service-by-email
        host_notification_commands      notify-host-by-email
        register                        1
        }

# TEMPLATES
###############################################################################

# Generic service

define service{
        name                            generic-service
        active_checks_enabled           1
        passive_checks_enabled          1
        parallelize_check               1
        obsess_over_service             1
        check_freshness                 0
        notifications_enabled           1
        event_handler_enabled           1
        flap_detection_enabled          1
        failure_prediction_enabled      1
        process_perf_data               1
        retain_status_information       1
        retain_nonstatus_information    1
        is_volatile                     0
        check_period                    24x7
        max_check_attempts              3
        normal_check_interval           10
        retry_check_interval            2
        contact_groups                  MailContacts
        notification_options            w,u,c,r
        notification_interval           60
        notification_period             24x7
        register                        1
        }

define host{
        name                            generic-host
        notifications_enabled           1
        event_handler_enabled           1
        flap_detection_enabled          1
        failure_prediction_enabled      1
        process_perf_data               1
        max_check_attempts              5
        check_command                   check-host-alive
#       check_command                   check_ping
        retain_status_information       1
        retain_nonstatus_information    1
        notification_period             24x7
        register                        1           ; This host registered 3/8/12 to fight errors
        }

# Printers
        define host{
        name                            generic-printer
        use                             generic-host
        check_period                    24x7
        check_interval                  5
        retry_interval                  1
        max_check_attempts              10
        check_command                   check-host-alive
        notification_period             workhours
        notification_interval           30
        notification_options            d,r
        contact_groups                  MailContacts
        register                        1
        }

# Switches
        define host{
        name                            generic-switch
        use                             generic-host
        check_period                    24x7
        check_interval                  5
        retry_interval                  1
        max_check_attempts              10
        check_command                   check-host-alive
        notification_period             24x7
        notification_interval           30
        notification_options            d,r
        contact_groups                  MailContacts
        register                        1
        }

# Linux servers
        define host{
        name                            linux-server
        use                             generic-host
        check_period                    24x7
        check_interval                  5
        retry_interval                  1
        max_check_attempts              10
        check_command                   check-host-alive
        notification_period             workhours
        notification_interval           120
        notification_options            d,u,r
        contact_groups                  MailContacts
        register                        1
        }

# Local service
        define service{
        name                            local-service
        use                             generic-service
        max_check_attempts              4
        normal_check_interval           5
        retry_check_interval            1
        register                        1
        }
And my contacts.cfg file:

Code: Select all

# CONTACTS
###############################################################################

define contact{
    contact_name                    JobeeMail
    use                             generic-contact
    alias                           Nagios Jobee
    email                           [email protected]
    host_notification_options       d,s,u
    service_notification_options    c,s,u
    register                        1
    }

define contact{
    contact_name    admins
    use             generic-contact
    alias           Admin contact
    email           [email protected]
}


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

define contactgroup{
    contactgroup_name       MailContacts
    alias                   Mail Contacts
    members                 JobeeMail
    }

define contactgroup{
    contactgroup_name       admins
    alias                   Admin Contacts
    members                 admins
}

define contactgroup{
    contactgroup_name       PhoneContacts
    alias                   For error removal
    members                 admins
}
Thanks for the help!

Joe B
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: Install won't relay off of my Exchange 2007 server

Post by sreinhardt »

Could you also post the notify-host-by-email definition, just so we have a complete picture. Along the same lines, most times that command will use the local mta and if it is not configured to send externally, the mail may be spooling in the local mail queue\spool.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
jbruyet
Posts: 235
Joined: Wed Dec 28, 2011 12:14 pm

Re: Install won't relay off of my Exchange 2007 server

Post by jbruyet »

Here's my configuration:

Code: Select all

# 'notify-host-by-email' command definition
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/local/bin/sendEmail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
    }
I read in a few places that the sendEmail program was one of the better ones to use.

You know, now that I think about it I don't believe I ever configured the sendEmail program to send emails to my Exchange Server. I'll have to check in to that...

Thanks,

Joe B
jbruyet
Posts: 235
Joined: Wed Dec 28, 2011 12:14 pm

Re: Install won't relay off of my Exchange 2007 server

Post by jbruyet »

Oh, the SMTP server is specified when the email is sent.

Thanks,

Joe B
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Install won't relay off of my Exchange 2007 server

Post by slansing »

That last post was a bit cryptic, did you get this working?
jbruyet
Posts: 235
Joined: Wed Dec 28, 2011 12:14 pm

Re: Install won't relay off of my Exchange 2007 server

Post by jbruyet »

As I understand it the sendEmail program is more of a command line email program for use in scripts so the Exchange server address needs to be added to the script.

I'm still working on this and I'm starting to think I should get rid of the sendEmail program and use the default FreeBSD mail transport agent. Seems like I had this working in a previous install...

Thanks,

Joe B
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Install won't relay off of my Exchange 2007 server

Post by abrist »

jbruyet wrote:I'm still working on this and I'm starting to think I should get rid of the sendEmail program and use the default FreeBSD mail transport agent. Seems like I had this working in a previous install...
I agree. mailx supports sending through an smtp relay, and I am sure other vanilla bsd clients do as well. You just need to hunt down the right syntax for sending to an smtp relay for the client of your choice.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
jbruyet
Posts: 235
Joined: Wed Dec 28, 2011 12:14 pm

Re: Install won't relay off of my Exchange 2007 server

Post by jbruyet »

Ok, I've removed sendEmail from my Nagios server and from what I can find on Google I believe I have my alerting configuration set correctly (I've made a few tweaks because just about everything I've seen is for Linux and FreeBSD does things a little differently). I created a test configuration for a computer and it shows up as a critical state in Nagios but I'm still not getting notifications. I checked my spam filter to see if my notifications were getting blocked but there aren't any notifications there. I'm using the information from these two web sites to configure my notifications:

http://www.thegeekstuff.com/2009/06/4-s ... ification/

http://www.linux.com/learn/tutorials/31 ... ith-nagios

Do either of these two sets of instructions not translate into FreeBSD terminology? Is there a FreeBSD page with instructions on how to configure alerting?

Thanks,

Joe B
Locked