Notifications on Severity

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
kimpeck
Posts: 3
Joined: Thu May 12, 2011 8:37 am

Notifications on Severity

Post by kimpeck »

Hi,

Firstly I apologize if this has been asked and I haven't managed to find it.

I have a host I am monitoring for disk space and have set the following :-

Warning at 70% and critical at 90%.

I have setup email and sms and they seem to be working fine.

However

is there a way I could email myself (only) when the warning level is reached and email and sms myself when the critical level is reached.

I have a template setup but I seem to be able to call each one or both.

Code: Select all


###############################################################################
###############################################################################
#
# SERVICE TEMPLATES NEW
#
###############################################################################
###############################################################################
#Generic service definition template - This is NOT a real service, just a template!

define service{
        name                            netapp-service-email 	; 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
        is_volatile                     0       		; The service is not volatile
        check_period                    24x7			; The service can be checked at any time of the day
        max_check_attempts              3			; Re-check the service up to 3 times in order to determine its final (hard) state
        normal_check_interval           10			; Check the service every 10 minutes under normal conditions
        retry_check_interval            2			; Re-check the service every two minutes until a hard state can be determined
        contact_groups                  email_admin			; Notifications get sent out to everyone in the 'admins' group
	notification_options		w,u,c,r			; Send notifications about warning, unknown, critical, and recovery events
        notification_interval           720			; Re-notify about service problems every hour
        notification_period             24x7			; Notifications can be sent out at any time
         register                        0       		; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
        }

# Generic service definition template - This is NOT a real service, just a template!

define service{
        name                            netapp-service-sms 	; 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
        is_volatile                     0       		; The service is not volatile
        check_period                    24x7			; The service can be checked at any time of the day
        max_check_attempts              3			; Re-check the service up to 3 times in order to determine its final (hard) state
        normal_check_interval           10			; Check the service every 10 minutes under normal conditions
        retry_check_interval            2			; Re-check the service every two minutes until a hard state can be determined
        contact_groups                  sms_admin			; Notifications get sent out to everyone in the 'admins' group
	notification_options		u,c,r			; Send notifications about warning, unknown, critical, and recovery events
        notification_interval           720			; Re-notify about service problems every hour
        notification_period             24x7			; Notifications can be sent out at any time
         register                        0       		; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
        }


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

# Just one contact defined by default - the Nagios admin (that's you) # This contact definition inherits a lot of default values from the 'generic-contact' 
# template which is defined elsewhere.

define contact{
        contact_name                    nagios_email_admin		; Short name of user
	use				generic-contact		; Inherit default values from generic-contact template (defined above)
        alias                           Nagios Email Admin		; Full name of user

        email                           Me@myemail.com	; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
        }


define contact{
        contact_name                    nagios_sms_admin		; Short name of user
	use				generic-contact-sms		; Inherit default values from generic-contact template (defined above)
        alias                           Nagios SMS Admin		; Full name of user

        email                          me@mysms	; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
        }



###############################################################################
###############################################################################
#
# 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       email_admin
        alias                   Nagios Email Administrators
        members                 nagios_email_admin
        }

define contactgroup{
        contactgroup_name       sms_admin
        alias                   Nagios SMS Administrators
        members                 nagios_sms_admin

###############################################################################
###############################################################################
#
# SYSTEM CHECK SERVICE
###############################################################################
###############################################################################



define service{
	use			netapp-service-sms	; Inherit values from a template
	host_name		NetApp_FAS2240 ; The name of the host the service is associated with
	service_description	Vol Space - WEB IMAGES	
	check_command		check_netapp_vol_cifs_web_images
	}
User avatar
gshergill
Posts: 231
Joined: Tue Aug 07, 2012 5:08 am

Re: Notifications on Severity

Post by gshergill »

Hi kimpeck,

One option would be to create two contacts/contact templates, one for email one for SMS.

Then set the notification_options to either w or c.

This may not be the best solution, but I hope this helps!

Kind Regards,

Gary Shergill
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Notifications on Severity

Post by abrist »

You will want to set service notification options for both of you contacts as suggested by gshergill:
http://nagios.sourceforge.net/docs/3_0/ ... ml#contact
service_notification_options [w,u,c,r,f,s,n]

Code: Select all

define contact{
        contact_name                    nagios_email_admin      ; Short name of user
        use            generic-contact      ; Inherit default values from generic-contact template (defined above)
        alias                           Nagios Email Admin      ; Full name of user
        service_notification_options	w,c,r
        email                           Me@myemail.com   ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
        }


define contact{
        contact_name                    nagios_sms_admin      ; Short name of user
        use            generic-contact-sms      ; Inherit default values from generic-contact template (defined above)
        alias                           Nagios SMS Admin      ; Full name of user
        service_notification_options	c,r
        email                          me@mysms   ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
        }
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.
Locked