fix re-setting green/red threshold when reloading health configuration
Costa Tsaousis committed
Aug 21, 2016 at 00:05 UTC
9537ff77a56ae275867290e1d4d9af996da7299c
2 files changed
+18
-10
src/health.c
+16
-8
@@ -416,7 +416,7 @@ void rrddimvar_free(RRDDIMVAR *rs) {
416
// RRDCALC management
417
418
static void rrdsetcalc_link(RRDSET *st, RRDCALC *rc) {
419
- debug(D_HEALTH, "Health linking alarm '%s.%s' from chart '%s' of host '%s'", rc->chart?rc->chart:"NOCHART", rc->name, st->id, st->rrdhost->hostname);
419
+ debug(D_HEALTH, "Health linking alarm '%s.%s' to chart '%s' of host '%s'", rc->chart?rc->chart:"NOCHART", rc->name, st->id, st->rrdhost->hostname);
420
421
rc->rrdset = st;
422
@@ -425,11 +425,15 @@ static void rrdsetcalc_link(RRDSET *st, RRDCALC *rc) {
425
rc->update_every = rc->rrdset->update_every;
426
}
427
428
- if(rc->green && !st->green)
428
+ if(!isnan(rc->green) && isnan(st->green)) {
429
+ debug(D_HEALTH, "Health alarm '%s.%s' green threshold set from %Lf to %Lf.", rc->rrdset->id, rc->name, rc->rrdset->green, rc->green);
430
st->green = rc->green;
431
+ }
432
431
- if(rc->red && !st->red)
433
+ if(!isnan(rc->red) && isnan(st->red)) {
434
+ debug(D_HEALTH, "Health alarm '%s.%s' red threshold set from %Lf to %Lf.", rc->rrdset->id, rc->name, rc->rrdset->red, rc->red);
435
st->red = rc->red;
436
+ }
437
438
rc->local = rrdvar_create_and_index("local", &st->variables_root_index, rc->name, RRDVAR_TYPE_CALCULATED, &rc->value);
439
rc->family = rrdvar_create_and_index("family", &st->rrdfamily->variables_root_index, rc->name, RRDVAR_TYPE_CALCULATED, &rc->value);
@@ -581,6 +585,8 @@ static inline RRDCALC *rrdcalc_create(RRDHOST *host, const char *name, const cha
585
586
if(dimensions) rc->dimensions = strdupz(dimensions);
587
588
+ rc->green = green;
589
+ rc->red = red;
590
rc->value = NAN;
591
rc->old_value = NAN;
592
@@ -590,9 +596,6 @@ static inline RRDCALC *rrdcalc_create(RRDHOST *host, const char *name, const cha
596
rc->update_every = update_every;
597
rc->options = options;
598
593
- rc->green = green;
594
- rc->red = red;
595
-
599
if(exec) rc->exec = strdupz(exec);
600
if(source) rc->source = strdupz(source);
601
@@ -1080,6 +1083,8 @@ int health_readfile(const char *path, const char *filename) {
1083
rc->name = strdupz(value);
1084
rc->hash = simple_hash(rc->name);
1085
rc->source = health_source_file(line, path, filename);
1086
+ rc->green = NAN;
1087
+ rc->red = NAN;
1088
rc->value = NAN;
1089
rc->old_value = NAN;
1090
@@ -1100,6 +1105,8 @@ int health_readfile(const char *path, const char *filename) {
1105
rt->name = strdupz(value);
1106
rt->hash_name = simple_hash(rt->name);
1107
rt->source = health_source_file(line, path, filename);
1108
+ rt->green = NAN;
1109
+ rt->red = NAN;
1110
1111
if(rrdvar_fix_name(rt->name))
1112
error("Health configuration renamed template '%s' to '%s'", value, rt->name);
@@ -1386,10 +1393,11 @@ void health_reload(void) {
1393
for(st = localhost.rrdset_root; st ; st = st->next) {
1394
rrdhost_rwlock(&localhost);
1395
1396
+ st->green = NAN;
1397
+ st->red = NAN;
1398
+
1399
rrdsetcalc_link_matching(st);
1400
rrdcalctemplate_link_matching(st);
1391
- st->green = 0;
1392
- st->red = 0;
1401
1402
rrdhost_unlock(&localhost);
1403
}
src/rrd.c
+2
-2
@@ -522,8 +522,8 @@ RRDSET *rrdset_create(const char *type, const char *id, const char *name, const
522
st->isdetail = 0;
523
st->debug = 0;
524
525
- st->green = 0;
526
- st->red = 0;
525
+ st->green = NAN;
526
+ st->red = NAN;
527
528
st->last_collected_time.tv_sec = 0;
529
st->last_collected_time.tv_usec = 0;