Diff -- /var/www/vhosts/3dshawn.com/site1/_alert_dispatch.pl
Diff
/var/www/vhosts/3dshawn.com/site1/_alert_dispatch.pl
modified on local at 2026-07-12 00:02:08
Added
+83
lines
Removed
-1
lines
Context
326
unchanged
Blobs
from ad10d46443a1
to 50aef6cbce02
to 50aef6cbce02
Unified diff
Naive LCS-based line diff. Additions in emerald, deletions in rose. Both sides decompressed live from BLOB_STORE.| 1 | 1 | #!/usr/bin/perl |
| 2 | 2 | #====================================================================== |
| 3 | 3 | # DriftSense -- alert dispatcher |
| 4 | 4 | # |
| 5 | 5 | # Cron entry point (NOT a CGI). Walks FILE_CHANGES + SCHEMA_CHANGE rows |
| 6 | 6 | # inserted since the last cursor tick, evaluates every ACTIVE rule |
| 7 | 7 | # against each new row, and POSTs matching payloads to the configured |
| 8 | 8 | # webhook (Slack / Discord / generic HTTP). Every attempt is logged |
| 9 | 9 | # to ALERT_DELIVERIES for the operator's audit trail. |
| 10 | 10 | # |
| 11 | 11 | # Config: /etc/drift_sense/drift_sense.conf (via MODS::Config). |
| 12 | 12 | # Log: /var/log/drift_sense/alert_dispatch.log (via cron redirect). |
| 13 | 13 | #====================================================================== |
| 14 | 14 | use strict; |
| 15 | 15 | use warnings; |
| 16 | 16 | use lib '/var/www/vhosts/3dshawn.com/site1'; |
| 17 | 17 | use POSIX (); |
| 18 | 18 | use JSON::PP; |
| 19 | 19 | use MODS::Config; |
| 20 | 20 | use MODS::DBConnect; |
| 21 | 21 | use MODS::Webhook; |
| 22 | 22 | |
| 23 | 23 | $| = 1; |
| 24 | 24 | my $ts = POSIX::strftime('%Y-%m-%d %H:%M:%S', localtime); |
| 25 | 25 | |
| 26 | 26 | my $cfg = MODS::Config->new; |
| 27 | 27 | my $db = MODS::DBConnect->new; |
| 28 | 28 | my $dbh = $db->db_connect or die "[$ts] cannot connect to DriftSense storage DB\n"; |
| 29 | 29 | |
| 30 | 30 | my $public_url = $cfg->settings('public_url') || 'https://watchtower.3dshawn.com'; |
| 31 | 31 | |
| 32 | 32 | # ---- Fetch active rules --------------------------------------------- |
| 33 | 33 | my @rules = $db->db_readwrite_multiple($dbh, q~ |
| 34 | 34 | SELECT alert_rule_id, rule_name, match_kind, match_path_glob, |
| 35 | 35 | match_status_list, exclude_ts_only, |
| 36 | 36 | delivery_kind, delivery_url, delivery_email, |
| 37 | rate_limit_per_min, coalesce_window_s | |
| 37 | rate_limit_per_min, coalesce_window_s, | |
| 38 | frequency_threshold, frequency_window_min, | |
| 39 | UNIX_TIMESTAMP(last_frequency_fire_at) AS last_freq_fire_epoch | |
| 38 | 40 | FROM ALERT_RULES |
| 39 | 41 | WHERE is_active = 1 |
| 40 | 42 | ~, __FILE__, __LINE__); |
| 41 | 43 | |
| 42 | 44 | unless (@rules) { |
| 43 | 45 | print "[$ts] no active alert rules, exiting\n"; |
| 44 | 46 | $db->db_disconnect($dbh); |
| 45 | 47 | exit 0; |
| 46 | 48 | } |
| 47 | 49 | |
| 48 | 50 | # ---- Fetch cursor --------------------------------------------------- |
| 49 | 51 | my %cursor; |
| 50 | 52 | foreach my $r ($db->db_readwrite_multiple($dbh, q~ |
| 51 | 53 | SELECT source_kind, last_seen_id FROM ALERT_CURSOR |
| 52 | 54 | ~, __FILE__, __LINE__)) { |
| 53 | 55 | $cursor{$r->{source_kind}} = $r->{last_seen_id}; |
| 54 | 56 | } |
| 55 | 57 | $cursor{file} //= 0; |
| 56 | 58 | $cursor{schema} //= 0; |
| 57 | 59 | |
| 58 | 60 | # ---- Pull new FILE_CHANGES since cursor ------------------------------ |
| 59 | 61 | my $file_max = $cursor{file}; |
| 60 | 62 | my @file_new = $db->db_readwrite_multiple($dbh, qq~ |
| 61 | 63 | SELECT fc.file_changes_id AS id, fc.file_name, fc.status, fc.blob_sha, |
| 62 | 64 | fc.is_ts_only, fc.date_time, |
| 63 | 65 | UNIX_TIMESTAMP(fc.date_time) AS ts_epoch, |
| 64 | 66 | s.server_name |
| 65 | 67 | FROM FILE_CHANGES fc |
| 66 | 68 | LEFT JOIN SERVERS s ON s.server_id = fc.server_id |
| 67 | 69 | WHERE fc.file_changes_id > $cursor{file} |
| 68 | 70 | ORDER BY fc.file_changes_id ASC |
| 69 | 71 | LIMIT 500 |
| 70 | 72 | ~, __FILE__, __LINE__); |
| 71 | 73 | foreach my $r (@file_new) { |
| 72 | 74 | $file_max = $r->{id} if $r->{id} > $file_max; |
| 73 | 75 | } |
| 74 | 76 | |
| 75 | 77 | # ---- Pull new SCHEMA_CHANGE since cursor ----------------------------- |
| 76 | 78 | my $schema_max = $cursor{schema}; |
| 77 | 79 | my @schema_new = $db->db_readwrite_multiple($dbh, qq~ |
| 78 | 80 | SELECT sc.schema_change_id AS id, sc.database_name, sc.table_name, |
| 79 | 81 | sc.changes, sc.is_ts_only, sc.change_datetime, |
| 80 | 82 | UNIX_TIMESTAMP(sc.change_datetime) AS ts_epoch, |
| 81 | 83 | s.server_name |
| 82 | 84 | FROM SCHEMA_CHANGE sc |
| 83 | 85 | LEFT JOIN SERVERS s ON s.server_id = sc.server_id |
| 84 | 86 | WHERE sc.schema_change_id > $cursor{schema} |
| 85 | 87 | ORDER BY sc.schema_change_id ASC |
| 86 | 88 | LIMIT 500 |
| 87 | 89 | ~, __FILE__, __LINE__); |
| 88 | 90 | foreach my $r (@schema_new) { |
| 89 | 91 | $schema_max = $r->{id} if $r->{id} > $schema_max; |
| 90 | 92 | } |
| 91 | 93 | |
| 92 | 94 | my $total_new = scalar(@file_new) + scalar(@schema_new); |
| 93 | 95 | if ($total_new == 0) { |
| 94 | 96 | print "[$ts] no new changes since cursor (file=$cursor{file} schema=$cursor{schema})\n"; |
| 95 | 97 | $db->db_disconnect($dbh); |
| 96 | 98 | exit 0; |
| 97 | 99 | } |
| 98 | 100 | |
| 99 | 101 | # ---- Evaluate + deliver --------------------------------------------- |
| 100 | 102 | # HTTP transport is MODS::Webhook (shells out to /usr/bin/curl) so we |
| 101 | 103 | # don't need LWP::Protocol::https / IO::Socket::SSL as CPAN installs. |
| 102 | 104 | |
| 103 | 105 | my $delivered = 0; |
| 104 | 106 | my $skipped = 0; |
| 105 | 107 | my $failed = 0; |
| 106 | 108 | |
| 107 | 109 | foreach my $row (@file_new) { _process_row($row, 'file'); } |
| 108 | 110 | foreach my $row (@schema_new) { _process_row($row, 'schema'); } |
| 111 | ||
| 112 | # ---- Frequency-mode rules ------------------------------------------ | |
| 113 | # For any rule where frequency_threshold > 0, we ignore the per-row loop | |
| 114 | # above and instead: query how many file changes matching the rule's | |
| 115 | # path glob happened in the last window_min minutes. If it crosses the | |
| 116 | # threshold and we haven't fired within the same window, fire once with | |
| 117 | # the top offender. | |
| 118 | foreach my $rule (@rules) { | |
| 119 | next unless ($rule->{frequency_threshold} || 0) > 0; | |
| 120 | my $win = int($rule->{frequency_window_min} || 60); | |
| 121 | my $thr = int($rule->{frequency_threshold}); | |
| 122 | ||
| 123 | # Re-fire cooldown: don't fire more than once per window | |
| 124 | my $last = int($rule->{last_freq_fire_epoch} || 0); | |
| 125 | if ($last && (time - $last) < $win * 60) { | |
| 126 | next; | |
| 127 | } | |
| 128 | ||
| 129 | # Find files whose match_path_glob-hit change count > threshold | |
| 130 | my $glob = $rule->{match_path_glob} // ''; | |
| 131 | my $glob_sql = ''; | |
| 132 | if (length $glob) { | |
| 133 | # Approx: SQL LIKE. Convert glob wildcards to SQL % / _. | |
| 134 | my $like = $glob; | |
| 135 | $like =~ s/\*\*/%/g; | |
| 136 | $like =~ s/\*/%/g; | |
| 137 | $like =~ s/\?/_/g; | |
| 138 | my $q_like = $dbh->quote($like); | |
| 139 | $glob_sql = " AND fc.file_name LIKE $q_like"; | |
| 140 | } | |
| 141 | my @hot = $db->db_readwrite_multiple($dbh, qq~ | |
| 142 | SELECT fc.file_name, | |
| 143 | COUNT(*) AS ct, | |
| 144 | MAX(fc.file_changes_id) AS latest_id, | |
| 145 | s.server_name | |
| 146 | FROM FILE_CHANGES fc | |
| 147 | LEFT JOIN SERVERS s ON s.server_id = fc.server_id | |
| 148 | WHERE fc.date_time >= DATE_SUB(NOW(), INTERVAL $win MINUTE) | |
| 149 | $glob_sql | |
| 150 | GROUP BY fc.file_name | |
| 151 | HAVING ct >= $thr | |
| 152 | ORDER BY ct DESC | |
| 153 | LIMIT 5 | |
| 154 | ~, __FILE__, __LINE__); | |
| 155 | next unless @hot; | |
| 156 | ||
| 157 | # Fire once with the top offender's info | |
| 158 | my $top = $hot[0]; | |
| 159 | my $fake_row = { | |
| 160 | id => $top->{latest_id}, | |
| 161 | file_name => $top->{file_name}, | |
| 162 | server_name => $top->{server_name} // 'local', | |
| 163 | date_time => POSIX::strftime('%Y-%m-%d %H:%M:%S', localtime), | |
| 164 | ts_epoch => time, | |
| 165 | status => 'frequency_alert', | |
| 166 | }; | |
| 167 | my $payload = _build_payload($rule, $fake_row, 'file'); | |
| 168 | # Enrich summary with count + threshold | |
| 169 | my $extra = "frequency alert: $top->{file_name} changed $top->{ct} times in the last $win min (threshold: $thr)"; | |
| 170 | if (ref($payload->{generic_webhook}) eq 'HASH') { | |
| 171 | $payload->{generic_webhook}{frequency_summary} = $extra; | |
| 172 | $payload->{generic_webhook}{frequency_count} = $top->{ct}; | |
| 173 | $payload->{generic_webhook}{frequency_window} = $win; | |
| 174 | $payload->{generic_webhook}{summary} = $extra; | |
| 175 | } | |
| 176 | my ($status, $http_code, $body, $err) = _deliver($rule, $payload); | |
| 177 | _log_delivery($rule, $fake_row, 'file', $status, $http_code, $body, $err); | |
| 178 | if ($status eq 'sent') { | |
| 179 | $delivered++; | |
| 180 | $db->db_readwrite($dbh, qq~ | |
| 181 | UPDATE ALERT_RULES | |
| 182 | SET fire_count = fire_count + 1, | |
| 183 | last_fired_at = NOW(), | |
| 184 | last_frequency_fire_at = NOW() | |
| 185 | WHERE alert_rule_id = $rule->{alert_rule_id} | |
| 186 | ~, __FILE__, __LINE__); | |
| 187 | } else { | |
| 188 | $failed++; | |
| 189 | } | |
| 190 | } | |
| 109 | 191 | |
| 110 | 192 | # ---- Advance cursor atomically -------------------------------------- |
| 111 | 193 | if ($file_max > $cursor{file}) { |
| 112 | 194 | $db->db_readwrite($dbh, |
| 113 | 195 | "UPDATE ALERT_CURSOR SET last_seen_id = $file_max WHERE source_kind = 'file'", |
| 114 | 196 | __FILE__, __LINE__); |
| 115 | 197 | } |
| 116 | 198 | if ($schema_max > $cursor{schema}) { |
| 117 | 199 | $db->db_readwrite($dbh, |
| 118 | 200 | "UPDATE ALERT_CURSOR SET last_seen_id = $schema_max WHERE source_kind = 'schema'", |
| 119 | 201 | __FILE__, __LINE__); |
| 120 | 202 | } |
| 121 | 203 | |
| 122 | 204 | $db->db_disconnect($dbh); |
| 123 | 205 | print "[$ts] processed +$total_new new changes: $delivered delivered, $skipped skipped, $failed failed\n"; |
| 124 | 206 | exit 0; |
| 125 | 207 | |
| 126 | 208 | #--------------------------------------------------------------------- |
| 127 | 209 | sub _process_row { |
| 128 | 210 | my ($row, $kind) = @_; |
| 129 | 211 | foreach my $rule (@rules) { |
| 130 | 212 | next unless _rule_matches($rule, $row, $kind); |
| 131 | 213 | |
| 132 | 214 | # Rate limit check |
| 133 | 215 | if ($rule->{rate_limit_per_min} > 0) { |
| 134 | 216 | my $rlq = $db->db_readwrite($dbh, qq~ |
| 135 | 217 | SELECT COUNT(*) AS n FROM ALERT_DELIVERIES |
| 136 | 218 | WHERE alert_rule_id = $rule->{alert_rule_id} |
| 137 | 219 | AND fired_at >= DATE_SUB(NOW(), INTERVAL 1 MINUTE) |
| 138 | 220 | AND delivery_status IN ('sent','pending') |
| 139 | 221 | ~, __FILE__, __LINE__); |
| 140 | 222 | if ($rlq && $rlq->{n} >= $rule->{rate_limit_per_min}) { |
| 141 | 223 | _log_delivery($rule, $row, $kind, 'skipped', undef, undef, |
| 142 | 224 | "rate limit ($rule->{rate_limit_per_min}/min) reached"); |
| 143 | 225 | $skipped++; |
| 144 | 226 | next; |
| 145 | 227 | } |
| 146 | 228 | } |
| 147 | 229 | |
| 148 | 230 | # Build payload + POST |
| 149 | 231 | my $payload = _build_payload($rule, $row, $kind); |
| 150 | 232 | my ($status, $http_code, $body, $err) = _deliver($rule, $payload); |
| 151 | 233 | _log_delivery($rule, $row, $kind, $status, $http_code, $body, $err); |
| 152 | 234 | |
| 153 | 235 | if ($status eq 'sent') { $delivered++; } |
| 154 | 236 | elsif ($status eq 'skipped') { $skipped++; } |
| 155 | 237 | else { $failed++; } |
| 156 | 238 | |
| 157 | 239 | # Bump the rule's fire_count + last_fired_at |
| 158 | 240 | if ($status eq 'sent') { |
| 159 | 241 | $db->db_readwrite($dbh, qq~ |
| 160 | 242 | UPDATE ALERT_RULES |
| 161 | 243 | SET fire_count = fire_count + 1, |
| 162 | 244 | last_fired_at = NOW() |
| 163 | 245 | WHERE alert_rule_id = $rule->{alert_rule_id} |
| 164 | 246 | ~, __FILE__, __LINE__); |
| 165 | 247 | } |
| 166 | 248 | } |
| 167 | 249 | } |
| 168 | 250 | |
| 169 | 251 | #--------------------------------------------------------------------- |
| 170 | 252 | sub _rule_matches { |
| 171 | 253 | my ($rule, $row, $kind) = @_; |
| 172 | 254 | |
| 173 | 255 | # Kind filter |
| 174 | 256 | return 0 if $rule->{match_kind} ne 'either' && $rule->{match_kind} ne $kind; |
| 175 | 257 | |
| 176 | 258 | # ts-only exclusion (files only) |
| 177 | 259 | return 0 if $kind eq 'file' && $rule->{exclude_ts_only} && $row->{is_ts_only}; |
| 178 | 260 | |
| 179 | 261 | # Path glob |
| 180 | 262 | my $glob = $rule->{match_path_glob} // ''; |
| 181 | 263 | if (length $glob) { |
| 182 | 264 | my $target = $kind eq 'file' |
| 183 | 265 | ? ($row->{file_name} // '') |
| 184 | 266 | : (($row->{database_name} // '') . '.' . ($row->{table_name} // '')); |
| 185 | 267 | my $re = _glob_to_regex($glob); |
| 186 | 268 | return 0 unless $target =~ $re; |
| 187 | 269 | } |
| 188 | 270 | |
| 189 | 271 | # Status filter (files only) |
| 190 | 272 | if ($kind eq 'file' && $rule->{match_status_list}) { |
| 191 | 273 | my %allowed = map { s/^\s+|\s+$//g; $_ => 1 } |
| 192 | 274 | split /,/, $rule->{match_status_list}; |
| 193 | 275 | return 0 unless $allowed{ $row->{status} // '' }; |
| 194 | 276 | } |
| 195 | 277 | |
| 196 | 278 | return 1; |
| 197 | 279 | } |
| 198 | 280 | |
| 199 | 281 | sub _glob_to_regex { |
| 200 | 282 | my $g = shift; |
| 201 | 283 | my $re = quotemeta $g; |
| 202 | 284 | # Handle glob patterns: escaped meta chars back to regex meaning |
| 203 | 285 | $re =~ s{\\\*\\\*}{.*}g; # ** -> .* |
| 204 | 286 | $re =~ s{\\\*}{[^/]*}g; # * -> [^/]* |
| 205 | 287 | $re =~ s{\\\?}{.}g; # ? -> . |
| 206 | 288 | return qr/^$re$/; |
| 207 | 289 | } |
| 208 | 290 | |
| 209 | 291 | #--------------------------------------------------------------------- |
| 210 | 292 | sub _build_payload { |
| 211 | 293 | my ($rule, $row, $kind) = @_; |
| 212 | 294 | |
| 213 | 295 | my $where = $kind eq 'file' |
| 214 | 296 | ? ($row->{file_name} // '(unknown file)') |
| 215 | 297 | : (($row->{database_name} // '?') . '.' . ($row->{table_name} // '?')); |
| 216 | 298 | my $when_utc = $row->{date_time} || $row->{change_datetime} || ''; |
| 217 | 299 | my $server = $row->{server_name} || 'local'; |
| 218 | 300 | my $status_h = $kind eq 'file' ? ($row->{status} // '') : 'DDL change'; |
| 219 | 301 | my $link_id = $row->{id}; |
| 220 | 302 | my $link = "$public_url/diff.cgi?kind=$kind&id=$link_id"; |
| 221 | 303 | |
| 222 | 304 | my $summary = $kind eq 'file' |
| 223 | 305 | ? "$status_h: $where on $server" |
| 224 | 306 | : "$where changed on $server"; |
| 225 | 307 | |
| 226 | 308 | my $slack = { |
| 227 | 309 | text => "*DriftSense*: $summary", |
| 228 | 310 | attachments => [{ |
| 229 | 311 | color => $kind eq 'schema' ? '#f59e0b' : '#14b8a6', |
| 230 | 312 | fields => [ |
| 231 | 313 | { title => 'What', value => $where, short => 0 }, |
| 232 | 314 | { title => 'When', value => $when_utc, short => 1 }, |
| 233 | 315 | { title => 'Server', value => $server, short => 1 }, |
| 234 | 316 | ], |
| 235 | 317 | actions => [{ |
| 236 | 318 | type => 'button', text => 'View diff', url => $link, |
| 237 | 319 | }], |
| 238 | 320 | }], |
| 239 | 321 | }; |
| 240 | 322 | my $discord = { |
| 241 | 323 | content => "**DriftSense**: $summary", |
| 242 | 324 | embeds => [{ |
| 243 | 325 | title => $where, |
| 244 | 326 | url => $link, |
| 245 | 327 | color => $kind eq 'schema' ? 16101915 : 1349286, # amber, teal |
| 246 | 328 | fields => [ |
| 247 | 329 | { name => 'When', value => $when_utc || '?', inline => \1 }, |
| 248 | 330 | { name => 'Server', value => $server, inline => \1 }, |
| 249 | 331 | ], |
| 250 | 332 | }], |
| 251 | 333 | }; |
| 252 | 334 | my $generic = { |
| 253 | 335 | source => 'drift_sense', |
| 254 | 336 | rule_id => $rule->{alert_rule_id}, |
| 255 | 337 | rule_name => $rule->{rule_name}, |
| 256 | 338 | kind => $kind, |
| 257 | 339 | summary => $summary, |
| 258 | 340 | target => $where, |
| 259 | 341 | server => $server, |
| 260 | 342 | when_utc => $when_utc, |
| 261 | 343 | ts_epoch => $row->{ts_epoch}, |
| 262 | 344 | diff_url => $link, |
| 263 | 345 | status => $status_h, |
| 264 | 346 | }; |
| 265 | 347 | |
| 266 | 348 | return { |
| 267 | 349 | slack => $slack, |
| 268 | 350 | discord => $discord, |
| 269 | 351 | generic_webhook => $generic, |
| 270 | 352 | summary => $summary, |
| 271 | 353 | }; |
| 272 | 354 | } |
| 273 | 355 | |
| 274 | 356 | #--------------------------------------------------------------------- |
| 275 | 357 | sub _deliver { |
| 276 | 358 | my ($rule, $payload) = @_; |
| 277 | 359 | my $kind = $rule->{delivery_kind}; |
| 278 | 360 | my $url = $rule->{delivery_url}; |
| 279 | 361 | |
| 280 | 362 | if ($kind eq 'email') { |
| 281 | 363 | return ('skipped', undef, undef, 'email delivery not yet implemented'); |
| 282 | 364 | } |
| 283 | 365 | unless (length($url // '')) { |
| 284 | 366 | return ('failed', undef, undef, "no delivery URL configured"); |
| 285 | 367 | } |
| 286 | 368 | |
| 287 | 369 | my $body_ref = $kind eq 'slack' ? $payload->{slack} |
| 288 | 370 | : $kind eq 'discord' ? $payload->{discord} |
| 289 | 371 | : $payload->{generic_webhook}; |
| 290 | 372 | |
| 291 | 373 | # MODS::Webhook handles JSON encoding + curl transport; returns |
| 292 | 374 | # (http_code, response_body, error_message). |
| 293 | 375 | my ($code, $rbody, $err) = MODS::Webhook::post_json( |
| 294 | 376 | $url, $body_ref, |
| 295 | 377 | timeout => 8, |
| 296 | 378 | user_agent => 'DriftSense/1.0 (alert-dispatch)', |
| 297 | 379 | ); |
| 298 | 380 | $rbody //= ''; |
| 299 | 381 | $rbody = substr($rbody, 0, 500) if length($rbody) > 500; |
| 300 | 382 | |
| 301 | 383 | if (!$err && $code >= 200 && $code < 400) { |
| 302 | 384 | return ('sent', $code, $rbody, undef); |
| 303 | 385 | } |
| 304 | 386 | return ('failed', $code, $rbody, $err || "HTTP $code"); |
| 305 | 387 | } |
| 306 | 388 | |
| 307 | 389 | #--------------------------------------------------------------------- |
| 308 | 390 | sub _log_delivery { |
| 309 | 391 | my ($rule, $row, $kind, $status, $http_code, $body, $err) = @_; |
| 310 | 392 | my $summary = substr(($rule->{rule_name} // '') . ' :: ' . ($row->{file_name} |
| 311 | 393 | || ($row->{database_name} . '.' . $row->{table_name}) |
| 312 | 394 | || '?'), 0, 490); |
| 313 | 395 | my $q_summary = $dbh->quote($summary); |
| 314 | 396 | my $q_status = $dbh->quote($status); |
| 315 | 397 | my $q_body = $dbh->quote($body // ''); |
| 316 | 398 | my $q_err = $dbh->quote($err // ''); |
| 317 | 399 | my $q_code = defined($http_code) ? int($http_code) : 'NULL'; |
| 318 | 400 | |
| 319 | 401 | $db->db_readwrite($dbh, qq~ |
| 320 | 402 | INSERT INTO ALERT_DELIVERIES |
| 321 | 403 | (alert_rule_id, source_kind, source_id, match_summary, |
| 322 | 404 | delivery_status, http_status, http_response, error_message) |
| 323 | 405 | VALUES |
| 324 | 406 | ($rule->{alert_rule_id}, '$kind', $row->{id}, $q_summary, |
| 325 | 407 | $q_status, $q_code, $q_body, $q_err) |
| 326 | 408 | ~, __FILE__, __LINE__); |
| 327 | 409 | } |