diff options
author | Costa Tsaousis (ktsaou) <costa@tsaousis.gr> | 2017-09-07 11:14:32 +0300 |
---|---|---|
committer | Costa Tsaousis (ktsaou) <costa@tsaousis.gr> | 2017-09-07 11:14:32 +0300 |
commit | 63d4a426222af592d5b61dd4c8d03757b4ec048f (patch) | |
tree | 2a7920dc30ad989b9122884b1bf9427b34f2c68a | |
parent | 57cfddf678e526597da96042df710fd76a66bc8d (diff) |
each host gets its own range of alarm and alarm log IDs; fixes #2694
-rw-r--r-- | src/health_log.c | 22 | ||||
-rw-r--r-- | src/rrd.h | 2 |
2 files changed, 12 insertions, 12 deletions
diff --git a/src/health_log.c b/src/health_log.c index 95abcfe5f4..9881d35d47 100644 --- a/src/health_log.c +++ b/src/health_log.c @@ -121,8 +121,6 @@ inline void health_alarm_log_save(RRDHOST *host, ALARM_ENTRY *ae) { } inline ssize_t health_alarm_log_read(RRDHOST *host, FILE *fp, const char *filename) { - static uint32_t max_unique_id = 0, max_alarm_id = 0; - errno = 0; char *s, *buf = mallocz(65536 + 1); @@ -271,7 +269,7 @@ inline ssize_t health_alarm_log_read(RRDHOST *host, FILE *fp, const char *filena ae->new_value = str2l(pointers[25]); ae->old_value = str2l(pointers[26]); - static char value_string[100 + 1]; + char value_string[100 + 1]; freez(ae->old_value_string); freez(ae->new_value_string); ae->old_value_string = strdupz(format_value_and_unit(value_string, 100, ae->old_value, ae->units, -1)); @@ -285,11 +283,11 @@ inline ssize_t health_alarm_log_read(RRDHOST *host, FILE *fp, const char *filena } else updated++; - if(unlikely(ae->unique_id > max_unique_id)) - max_unique_id = ae->unique_id; + if(unlikely(ae->unique_id > host->health_max_unique_id)) + host->health_max_unique_id = ae->unique_id; - if(unlikely(ae->alarm_id >= max_alarm_id)) - max_alarm_id = ae->alarm_id; + if(unlikely(ae->alarm_id >= host->health_max_alarm_id)) + host->health_max_alarm_id = ae->alarm_id; } else { error("HEALTH [%s]: line %zu of file '%s' is invalid (unrecognized entry type '%s').", host->hostname, line, filename, pointers[0]); @@ -301,11 +299,11 @@ inline ssize_t health_alarm_log_read(RRDHOST *host, FILE *fp, const char *filena freez(buf); - if(!max_unique_id) max_unique_id = (uint32_t)now_realtime_sec(); - if(!max_alarm_id) max_alarm_id = (uint32_t)now_realtime_sec(); + if(!host->health_max_unique_id) host->health_max_unique_id = (uint32_t)now_realtime_sec(); + if(!host->health_max_alarm_id) host->health_max_alarm_id = (uint32_t)now_realtime_sec(); - host->health_log.next_log_id = max_unique_id + 1; - host->health_log.next_alarm_id = max_alarm_id + 1; + host->health_log.next_log_id = host->health_max_unique_id + 1; + host->health_log.next_alarm_id = host->health_max_alarm_id + 1; debug(D_HEALTH, "HEALTH [%s]: loaded file '%s' with %zd new alarm entries, updated %zd alarms, errors %zd entries, duplicate %zd", host->hostname, filename, loaded, updated, errored, duplicate); return loaded; @@ -388,7 +386,7 @@ inline void health_alarm_log( ae->old_value = old_value; ae->new_value = new_value; - static char value_string[100 + 1]; + char value_string[100 + 1]; ae->old_value_string = strdupz(format_value_and_unit(value_string, 100, ae->old_value, ae->units, -1)); ae->new_value_string = strdupz(format_value_and_unit(value_string, 100, ae->new_value, ae->units, -1)); @@ -463,6 +463,8 @@ struct rrdhost { ALARM_LOG health_log; // alarms historical events (event log) uint32_t health_last_processed_id; // the last processed health id from the log + uint32_t health_max_unique_id; // the max alarm log unique id given for the host + uint32_t health_max_alarm_id; // the max alarm id given for the host // templates of alarms // these are used to create alarms when charts |