Skip to content

Commit

Permalink
prevent evaluating alarms that do have the data for the evaluation; f…
Browse files Browse the repository at this point in the history
…ixes #1173
  • Loading branch information
ktsaou committed Oct 28, 2016
1 parent 774504d commit d69618b
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions src/health.c
Original file line number Diff line number Diff line change
Expand Up @@ -2564,8 +2564,8 @@ static inline int rrdcalc_isrunnable(RRDCALC *rc, time_t now, time_t *next_run)
return 0;
}

if (unlikely(!rc->rrdset->last_collected_time.tv_sec)) {
debug(D_HEALTH, "Health not running alarm '%s.%s'. Chart is not yet collected.", rc->chart?rc->chart:"NOCHART", rc->name);
if (unlikely(!rc->rrdset->last_collected_time.tv_sec || rc->rrdset->counter_done < 2)) {
debug(D_HEALTH, "Health not running alarm '%s.%s'. Chart is not fully collected yet.", rc->chart?rc->chart:"NOCHART", rc->name);
return 0;
}

Expand All @@ -2574,6 +2574,30 @@ static inline int rrdcalc_isrunnable(RRDCALC *rc, time_t now, time_t *next_run)
return 0;
}

int update_every = rc->rrdset->update_every;
time_t first = rrdset_first_entry_t(rc->rrdset);
time_t last = rrdset_last_entry_t(rc->rrdset);

if(now + update_every < first || now - update_every > last) {
debug(D_HEALTH
, "Health not examining alarm '%s.%s' yet (wanted time is out of bounds - we need %lu but got %lu - %lu)."
, rc->chart ? rc->chart : "NOCHART", rc->name, (unsigned long) now, (unsigned long) first
, (unsigned long) last);
return 0;
}

if (RRDCALC_HAS_DB_LOOKUP(rc)) {
time_t needed = now + rc->before + rc->after;

if(needed + update_every < first || needed - update_every > last) {
debug(D_HEALTH
, "Health not examining alarm '%s.%s' yet (not enough data yet - we need %lu but got %lu - %lu)."
, rc->chart ? rc->chart : "NOCHART", rc->name, (unsigned long) needed, (unsigned long) first
, (unsigned long) last);
return 0;
}
}

if (unlikely(rc->next_update > now)) {
if (unlikely(*next_run > rc->next_update))
*next_run = rc->next_update;
Expand All @@ -2582,12 +2606,6 @@ static inline int rrdcalc_isrunnable(RRDCALC *rc, time_t now, time_t *next_run)
return 0;
}

// FIXME
// we should check that the DB lookup is possible
// i.e.
// - the duration of the chart includes the required timeframe
// we SHOULD NOT check the dimensions - there might be alarms that refer non-existing dimensions (e.g. cpu steal)

return 1;
}

Expand Down

0 comments on commit d69618b

Please sign in to comment.