contacts.cfg is not working properly

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.
sinkak
Posts: 158
Joined: Thu Jul 30, 2015 1:30 pm

Re: contacts.cfg is not working properly

Post by sinkak »

Code: Select all

define contactgroup {
        contactgroup_name       DevNull
        alias   DevNull
        members wsawarn
        }
define contactgroup {
        contactgroup_name       Dustin-admins
        alias   Dustin
        members wsawarn
        }
define contactgroup {
        contactgroup_name       SmsOnlyOnce
        alias   SmsOnlyOnce
        members wsawarn
        }
define contactgroup {
        contactgroup_name       admins
        alias   Nagios Administrators
        members wsacritical,wsawarn
        }
define contactgroup {
        contactgroup_name       sms-admins
        alias   SMS
        members wsawarn
        }
define contact {
        contact_name    wsacritical
        alias   WSACRITICAL
        service_notification_period     24x7
        host_notification_period        24x7
        service_notification_options    c
        host_notification_options       d
        service_notification_commands   notify-service-by-sms-only-once,notify-service-by-email
        host_notification_commands      notify-host-by-sms-only-once,notify-host-by-email
        email   [email protected]
        minimum_importance      0
        host_notifications_enabled      1
        service_notifications_enabled   1
        can_submit_commands     1
        retain_status_information       1
        retain_nonstatus_information    1
        }
define contact {
        contact_name    wsawarn
        alias   WSAWarn
        service_notification_period     24x7
        host_notification_period        24x7
        service_notification_options    r,w,u
        host_notification_options       r,u
        service_notification_commands   notify-service-by-email
        host_notification_commands      notify-host-by-email
        email   [email protected]
        minimum_importance      0
        host_notifications_enabled      1
        service_notifications_enabled   1
        can_submit_commands     1
        retain_status_information       1
        retain_nonstatus_information    1
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: contacts.cfg is not working properly

Post by hsmith »

Can we take a look at your templates for generic-service,srv-pnp and any more upstream templates you may have?
Former Nagios Employee.
me.
sinkak
Posts: 158
Joined: Thu Jul 30, 2015 1:30 pm

Re: contacts.cfg is not working properly

Post by sinkak »

Code: Select all

define service{
        name                            generic-service ; The 'name' of this service template
        active_checks_enabled           1       ; Active service checks are enabled
        passive_checks_enabled          1       ; Passive service checks are enabled/accepted
        parallelize_check               1       ; Active service checks should be parallelized (disabling this can lead to major performance problems)
        obsess_over_service             1       ; We should obsess over this service (if necessary)
        check_freshness                 0       ; Default is to NOT check service 'freshness'
        notifications_enabled           1       ; Service notifications are enabled
        event_handler_enabled           1       ; Service event handler is enabled
        flap_detection_enabled          1       ; Flap detection is enabled
        failure_prediction_enabled      1       ; Failure prediction is enabled
        process_perf_data               1       ; Process performance data
        retain_status_information       1       ; Retain status information across program restarts
        retain_nonstatus_information    1       ; Retain non-status information across program restarts
                notification_interval           0               ; Only send notifications on status change by default.
                is_volatile                     0
                check_period                    24x7
                normal_check_interval           5
                retry_check_interval            1
                max_check_attempts              4
                notification_period             24x7
                notification_options            w,u,c,r
                contact_groups                  admins
        register                        0       ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
        }

Code: Select all

define service{
        name                    srv-pnp
        action_url              /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$' class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=$SERVIC
EDESC$
        register                0
        }

Code: Select all

define host{
        name                            generic-host    ; The name of this host template
        notifications_enabled           1       ; Host notifications are enabled
        event_handler_enabled           1       ; Host event handler is enabled
        flap_detection_enabled          1       ; Flap detection is enabled
        failure_prediction_enabled      1       ; Failure prediction is enabled
        process_perf_data               1       ; Process performance data
        retain_status_information       1       ; Retain status information across program restarts
        retain_nonstatus_information    1       ; Retain non-status information across program restarts
                check_command                   check-host-alive
                max_check_attempts              10
                notification_interval           0
                notification_period             24x7
                notification_options            d,u,r
                contact_groups                  admins,SmsOnlyOnce
        register                        0       ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
        }

define host {
        name                    host-pnp
        action_url              /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_' class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=_HOST_
        register                0
        }

User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: contacts.cfg is not working properly

Post by hsmith »

Everything appears to be in order in your configuration files. Time to dive a little bit deeper. Can you su to the nagios user, and try to manually submit an email to the address in question?

For example:

Code: Select all

/usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: test\n\nService: test\nHost: test\nAddress: test\nState: test\n\nDate/Time: test\n\nAdditional Info:\n\test\n" | /bin/mail -s "** test Service Alert: test/test is test **" "[email protected]" 
Former Nagios Employee.
me.
sinkak
Posts: 158
Joined: Thu Jul 30, 2015 1:30 pm

Re: contacts.cfg is not working properly

Post by sinkak »

during initial setup

Code: Select all

 sudo useradd nagios
    sudo groupadd nagcmd
    sudo usermod -a -G nagcmd nagios
i never gave password for nagios

now after

Code: Select all

ubuntu@nagios-2015:~$ su nagios
Password:
su: Authentication failure
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: contacts.cfg is not working properly

Post by hsmith »

Can you su to nagios using root?
Former Nagios Employee.
me.
sinkak
Posts: 158
Joined: Thu Jul 30, 2015 1:30 pm

Re: contacts.cfg is not working properly

Post by sinkak »

ubuntu@nagios-2015:~$ sudo su nagios
ubuntu@nagios-2015:~$ whoami
ubuntu
ubuntu@nagios-2015:~$
sinkak
Posts: 158
Joined: Thu Jul 30, 2015 1:30 pm

Re: contacts.cfg is not working properly

Post by sinkak »

I did this with out user nagios

Code: Select all

ubuntu@nagios-2015:/usr/local/nagios/etc$ /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: test\n\nService: test\nHost: test\nAddress: test\nState: test\n\nDate/Time: test\n\nAdditional Info:\n\test\n" | /usr/bin/mail -s "** test Service Alert: test/test is test **" "[email protected]"
ubuntu@nagios-2015:/usr/local/nagios/etc$

Code: Select all

ubuntu@nagios-2015:/usr/local/nagios/etc$ /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: test\n\nService: test\nHost: test\nAddress: test\nState: test\n\nDate/Time: test\n\nAdditional Info:\n\test\n" | /usr/bin/mail -s "** test Service Alert: test/test is test **" "[email protected]"
none of them worked.
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: contacts.cfg is not working properly

Post by hsmith »

Silly question, but are you checking your spam box? The method that mail uses to send emails is often marked as spam.
Former Nagios Employee.
me.
sinkak
Posts: 158
Joined: Thu Jul 30, 2015 1:30 pm

Re: contacts.cfg is not working properly

Post by sinkak »

No nothing on spam either.
Locked