prevent running alarms on charts that have not been collected yet
Costa Tsaousis (ktsaou) committed
Sep 2, 2016 at 23:10 UTC
595340c4b866c042cae4082e7ba7b9272fd36108
1 file changed
+12
-1
src/health.c
+12
-1
@@ -1654,7 +1654,7 @@ void health_alarms2json(RRDHOST *host, BUFFER *wb, int all) {
1654
buffer_strcat(wb, "{\n\t\"alarms\": {\n");
1655
RRDCALC *rc;
1656
for(i = 0, rc = host->alarms; rc ; rc = rc->next) {
1657
- if(unlikely(!rc->rrdset))
1657
+ if(unlikely(!rc->rrdset || !rc->rrdset->last_collected_time.tv_sec))
1658
continue;
1659
1660
if(likely(!all && !(rc->status == RRDCALC_STATUS_WARNING || rc->status == RRDCALC_STATUS_CRITICAL)))
@@ -1916,6 +1916,11 @@ static inline int rrdcalc_isrunnable(RRDCALC *rc, time_t now, time_t *next_run)
1916
return 0;
1917
}
1918
1919
+ if (unlikely(!rc->rrdset->last_collected_time.tv_sec)) {
1920
+ debug(D_HEALTH, "Health not running alarm '%s.%s'. Chart is not yet collected.", rc->chart?rc->chart:"NOCHART", rc->name);
1921
+ return 0;
1922
+ }
1923
+
1924
if (unlikely(!rc->update_every)) {
1925
debug(D_HEALTH, "Health not running alarm '%s.%s'. It does not have an update frequency", rc->chart?rc->chart:"NOCHART", rc->name);
1926
return 0;
@@ -1929,6 +1934,12 @@ static inline int rrdcalc_isrunnable(RRDCALC *rc, time_t now, time_t *next_run)
1934
return 0;
1935
}
1936
1937
+ // FIXME
1938
+ // we should check that the DB lookup is possible
1939
+ // i.e.
1940
+ // - the duration of the chart includes the required timeframe
1941
+ // we SHOULD NOT check the dimensions - there might be alarms that refer non-existing dimensions (e.g. cpu steal)
1942
+
1943
return 1;
1944
}
1945