Service http checks

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
anobles
Posts: 3
Joined: Fri Nov 20, 2020 3:13 pm

Service http checks

Post by anobles »

Hey. I'm trying to setup notifications for the http service checks. They seem to work when i select send custom service notifications. They check http also works for Host and are sending notifications going that route. I noticed my https service checks only show they have completed 1 attempt until I restart nagios. I'm guessing this is the reason the notifications are not getting sent but I don't know the cause of it. As far as the logs they do not show anything after the first check has been submitted.
Server Object

Code: Select all

define host {
        use                     	host
        host_name			Test3
        address                 	<serveraddress> 
	hostgroups			Server
}

define service {
	use 			Server_HTTP
	host_name		Test3
}

Service.cfg

Code: Select all

define service{
        name                   Server_HTTP
        use			generic-service
	servicegroups        	Managed_Servers
        max_check_attempts      2
        check_interval          5
        retry_interval          2
        check_command           check_http
        notification_period     24x7
        notification_interval   0
        service_description	 HTTP
        contact_groups          admins
        register                0 
}
template

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
    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
    check_interval                  6                      ; Check the service every 6 minutes under normal conditions
    retry_interval                  2                       ; Re-check the service every two minutes until a hard state can be determined
    contact_groups                  admins                 ; 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           0                      ; Re-notify about service problems
    notification_period             24x7                    ; Notifications can be sent out at any time
    register                        0                       ; DON'T REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
}
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: Service http checks

Post by benjaminsmith »

Hi @anobles,

The nagios log will only show state changes, it's not going to log every single check. You can test this by watching the nagios log and sending passive check results.

Code: Select all

tail -f /usr/local/nagios/var/nagios.log
Make sure to check the contact group for the service (admins) for the right settings (notification handlers, notification options, time periods..etc). I would compare this against the host for differences.

By the way, searching through the objects.cache file is really helpful to view the entire object results once the various templates have been added.

Code: Select all

/usr/local/nagios/var/objects.cache
By the way, the following guide is very helpful for troubleshooting notifications (even though this is written for Nagios XI).

Nagios XI - Notification Problems

Cheers,
Benjamin
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
anobles
Posts: 3
Joined: Fri Nov 20, 2020 3:13 pm

Re: Service http checks

Post by anobles »

Hey Benjamin

when I was watching the logs using tail command, I could see the task get logged. On the first go around the check is logged then a few seconds later the results appear. After the first check, the result of the checks will no longer appear and the attempt counter never goes past 1

objects.cache

Code: Select all


define contactgroup {
	contactgroup_name	admins
	alias	Nagios Administrators
	members	me
	}

define contact {
	contact_name	me
	alias	me
	service_notification_period	24x7
	host_notification_period	24x7
	service_notification_options	r,w,u,c,f,s
	host_notification_options	r,d,u,f,s
	service_notification_commands	notify-service-by-email
	host_notification_commands	notify-support-by-email
	email	adamn@controlbynet.com
	minimum_importance	0
	host_notifications_enabled	1
	service_notifications_enabled	1
	can_submit_commands	1
	retain_status_information	1
	retain_nonstatus_information	1
	}

define service {
	host_name	Test10
	service_description	HTTP
	check_period	24x7
	check_command	check_http
	contact_groups	admins
	notification_period	24x7
	initial_state	o
	importance	0
	check_interval	5.000000
	retry_interval	2.000000
	max_check_attempts	2
	is_volatile	0
	parallelize_check	1
	active_checks_enabled	1
	passive_checks_enabled	1
	obsess	1
	event_handler_enabled	1
	low_flap_threshold	0.000000
	high_flap_threshold	0.000000
	flap_detection_enabled	1
	flap_detection_options	a
	freshness_threshold	0
	check_freshness	0
	notification_options	r,w,u,c
	notifications_enabled	1
	notification_interval	0.000000
	first_notification_delay	0.000000
	stalking_options	n
	process_perf_data	1
	retain_status_information	1
	retain_nonstatus_information	1
	}

define service {
	host_name	Test10
	service_description	ping
	check_period	24x7
	check_command	check_ping!100,20%!500,60%
	contact_groups	admins
	notification_period	24x7
	initial_state	o
	importance	0
	check_interval	6.000000
	retry_interval	2.000000
	max_check_attempts	3
	is_volatile	0
	parallelize_check	1
	active_checks_enabled	1
	passive_checks_enabled	1
	obsess	1
	event_handler_enabled	1
	low_flap_threshold	0.000000
	high_flap_threshold	0.000000
	flap_detection_enabled	1
	flap_detection_options	a
	freshness_threshold	0
	check_freshness	0
	notification_options	r,w,u,c
	notifications_enabled	1
	notification_interval	0.000000
	first_notification_delay	0.000000
	stalking_options	n
	process_perf_data	1
	retain_status_information	1
	retain_nonstatus_information	1
	}


This is one of the only two that send a notification. The other services stay frozen at the first attempt

Code: Select all

define service {
	host_name	Other_Server
	service_description	Ping
	check_period	24x7
	check_command	check_ping!100.0,20%!500.0,60%
	contact_groups	admins
	notification_period	24x7
	initial_state	o
	importance	0
	check_interval	6.000000
	retry_interval	2.000000
	max_check_attempts	3
	is_volatile	0
	parallelize_check	1
	active_checks_enabled	1
	passive_checks_enabled	1
	obsess	1
	event_handler_enabled	1
	low_flap_threshold	0.000000
	high_flap_threshold	0.000000
	flap_detection_enabled	1
	flap_detection_options	a
	freshness_threshold	0
	check_freshness	0
	notification_options	r,w,u,c
	notifications_enabled	1
	notification_interval	0.000000
	first_notification_delay	0.000000
	stalking_options	n
	process_perf_data	1
	retain_status_information	1
	retain_nonstatus_information	1
	}
Here is one of the host configs.

Code: Select all

define host {
	host_name	another_Server
	alias	Server
	address	another_Server
	check_command	check_http
	contact_groups	admins
	notification_period	24x7
	initial_state	o
	importance	0
	check_interval	5.000000
	retry_interval	2.000000
	max_check_attempts	2
	active_checks_enabled	1
	passive_checks_enabled	1
	obsess	1
	event_handler_enabled	1
	low_flap_threshold	0.000000
	high_flap_threshold	0.000000
	flap_detection_enabled	1
	flap_detection_options	a
	freshness_threshold	0
	check_freshness	0
	notification_options	a
	notifications_enabled	1
	notification_interval	0.000000
	first_notification_delay	0.000000
	stalking_options	n
	process_perf_data	1
	retain_status_information	1
	retain_nonstatus_information	1
	}

I compared the ping from "other server" with the services from test10 and don't see any difference. The send custom notification option still goes through for each service. I have the contact definition using the generic so all the options are checked. The time periods are set to 24x7 and the event handler is enabled. I was thinking it was probably a global setting but if that was the case the one ping from "other server" would not work like the rest.
anobles
Posts: 3
Joined: Fri Nov 20, 2020 3:13 pm

Re: Service http checks

Post by anobles »

Sorry, I forgot to mention that I'm using Nagios core.
Locked