Page 1 of 1

Nagios 4.0.8 passive checks

Posted: Wed Sep 23, 2015 4:25 am
by sspaise
Hi Everybody,

I have just recently set up a new Nagios system using 4.0.8 with passive service checking only. This is working as expected, passive alerts are being received etc, but I appear to be having a problem with stale results.

I would like to set up the system so that when a check goes stale, a command is run to mark the service with a WARNING state, and the message "no recent passive updates received". Below I have attempted to explain the issue in more detail, and provided all the necessary configuration:

a) After three minutes (for this particular check) the results turn stale due to receiving no passive update:

Code: Select all

[1442935266] Warning: The results of service 'System-Memory' on host 'testunit' are stale by 0d 0h 0m 34s (threshold=0d 0h 3m 20s).  I'm forcing an immediate check of the service.
Nothing happens after this. It is supposed to be passed to a defined command called "no_recent_passive" which uses the check_dummy plugin as shown below:

Code: Select all

# no_recent_passive definition
define command {
        command_name no_recent_passive
        command_line /usr/local/nagios/libexec/check_dummy 1 "There have been no recent passive updates"
}
It would appear that this command is never called. The stale result message is displayed again three minutes later instead of marking the service as a WARNING.

Service definition:

Code: Select all

define service{
        name                            passive-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                 1       ; check service 'freshness'
        freshness_threshold             600     ;  complain if the data recieved is more than 10 mins old.
        check_command                   no_recent_passive   ; Report staleness
        notifications_enabled           1       ; Service notifications are enabled
        event_handler_enabled           1       ; Service event handler is enabled
        flap_detection_enabled          0       ; Flap detection is enabled .... disabled
        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
        notification_interval           0       ; Only send notifications on status change by default.
;       is_volatile                     0
        check_period                    24x7
        check_interval                  0
        retry_check_interval            1
        max_check_attempts              1
        notification_period             24x7
        notification_options            w,u,c,r
        contact_groups                  admins
        register                        0       ; Don't register this template
        }
Enabled in main nagios.conf file:
check_service_freshness=1

Is anyone able to point me in the right direction as to why the "check_command" is not called when a result turns stale?

Many thanks,
Sam

Re: Nagios 4.0.8 passive checks

Posted: Wed Sep 23, 2015 4:51 pm
by lmiltchev
You will need to remove:

Code: Select all

register                        0
if this is a "regular" service definition. The way you have it now, it is a "template".

Re: Nagios 4.0.8 passive checks

Posted: Thu Sep 24, 2015 3:34 am
by sspaise
Hi Imiltchev,

Thanks for your reply. I would actually like to use this as a template for other hosts rather than a regular service definition.

The template in use was pulled from our previous nagios server (which I had no part in setting up), where the register statement is still present in the configuration, and the check_command is working as expected for passive updates.

Is there a way to template this and still use the "check_command"?

Thanks,
Sam

Re: Nagios 4.0.8 passive checks

Posted: Thu Sep 24, 2015 5:09 pm
by ssax
Yes, you can specify the check_command in the template and then if you want to override the check_command for one of them you would just define it locally on that service.

Re: Nagios 4.0.8 passive checks

Posted: Fri Sep 25, 2015 4:20 am
by sspaise
Hi ssax,

The check_command is defined in the template, and I've actually tried defining it on the service also, but it still never gets called.

I have a feeling something else is in play here, because no matter how its configured the check_command is never called on a stale state.

Re: Nagios 4.0.8 passive checks

Posted: Fri Sep 25, 2015 2:23 pm
by scottwilkerson
make sure your nagios.cfg has

Code: Select all

check_service_freshness=1

Re: Nagios 4.0.8 passive checks

Posted: Mon Sep 28, 2015 3:14 am
by sspaise
HI Scott,

I can confirm, as per my original posting that this option is already enabled in the configuration:

[root@invnag nagios]# grep "check_service_freshness" nagios.cfg
check_service_freshness=1

Re: Nagios 4.0.8 passive checks

Posted: Mon Sep 28, 2015 1:41 pm
by tmcdonald
In your nagios.cfg, set debug_level=-1 and restart nagios. Wait long enough for a check to go stale then stop nagios and set debug_level=0 and start back up, then post/PM the nagios.debug file (wherever you have it defined).

Re: Nagios 4.0.8 passive checks

Posted: Tue Oct 06, 2015 6:39 am
by sspaise
Hi All,

Just wanted to say thanks for your input, I've now managed to resolve this.

My NSCA daemon was throwing a wobbly and not processing commands correctly. After a reinstall commands started working as expected for passive checks.

Cheers,
Sam

Re: Nagios 4.0.8 passive checks

Posted: Tue Oct 06, 2015 1:52 pm
by hsmith
Glad to hear this one is working for you now. I'll go ahead and close the thread up and mark it resolved.