How to enable notification?

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.
Locked
tezarin
Posts: 32
Joined: Tue Apr 07, 2015 8:03 am

How to enable notification?

Post by tezarin »

Hi all,

Edit - I just edited my first post and fixed all of the other errors, the ones remaining are below. BAsically I would like to enable notifications in Nagios:

I just installed Nagios and after modifying the config files I am getting an error:

Code: Select all

Error: Contact 'nagiosadmin' has no service notification commands defined!
Error: Contact 'nagiosadmin' has no host notification commands defined!
Any info would be much appreciated
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: How to enable notification?

Post by dwhitfield »

Below is a contact with all of the possible directives. Notice host_notification_commands and service_notification_commands. It would appear you don't have those.

Code: Select all

define contact{
	contact_name	contact_name
	alias	alias
	contactgroups	contactgroup_names
	minimum_value	#
	host_notifications_enabled	[0/1]
	service_notifications_enabled	[0/1]
	host_notification_period	timeperiod_name
	service_notification_period	timeperiod_name
	host_notification_options	[d,u,r,f,s,n]
	service_notification_options	[w,u,c,r,f,s,n]
	host_notification_commands	command_name
	service_notification_commands	command_name
	email	email_address
	pager	pager_number or pager_email_gateway
	addressx	additional_contact_address
	can_submit_commands	[0/1]
	retain_status_information	[0/1]
	retain_nonstatus_information	[0/1]
   	}
Take a look at https://assets.nagios.com/downloads/nag ... ml#command and you'll see how to define commands.

Do you have a commands.cfg? If so, can you attach it? If you aren't sure you can check with find / -name commands.cfg
tezarin
Posts: 32
Joined: Tue Apr 07, 2015 8:03 am

Re: How to enable notification?

Post by tezarin »

dwhitfield wrote:Below is a contact with all of the possible directives. Notice host_notification_commands and service_notification_commands. It would appear you don't have those.

Code: Select all

define contact{
	contact_name	contact_name
	alias	alias
	contactgroups	contactgroup_names
	minimum_value	#
	host_notifications_enabled	[0/1]
	service_notifications_enabled	[0/1]
	host_notification_period	timeperiod_name
	service_notification_period	timeperiod_name
	host_notification_options	[d,u,r,f,s,n]
	service_notification_options	[w,u,c,r,f,s,n]
	host_notification_commands	command_name
	service_notification_commands	command_name
	email	email_address
	pager	pager_number or pager_email_gateway
	addressx	additional_contact_address
	can_submit_commands	[0/1]
	retain_status_information	[0/1]
	retain_nonstatus_information	[0/1]
   	}
Take a look at https://assets.nagios.com/downloads/nag ... ml#command and you'll see how to define commands.

Do you have a commands.cfg? If so, can you attach it? If you aren't sure you can check with find / -name commands.cfg
Thanks for your reply. I have the commands.cfg:

Code: Select all

define command {
    command_name    check_memory
    command_line    $NAGIOSPLUGINSDIR$/check_memory -w 90 -c 95
}

define command {
    command_name    check_disk
    command_line    $NAGIOSPLUGINSDIR$/check_disk --warning 10% --critical 5% /
}
define command {
    command_name    local_memory_usage
    command_line    $NAGIOSPLUGINSDIR$/check_memory -w 90 -c 95
}
define command {
    command_name    local_check_disk_root
    command_line    $NAGIOSPLUGINSDIR$/check_disk --warning 30% --critical 15% /
}

define command {
    command_name    local_check_disk_inode_root
    command_line    $NAGIOSPLUGINSDIR$/check_disk --iwarning 30% --icritical 15% /
}

define command{
        command_name    check_ping
        command_line    $USER1$/check_ping -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ -p 5
        }

# 'check-host-alive' command definition
define command{
        command_name    check-host-alive
        command_line    $USER1$/check_ping -H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -p 5
        }

# 'notify-host-by-email' command definition
define command{
        command_name    host-notify-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" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host AA
lert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
        }

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

And I just modified my contacts so it reads:

Code: Select all

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 scc
heduled downtime events
        host_notification_options       d,u,r,f,s               ; send notifications for all host states, flapping events, and schedd
uled 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 TEMM
PLATE!
        }


define contact{
        contact_name                    nagiosadmin             ; Short name of user
        alias                           Nagios Admin            ; Full name of user
        service_notification_period                   24x7
        host_notification_period                      24x7
        service_notification_options                 c,r
        host_notification_options                    d,r
        service_notification_commands            host-notify-by-email
        host_notification_commands               host-notify-by-email
        email                           tezarin@gmail.com
        }


###############################################################################
###############################################################################
#
# 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
        }
Does it look good? How can I test to see if it works?

Thanks
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: How to enable notification?

Post by dwhitfield »

tezarin wrote:
Does it look good?


Not really. You are using the same command for hosts and services. This could work, but it's not really the way it's supposed to work.
How can I test to see if it works?
Make a service go critical or a host go down, based on your current config (and assuming everything is up and ok now)
Locked