diff options
author | Stelios Fragkakis <52996999+stelfrag@users.noreply.github.com> | 2020-08-11 18:16:10 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-11 18:16:10 +0300 |
commit | 53d7d3c3fa69c66a519a0889fb684be08efe71c8 (patch) | |
tree | 89984322c74b7214ab4057f656fb2805ef17fec9 /database | |
parent | 1c846d568d8ad075fbc3444d35f9c93b8aaf028c (diff) |
Fixed issue with missing alarms (#9712)
Fixed the alarm configuration when dimensions switch from archived to active
Diffstat (limited to 'database')
-rw-r--r-- | database/rrddim.c | 48 |
1 files changed, 29 insertions, 19 deletions
diff --git a/database/rrddim.c b/database/rrddim.c index 8be3df04f1..25209dbe24 100644 --- a/database/rrddim.c +++ b/database/rrddim.c @@ -3,6 +3,32 @@ #define NETDATA_RRD_INTERNALS #include "rrd.h" +static inline void calc_link_to_rrddim(RRDDIM *rd) +{ + RRDHOST *host = rd->rrdset->rrdhost; + RRDSET *st = rd->rrdset; + if (host->alarms_with_foreach || host->alarms_template_with_foreach) { + int count = 0; + int hostlocked; + for (count = 0; count < 5; count++) { + hostlocked = netdata_rwlock_trywrlock(&host->rrdhost_rwlock); + if (!hostlocked) { + rrdcalc_link_to_rrddim(rd, st, host); + rrdhost_unlock(host); + break; + } else if (hostlocked != EBUSY) { + error("Cannot lock host to create an alarm for the dimension."); + } + sleep_usec(USEC_PER_MS * 200); + } + + if (count == 5) { + error( + "Failed to create an alarm for dimension %s of chart %s 5 times. Skipping alarm.", rd->name, st->name); + } + } +} + // ---------------------------------------------------------------------------- // RRDDIM index @@ -212,6 +238,7 @@ RRDDIM *rrddim_add_custom(RRDSET *st, const char *id, const char *name, collecte rrddimvar_create(rd, RRDVAR_TYPE_CALCULATED, NULL, NULL, &rd->last_stored_value, RRDVAR_OPTION_DEFAULT); rrddimvar_create(rd, RRDVAR_TYPE_COLLECTED, NULL, "_raw", &rd->last_collected_value, RRDVAR_OPTION_DEFAULT); rrddimvar_create(rd, RRDVAR_TYPE_TIME_T, NULL, "_last_collected_t", &rd->last_collected_time.tv_sec, RRDVAR_OPTION_DEFAULT); + calc_link_to_rrddim(rd); } // DBENGINE available and activated? #ifdef ENABLE_DBENGINE @@ -425,26 +452,9 @@ RRDDIM *rrddim_add_custom(RRDSET *st, const char *id, const char *name, collecte if(unlikely(rrddim_index_add(st, rd) != rd)) error("RRDDIM: INTERNAL ERROR: attempt to index duplicate dimension '%s' on chart '%s'", rd->id, st->id); - if (host->alarms_with_foreach || host->alarms_template_with_foreach) { - int count = 0; - int hostlocked; - for (count = 0 ; count < 5 ; count++) { - hostlocked = netdata_rwlock_trywrlock(&host->rrdhost_rwlock); - if (!hostlocked) { - rrdcalc_link_to_rrddim(rd, st, host); - rrdhost_unlock(host); - break; - } else if (hostlocked != EBUSY) { - error("Cannot lock host to create an alarm for the dimension."); - } - usleep(200000); - } + if (!is_archived) + calc_link_to_rrddim(rd); - if (count == 5) { - error("Failed to create an alarm for dimension %s of chart %s 5 times. Skipping alarm." - , rd->name, st->name); - } - } rrdset_unlock(st); #ifdef ENABLE_ACLK if (netdata_cloud_setting) |