Page 1 of 3

Adding contacts and contact groups

Posted: Wed Oct 02, 2019 12:12 pm
by madhurima12
I am trying to set up one contact group with 3 contacts in that group. As soon as I changed my contacts.cfg file to add the contacts and restarted nagios, it stopped running. Could you please help out on this? My contacts.cfg file looks something like this :
define contact {

contact_name nagiosadmin1 ; Short name of user
use generic-contact ; Inherit default values from generic-contact template (defined above)
alias Nagios Admin 1 ; Full name of user
email [email protected] ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
}

define contact {

contact_name nagiosadmin2 ; Short name of user
use generic-contact ; Inherit default values from generic-contact template (defined above)
alias Nagios Admin 2 ; Full name of user
email [email protected] ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
}

define contact {

contact_name nagiosadmin3 ; Short name of user
use generic-contact ; Inherit default values from generic-contact template (defined above)
alias Nagios Admin 3 ; Full name of user
email [email protected] ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
}


define contactgroup {

contactgroup_name admins
alias Nagios Administrators
members nagiosadmin1, nagiosadmin2, nagiosadmin3
}

And my host definition looks like this :
define host {

use linux-server
host_name lsbx.icbc.net
alias lsbx
address 10.132.7.200
contact_groups admins
}

And one of my service definitions is :
define service{

use generic-service
host_name lsbx.icbc.net
service_description HTTP
contact_groups admins
check_command check_http
}

Re: Adding contacts and contact groups

Posted: Wed Oct 02, 2019 12:15 pm
by scottwilkerson
After you made the configuration change did you verify the config and check for errors (always recommended)?

Code: Select all

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Re: Adding contacts and contact groups

Posted: Thu Oct 03, 2019 1:13 pm
by madhurima12
Verify nagios.cfg?

Re: Adding contacts and contact groups

Posted: Thu Oct 03, 2019 1:23 pm
by scottwilkerson
madhurima12 wrote:Verify nagios.cfg?
yes

Re: Adding contacts and contact groups

Posted: Thu Oct 03, 2019 5:40 pm
by madhurima12
Yes I did. There are no errors. Everything is set up. The object.cache file also says that the contact_groups is admins, as defined. I don't understand why there is no response. Nagios is working, the servers are down, but I receive no email.

Re: Adding contacts and contact groups

Posted: Fri Oct 04, 2019 6:26 am
by scottwilkerson
In the UI does it show the notification being sent under Notifications?

Re: Adding contacts and contact groups

Posted: Fri Oct 04, 2019 11:45 am
by madhurima12
Yes it does.

Re: Adding contacts and contact groups

Posted: Fri Oct 04, 2019 11:55 am
by scottwilkerson
Ok so the contacts are using a generic-contact template

Lets look in the template, and see what the notification handlers are called

Then look for those command definitions and post them here

also, include what operating system and version you are running your Nagios server on

Re: Adding contacts and contact groups

Posted: Fri Oct 04, 2019 12:18 pm
by madhurima12
The template for generic-contact:

define contact{
name generic-contact ; The name of this contact template
service_notification_period 24x7 ; service notifications can be sent anytime
host_notification_period 24x7 ; host notifications can be sent anytime
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 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL CONTACT, JUST A TEMPLATE!
}

Commands:

# '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/bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
}

# 'notify-service-by-email' command definition
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$\n" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}

Operting system info:
NAME="RancherOS"
VERSION=v1.5.4

Re: Adding contacts and contact groups

Posted: Fri Oct 04, 2019 12:37 pm
by scottwilkerson
Ok, let's verify the path to mail

Code: Select all

which mail
and printf

Code: Select all

which printf
I'm not familiar with RancherOS, do you know the location of the mail log for the MTA installed? Can you tail that log to see if there are any results?

Such as

Code: Select all

tail -50 /var/log/maillog