Adding contacts and contact groups
-
- Posts: 15
- Joined: Wed Sep 25, 2019 4:05 pm
Adding contacts and contact groups
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 somethingemail@something.com ; <<***** 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 someotheremail@something.com ; <<***** 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 athirdemail@something.com ; <<***** 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
}
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 somethingemail@something.com ; <<***** 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 someotheremail@something.com ; <<***** 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 athirdemail@something.com ; <<***** 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
}
Last edited by madhurima12 on Wed Oct 02, 2019 12:15 pm, edited 1 time in total.
-
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Adding contacts and contact groups
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
-
- Posts: 15
- Joined: Wed Sep 25, 2019 4:05 pm
Re: Adding contacts and contact groups
Verify nagios.cfg?
-
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Adding contacts and contact groups
yesmadhurima12 wrote:Verify nagios.cfg?
-
- Posts: 15
- Joined: Wed Sep 25, 2019 4:05 pm
Re: Adding contacts and contact groups
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.
-
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Adding contacts and contact groups
In the UI does it show the notification being sent under Notifications?
-
- Posts: 15
- Joined: Wed Sep 25, 2019 4:05 pm
Re: Adding contacts and contact groups
Yes it does.
-
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Adding contacts and contact groups
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
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
-
- Posts: 15
- Joined: Wed Sep 25, 2019 4:05 pm
Re: Adding contacts and contact groups
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
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
-
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Adding contacts and contact groups
Ok, let's verify the path to mail
and 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
which mail
Code: Select all
which printf
Such as
Code: Select all
tail -50 /var/log/maillog