@cryptotaxi247 / netdata-1 / commits / d69618bb0

prevent evaluating alarms that do have the data for the evaluation; fixes #1173

Costa Tsaousis (ktsaou) committed Oct 28, 2016 at 21:30 UTC d69618bb0a7958ad868ebfe125b53b456ab996a0
1 file changed +26 -8
src/health.c
+26 -8
@@ -2564,8 +2564,8 @@ static inline int rrdcalc_isrunnable(RRDCALC *rc, time_t now, time_t *next_run)
2564 return 0;
2565 }
2566
2567 - if (unlikely(!rc->rrdset->last_collected_time.tv_sec)) {
2568 - debug(D_HEALTH, "Health not running alarm '%s.%s'. Chart is not yet collected.", rc->chart?rc->chart:"NOCHART", rc->name);
2567 + if (unlikely(!rc->rrdset->last_collected_time.tv_sec || rc->rrdset->counter_done < 2)) {
2568 + debug(D_HEALTH, "Health not running alarm '%s.%s'. Chart is not fully collected yet.", rc->chart?rc->chart:"NOCHART", rc->name);
2569 return 0;
2570 }
2571
@@ -2574,6 +2574,30 @@ static inline int rrdcalc_isrunnable(RRDCALC *rc, time_t now, time_t *next_run)
2574 return 0;
2575 }
2576
2577 + int update_every = rc->rrdset->update_every;
2578 + time_t first = rrdset_first_entry_t(rc->rrdset);
2579 + time_t last = rrdset_last_entry_t(rc->rrdset);
2580 +
2581 + if(now + update_every < first || now - update_every > last) {
2582 + debug(D_HEALTH
2583 + , "Health not examining alarm '%s.%s' yet (wanted time is out of bounds - we need %lu but got %lu - %lu)."
2584 + , rc->chart ? rc->chart : "NOCHART", rc->name, (unsigned long) now, (unsigned long) first
2585 + , (unsigned long) last);
2586 + return 0;
2587 + }
2588 +
2589 + if (RRDCALC_HAS_DB_LOOKUP(rc)) {
2590 + time_t needed = now + rc->before + rc->after;
2591 +
2592 + if(needed + update_every < first || needed - update_every > last) {
2593 + debug(D_HEALTH
2594 + , "Health not examining alarm '%s.%s' yet (not enough data yet - we need %lu but got %lu - %lu)."
2595 + , rc->chart ? rc->chart : "NOCHART", rc->name, (unsigned long) needed, (unsigned long) first
2596 + , (unsigned long) last);
2597 + return 0;
2598 + }
2599 + }
2600 +
2601 if (unlikely(rc->next_update > now)) {
2602 if (unlikely(*next_run > rc->next_update))
2603 *next_run = rc->next_update;
@@ -2582,12 +2606,6 @@ static inline int rrdcalc_isrunnable(RRDCALC *rc, time_t now, time_t *next_run)
2606 return 0;
2607 }
2608
2585 - // FIXME
2586 - // we should check that the DB lookup is possible
2587 - // i.e.
2588 - // - the duration of the chart includes the required timeframe
2589 - // we SHOULD NOT check the dimensions - there might be alarms that refer non-existing dimensions (e.g. cpu steal)
2590 -
2609 return 1;
2610 }
2611