diff options
author | Emmanuel Vasilakis <mrzammler@mm.st> | 2021-11-18 20:14:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-18 20:14:31 +0200 |
commit | 14507c95979aff73b4359d92a7d4e6aacdbb4a47 (patch) | |
tree | de165d00c4519c376d38bd5b4144f80a671c6863 /database/sqlite/sqlite_aclk_alert.c | |
parent | 4f45e42eb2d38113bc6b53d9c9e88dc73811b973 (diff) |
Always queue alerts to aclk_alert (#11806)
* always queue to aclk_alert
* proper function name
Diffstat (limited to 'database/sqlite/sqlite_aclk_alert.c')
-rw-r--r-- | database/sqlite/sqlite_aclk_alert.c | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/database/sqlite/sqlite_aclk_alert.c b/database/sqlite/sqlite_aclk_alert.c index 950eadbf60..a71d686fd3 100644 --- a/database/sqlite/sqlite_aclk_alert.c +++ b/database/sqlite/sqlite_aclk_alert.c @@ -16,18 +16,20 @@ int sql_queue_alarm_to_aclk(RRDHOST *host, ALARM_ENTRY *ae) //include also the valid statuses for this case #ifdef ENABLE_ACLK #ifdef ENABLE_NEW_CLOUD_PROTOCOL - if (!aclk_use_new_cloud_arch) { + if (!aclk_use_new_cloud_arch && aclk_connected) { #endif if ((ae->new_status == RRDCALC_STATUS_WARNING || ae->new_status == RRDCALC_STATUS_CRITICAL) || ((ae->old_status == RRDCALC_STATUS_WARNING || ae->old_status == RRDCALC_STATUS_CRITICAL))) { aclk_update_alarm(host, ae); } - return 0; #endif #ifdef ENABLE_NEW_CLOUD_PROTOCOL } + if (!claimed()) + return 0; + if (ae->flags & HEALTH_ENTRY_FLAG_ACLK_QUEUED) return 0; @@ -846,3 +848,28 @@ void aclk_push_alert_snapshot_event(struct aclk_database_worker_config *wc, stru #endif return; } + +void sql_aclk_alert_clean_dead_entries(RRDHOST *host) +{ +#ifdef ENABLE_NEW_CLOUD_PROTOCOL + if (!claimed()) + return; + + if (unlikely(!host->dbsync_worker)) + return; + + char uuid_str[GUID_LEN + 1]; + uuid_unparse_lower_fix(&host->host_uuid, uuid_str); + + BUFFER *sql = buffer_create(1024); + + buffer_sprintf(sql,"delete from aclk_alert_%s where alert_unique_id not in " + " (select unique_id from health_log_%s); ", uuid_str, uuid_str); + + db_execute(buffer_tostring(sql)); + + buffer_free(sql); +#else + UNUSED(host); +#endif +} |