Do not include REMOVED status in the alert snapshot (#18197)
Do not include REMOVED status in the snapshot
Stelios Fragkakis committed
Jul 18, 2024 at 22:37 UTC
cf7a61081754405fdf11f3dc01f7392122b6e587
1 file changed
+4
-5
src/database/sqlite/sqlite_aclk_alert.c
+4
-5
@@ -859,7 +859,7 @@ void aclk_process_send_alarm_snapshot(char *node_id, char *claim_id __maybe_unus
859
860
#define SQL_COUNT_SNAPSHOT_ENTRIES \
861
"SELECT COUNT(1) FROM alert_version av, health_log hl " \
862
- "WHERE hl.host_id = @host_id AND hl.health_log_id = av.health_log_id"
862
+ "WHERE hl.host_id = @host_id AND hl.health_log_id = av.health_log_id AND av.status <> -2"
863
864
static int calculate_alert_snapshot_entries(nd_uuid_t *host_uuid)
865
{
@@ -896,7 +896,7 @@ done:
896
" FROM health_log hl, alert_hash ah, health_log_detail hld, alert_version av " \
897
" WHERE hl.config_hash_id = ah.hash_id" \
898
" AND hl.host_id = @host_id AND hl.health_log_id = hld.health_log_id " \
899
- " AND hld.health_log_id = av.health_log_id AND av.unique_id = hld.unique_id"
899
+ " AND hld.health_log_id = av.health_log_id AND av.unique_id = hld.unique_id AND av.status <> -2"
900
901
#define ALARM_EVENTS_PER_CHUNK 1000
902
void send_alert_snapshot_to_cloud(RRDHOST *host __maybe_unused)
@@ -952,20 +952,19 @@ void send_alert_snapshot_to_cloud(RRDHOST *host __maybe_unused)
952
alarm_log.node_id = wc->node_id;
953
alarm_log.claim_id = claim_id;
954
955
-
955
cnt = 0;
956
param = 0;
957
uint64_t version = 0;
958
+ int total_count = 0;
959
while (sqlite3_step_monitored(res) == SQLITE_ROW) {
960
cnt++;
961
+ total_count++;
962
963
if (!snapshot_proto)
964
snapshot_proto = generate_alarm_snapshot_proto(&alarm_snap);
965
966
health_alarm_log_populate(&alarm_log, res, host, NULL);
967
967
- //log_alarm_log(&alarm_log);
968
-
968
add_alarm_log_entry2snapshot(snapshot_proto, &alarm_log);
969
version += alarm_log.version;
970