Skip to content
This repository has been archived by the owner on Jan 15, 2019. It is now read-only.

[dev.icinga.com #1331] freshness_threshold problem in host checks by using check_interval in HARD or OK state, else retry_interval (like service checks) #592

Closed
icinga-migration opened this issue Mar 22, 2011 · 5 comments

Comments

@icinga-migration
Copy link

This issue has been migrated from Redmine: https://dev.icinga.com/issues/1331

Created by mfriedrich on 2011-03-22 22:18:18 +00:00

Assignee: mfriedrich
Status: Resolved (closed on 2011-06-15 16:57:49 +00:00)
Target Version: 1.5
Last Update: 2011-06-15 16:57:49 +00:00 (in Redmine)


We realised that the freshness_threshold does not use the retry_interval in host checks, when freshness_threshold=0 and our colletor goes down. It always uses the check_interval. So, one host can take a long time to have your state change to HARD.

On the other hand, the service checks works as expected, because it uses the retry_interval, when the state type = HARD or current state = OK, and it uses check_interval on other cases.

We can see this clearly when we look inside the base/checks.c source code:

[...]
/* tests whether or not a service's check results are fresh */
int is_service_result_fresh(service *temp_service, time_t current_time,
int log_this){
[...]
  /* use user-supplied freshness threshold or auto-calculate a
freshness threshold to use? */
  if(temp_service->freshness_threshold==0){
     if(temp_service->state_type==HARD_STATE || temp_service->current_state==STATE_OK)

freshness_threshold=(temp_service->check_interval*interval_length)+temp_service->latency+additional_freshness_latency;
     else

freshness_threshold=(temp_service->retry_interval*interval_length)+temp_service->latency+additional_freshness_latency;
     }
  else
     freshness_threshold=temp_service->freshness_threshold;
[...]
/* checks to see if a hosts's check results are fresh */
int is_host_result_fresh(host *temp_host, time_t current_time, int
log_this){
[...]
  /* use user-supplied freshness threshold or auto-calculate a
freshness threshold to use? */
  if(temp_host->freshness_threshold==0)

freshness_threshold=(temp_host->check_interval*interval_length)+temp_host->latency+additional_freshness_latency;
  else
     freshness_threshold=temp_host->freshness_threshold;
[...]

I change the lines in the checks.c as below:

========================================================
FROM: Lines 2439 - 2440


 if(temp_host->freshness_threshold==0)
                freshness_threshold=(temp_host->check_interval*interval_length)+temp_host->latency+additional_freshness_latency;

TO:

        if(temp_host->freshness_threshold==0){
                if(temp_host->state_type==HARD_STATE || temp_host->current_state==STATE_OK)

                        freshness_threshold=(temp_host->check_interval*interval_length)+temp_host->latency+additional_freshness_latency;
                else
                        freshness_threshold=(temp_host->retry_interval*interval_length)+temp_host->latency+additional_freshness_latency;
                }
========================================================

It is working well, as expected. My retry interval is 1 minute and hosts are taking about 2 minutes to change SOFT states.

I´m sending attached the diff file between the original checks.c file and the modified checks.c file. 

http://tracker.nagios.org/view.php?id=184

Attachments

Changesets

2011-06-15 16:00:56 +00:00 by mfriedrich 33ab149

core: fix freshness_threshold problem in host checks by using check_interval in HARD or OK state, else retry_interval (like service checks) #1331

fixes #1331

2011-06-20 17:06:48 +00:00 by mfriedrich 0e4605c

core: fix freshness_threshold problem in host checks by using check_interval in HARD or OK state, else retry_interval (like service checks) #1331

fixes #1331
@icinga-migration
Copy link
Author

Updated by mfriedrich on 2011-05-05 16:47:18 +00:00

  • Status changed from New to Feedback
  • Priority changed from Normal to Low

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2011-05-11 11:41:00 +00:00

  • Target Version set to 1.5

    From 29232a3950bb84a3ca3fab653a07386aab3a22f7 Mon Sep 17 00:00:00 2001
    From: Andreas Ericsson
    Date: Tue, 10 May 2011 14:48:49 +0000
    Subject: [PATCH] Use retry_interval for host freshness (re)checking

    Previously the normal check_interval was used regardless of the
    state of the host. This contradicted the documented behaviour
    and the behaviour of services, so fix hosts to work as people
    expect them to.

    This fixes issue [dev.icinga.com #395] Janitor patch: Remove unused variables #184, which suggests a slightly different patch.

    Reported-by: Rodney Ramos
    Original-patch-by: Rodney Ramos
    Signed-off-by: Andreas Ericsson

    base/checks.c | 12 ++++++++++--
    1 files changed, 10 insertions(+), 2 deletions(-)

    diff --git a/base/checks.c b/base/checks.c
    index b0fc968..049c8b6 100644
    --- a/base/checks.c
    +++ b/base/checks.c
    @@ -2440,8 +2440,16 @@ int is_host_result_fresh(host *temp_host, time_t current_time, int log_this){
    log_debug_info(DEBUGL_CHECKS,2,"Checking freshness of host '%s'...\n",temp_host->name);

      /* use user-supplied freshness threshold or auto-calculate a freshness threshold to use? */
    
    • if(temp_host->freshness_threshold==0)
    •   freshness_threshold=(temp_host->check_interval*interval_length)+temp_host->latency+additional_freshness_latency;
      
    • if(temp_host->freshness_threshold==0) {
    •   double interval;
      
    •   if(temp_host->state_type==HARD_STATE || temp_host->current_state==STATE_OK) {
      
    •       interval=temp_host->check_interval;
      
    •   } else {
      
    •       interval=temp_host->retry_interval;
      
    •   }
      
    •   freshness_threshold=(interval*interval_length)+temp_host->latency+additional_freshness_latency;
      
    • }
      else
      freshness_threshold=temp_host->freshness_threshold;

    --
    1.7.2.2

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2011-05-23 16:16:18 +00:00

  • Category set to Other
  • Status changed from Feedback to Assigned
  • Assigned to set to mfriedrich

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2011-06-15 16:00:43 +00:00

  • Subject changed from _freshness_threshold problem in host checks _ to freshness_threshold problem in host checks by using check_interval in HARD or OK state, else retry_interval (like service checks)

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2011-06-15 16:57:49 +00:00

  • Status changed from Assigned to Resolved
  • Done % changed from 0 to 100

Applied in changeset 33ab149.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant