summaryrefslogtreecommitdiffstats
path: root/health/health.c
diff options
context:
space:
mode:
authorEmmanuel Vasilakis <mrzammler@mm.st>2023-04-21 12:24:43 +0300
committerGitHub <noreply@github.com>2023-04-21 12:24:43 +0300
commit0d2c327ae58af5de35c9cb35a20cce9f59e92b9c (patch)
tree3f186f7a01ab574d0e2ba3ac46b85ea57aef56a8 /health/health.c
parent8d953cf206cdaac35aaa493cfcf419955db811da (diff)
Add a checkpoint message to alerts stream (#14847)
* pull aclk schemas * resolve capas * handle checkpoints and removed from health * build with disable-cloud * codacy 1 * misc changes * one more char in hash * free buffer * change topic * misc fixes * skip removed alert variables * change hash functions * use create and destroy for compatibility with older openssl
Diffstat (limited to 'health/health.c')
-rw-r--r--health/health.c63
1 files changed, 31 insertions, 32 deletions
diff --git a/health/health.c b/health/health.c
index 4218ede6fb..5c2b85bc5a 100644
--- a/health/health.c
+++ b/health/health.c
@@ -347,6 +347,15 @@ static void health_reload_host(RRDHOST *host) {
rrdcalctemplate_link_matching_templates_to_rrdset(st);
}
rrdset_foreach_done(st);
+
+#ifdef ENABLE_ACLK
+ if (netdata_cloud_setting) {
+ struct aclk_sync_host_config *wc = (struct aclk_sync_host_config *)host->aclk_sync_host_config;
+ if (likely(wc)) {
+ wc->alert_queue_removed = SEND_REMOVED_AFTER_HEALTH_LOOPS;
+ }
+ }
+#endif
}
/**
@@ -362,12 +371,6 @@ void health_reload(void) {
health_reload_host(host);
}
dfe_done(host);
-
-#ifdef ENABLE_ACLK
- if (netdata_cloud_setting) {
- aclk_alert_reloaded = 1;
- }
-#endif
}
// ----------------------------------------------------------------------------
@@ -977,9 +980,7 @@ void *health_main(void *ptr) {
rrdcalc_delete_alerts_not_matching_host_labels_from_all_hosts();
unsigned int loop = 0;
-#ifdef ENABLE_ACLK
- unsigned int marked_aclk_reload_loop = 0;
-#endif
+
while(service_running(SERVICE_HEALTH)) {
loop++;
debug(D_HEALTH, "Health monitoring iteration no %u started", loop);
@@ -1008,11 +1009,6 @@ void *health_main(void *ptr) {
}
}
-#ifdef ENABLE_ACLK
- if (aclk_alert_reloaded && !marked_aclk_reload_loop)
- marked_aclk_reload_loop = loop;
-#endif
-
worker_is_busy(WORKER_HEALTH_JOB_RRD_LOCK);
dfe_start_reentrant(rrdhost_root_index, host) {
@@ -1117,7 +1113,7 @@ void *health_main(void *ptr) {
rc->value = NAN;
#ifdef ENABLE_ACLK
- if (netdata_cloud_setting && likely(!aclk_alert_reloaded))
+ if (netdata_cloud_setting)
sql_queue_alarm_to_aclk(host, ae, 1);
#endif
}
@@ -1488,6 +1484,26 @@ void *health_main(void *ptr) {
}
break;
}
+#ifdef ENABLE_ACLK
+ if (netdata_cloud_setting) {
+ struct aclk_sync_host_config *wc = (struct aclk_sync_host_config *)host->aclk_sync_host_config;
+ if (unlikely(!wc)) {
+ continue;
+ }
+
+ if (wc->alert_queue_removed == 1) {
+ sql_queue_removed_alerts_to_aclk(host);
+ } else if (wc->alert_queue_removed > 1) {
+ wc->alert_queue_removed--;
+ }
+
+ if (wc->alert_checkpoint_req == 1) {
+ aclk_push_alarm_checkpoint(host);
+ } else if (wc->alert_checkpoint_req > 1) {
+ wc->alert_checkpoint_req--;
+ }
+ }
+#endif
}
dfe_done(host);
@@ -1500,23 +1516,6 @@ void *health_main(void *ptr) {
health_alarm_wait_for_execution(ae);
}
-#ifdef ENABLE_ACLK
- if (netdata_cloud_setting && unlikely(aclk_alert_reloaded) && loop > (marked_aclk_reload_loop + 2)) {
- dfe_start_reentrant(rrdhost_root_index, host) {
- if(unlikely(!service_running(SERVICE_HEALTH)))
- break;
-
- if (unlikely(!host->health.health_enabled))
- continue;
-
- sql_queue_removed_alerts_to_aclk(host);
- }
- dfe_done(host);
- aclk_alert_reloaded = 0;
- marked_aclk_reload_loop = 0;
- }
-#endif
-
if(unlikely(!service_running(SERVICE_HEALTH)))
break;