Fix AWK syntax errors in monitoring scripts
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 1m48s

- Remove semicolons from variable initialization in AWK scripts
- Each variable now on separate line to prevent syntax errors
- Fixes "syntax error at or near ," in monitor-attacks.sh and manage-blocked-ips.sh
- Scripts now properly parse HAProxy 3.0.11 threat intelligence data

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-09-22 19:42:54 -07:00
parent 4c4e99883b
commit 8636b69ee1
2 changed files with 19 additions and 5 deletions

View File

@@ -57,7 +57,11 @@ case "$1" in
echo "show table web" | socat stdio "$SOCKET" | awk ' echo "show table web" | socat stdio "$SOCKET" | awk '
NR>1 { NR>1 {
ip = $1 ip = $1
auth_fail = 0; authz_fail = 0; scanner = 0; repeat_off = 0; manual_bl = 0 auth_fail = 0
authz_fail = 0
scanner = 0
repeat_off = 0
manual_bl = 0
if ($0 ~ /gpc\(0\)=([0-9]+)/) { match($0, /gpc\(0\)=([0-9]+)/, arr); auth_fail = arr[1] } if ($0 ~ /gpc\(0\)=([0-9]+)/) { match($0, /gpc\(0\)=([0-9]+)/, arr); auth_fail = arr[1] }
if ($0 ~ /gpc\(1\)=([0-9]+)/) { match($0, /gpc\(1\)=([0-9]+)/, arr); authz_fail = arr[1] } if ($0 ~ /gpc\(1\)=([0-9]+)/) { match($0, /gpc\(1\)=([0-9]+)/, arr); authz_fail = arr[1] }

View File

@@ -19,10 +19,20 @@ show_threats() {
# Parse the stick table output for array-based GPC values # Parse the stick table output for array-based GPC values
ip = $1 ip = $1
# Look for GPC array values in the data # Look for GPC array values in the data
auth_fail = 0; authz_fail = 0; rate_viol = 0; scanner = 0 auth_fail = 0
sql_inj = 0; traversal = 0; wp_brute = 0; admin_scan = 0 authz_fail = 0
shell_att = 0; repeat_off = 0; manual_bl = 0; auto_bl = 0 rate_viol = 0
glitch_rate = 0; threat_score = 0 scanner = 0
sql_inj = 0
traversal = 0
wp_brute = 0
admin_scan = 0
shell_att = 0
repeat_off = 0
manual_bl = 0
auto_bl = 0
glitch_rate = 0
threat_score = 0
# Extract relevant metrics (simplified parsing) # Extract relevant metrics (simplified parsing)
if ($0 ~ /gpc\(0\)=([0-9]+)/) { if ($0 ~ /gpc\(0\)=([0-9]+)/) {