Find host and pass health_enabled to cloud health log message (#11960)
Emmanuel Vasilakis committed
Jan 13, 2022 at 19:04 UTC
ad6992e96886af03c85fb808a2f9becbb7ce8682
1 file changed
+16
-1
database/sqlite/sqlite_aclk_alert.c
+16
-1
@@ -321,6 +321,21 @@ void aclk_push_alarm_health_log(struct aclk_database_worker_config *wc, struct a
321
if (unlikely(!claim_id))
322
return;
323
324
+ RRDHOST *host = wc->host;
325
+ if (unlikely(!host)) {
326
+ rrd_wrlock();
327
+ host = find_host_by_node_id(wc->node_id);
328
+ rrd_unlock();
329
+
330
+ if (unlikely(!host)) {
331
+ log_access(
332
+ "AC [%s (N/A)]: ACLK synchronization thread for %s is not yet linked to HOST.",
333
+ wc->node_id,
334
+ wc->host_guid);
335
+ return;
336
+ }
337
+ }
338
+
339
uint64_t first_sequence = 0;
340
uint64_t last_sequence = 0;
341
struct timeval first_timestamp;
@@ -370,7 +385,7 @@ void aclk_push_alarm_health_log(struct aclk_database_worker_config *wc, struct a
385
alarm_log.node_id = wc->node_id;
386
alarm_log.log_entries = log_entries;
387
alarm_log.status = wc->alert_updates == 0 ? 2 : 1;
373
- alarm_log.enabled = 1;
388
+ alarm_log.enabled = (int)host->health_enabled;
389
390
wc->alert_sequence_id = last_sequence;
391