each host gets its own range of alarm and alarm log IDs; fixes #2694
Costa Tsaousis (ktsaou) committed
Sep 7, 2017 at 11:14 UTC
63d4a426222af592d5b61dd4c8d03757b4ec048f
2 files changed
+12
-12
src/health_log.c
+10
-12
@@ -121,8 +121,6 @@ inline void health_alarm_log_save(RRDHOST *host, ALARM_ENTRY *ae) {
121
}
122
123
inline ssize_t health_alarm_log_read(RRDHOST *host, FILE *fp, const char *filename) {
124
- static uint32_t max_unique_id = 0, max_alarm_id = 0;
125
-
124
errno = 0;
125
126
char *s, *buf = mallocz(65536 + 1);
@@ -271,7 +269,7 @@ inline ssize_t health_alarm_log_read(RRDHOST *host, FILE *fp, const char *filena
269
ae->new_value = str2l(pointers[25]);
270
ae->old_value = str2l(pointers[26]);
271
274
- static char value_string[100 + 1];
272
+ char value_string[100 + 1];
273
freez(ae->old_value_string);
274
freez(ae->new_value_string);
275
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
283
}
284
else updated++;
285
288
- if(unlikely(ae->unique_id > max_unique_id))
289
- max_unique_id = ae->unique_id;
286
+ if(unlikely(ae->unique_id > host->health_max_unique_id))
287
+ host->health_max_unique_id = ae->unique_id;
288
291
- if(unlikely(ae->alarm_id >= max_alarm_id))
292
- max_alarm_id = ae->alarm_id;
289
+ if(unlikely(ae->alarm_id >= host->health_max_alarm_id))
290
+ host->health_max_alarm_id = ae->alarm_id;
291
}
292
else {
293
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
299
300
freez(buf);
301
304
- if(!max_unique_id) max_unique_id = (uint32_t)now_realtime_sec();
305
- if(!max_alarm_id) max_alarm_id = (uint32_t)now_realtime_sec();
302
+ if(!host->health_max_unique_id) host->health_max_unique_id = (uint32_t)now_realtime_sec();
303
+ if(!host->health_max_alarm_id) host->health_max_alarm_id = (uint32_t)now_realtime_sec();
304
307
- host->health_log.next_log_id = max_unique_id + 1;
308
- host->health_log.next_alarm_id = max_alarm_id + 1;
305
+ host->health_log.next_log_id = host->health_max_unique_id + 1;
306
+ host->health_log.next_alarm_id = host->health_max_alarm_id + 1;
307
308
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);
309
return loaded;
@@ -388,7 +386,7 @@ inline void health_alarm_log(
386
ae->old_value = old_value;
387
ae->new_value = new_value;
388
391
- static char value_string[100 + 1];
389
+ char value_string[100 + 1];
390
ae->old_value_string = strdupz(format_value_and_unit(value_string, 100, ae->old_value, ae->units, -1));
391
ae->new_value_string = strdupz(format_value_and_unit(value_string, 100, ae->new_value, ae->units, -1));
392
src/rrd.h
+2
@@ -463,6 +463,8 @@ struct rrdhost {
463
464
ALARM_LOG health_log; // alarms historical events (event log)
465
uint32_t health_last_processed_id; // the last processed health id from the log
466
+ uint32_t health_max_unique_id; // the max alarm log unique id given for the host
467
+ uint32_t health_max_alarm_id; // the max alarm id given for the host
468
469
// templates of alarms
470
// these are used to create alarms when charts