diff --git a/modules/performance/network-bandwidth-analyzer.sh b/modules/performance/network-bandwidth-analyzer.sh index ff8e76d..5d980a3 100755 --- a/modules/performance/network-bandwidth-analyzer.sh +++ b/modules/performance/network-bandwidth-analyzer.sh @@ -234,7 +234,7 @@ analyze_web_traffic() { for logfile in "$log_dir"/*.log; do [ -f "$logfile" ] || continue local domain=$(basename "$logfile" .log) - local bytes=$(awk '{sum+=$10} END {print sum}' "$logfile" 2>/dev/null || echo "0") + local bytes=$(awk 'BEGIN {sum=0} {sum+=$10} END {print sum}' "$logfile" 2>/dev/null || echo "0") if [ "$bytes" -gt 0 ]; then local mb=$(awk "BEGIN {printf \"%.2f\", $bytes / 1048576}") diff --git a/modules/security/bot-analyzer.sh b/modules/security/bot-analyzer.sh index c10bc5b..50ae08a 100755 --- a/modules/security/bot-analyzer.sh +++ b/modules/security/bot-analyzer.sh @@ -860,7 +860,7 @@ detect_botnets() { sort | uniq -c | \ awk '$1 > 50 {print $1 " " $2}' | \ awk -F'|' '{print $1}' | \ - awk '{ip=$2; count=$1; sum[ip]+=count; max[ip]=(count>max[ip]?count:max[ip])} END {for(ip in sum) print sum[ip], ip, max[ip]}' | \ + awk 'BEGIN {ip=""} {ip=$2; count=$1; sum[ip]+=count; max[ip]=(count>max[ip]?count:max[ip])} END {for(ip in sum) print sum[ip], ip, max[ip]}' | \ sort -rn > "$TEMP_DIR/rapid_fire_ips.txt" print_success "Botnet analysis complete" @@ -1560,8 +1560,8 @@ generate_report() { echo "2. Top Aggressive Bots:" counter=1 while read -r line && [ "${counter:-0}" -le 5 ]; do - count=$(echo "$line" | awk '{print $1}') - bot=$(echo "$line" | awk '{$1=""; print $0}' | xargs) + count=$(echo "$line" | awk 'BEGIN {count=0} {print $1}') + bot=$(echo "$line" | awk 'BEGIN {f=""} {$1=""; print $0}' | xargs) action="Allow" if echo "$bot" | grep -qiE "ahrefs|semrush|dotbot|blex|megaindex"; then diff --git a/modules/security/optimize-ct-limit.sh b/modules/security/optimize-ct-limit.sh index 544100f..f244294 100755 --- a/modules/security/optimize-ct-limit.sh +++ b/modules/security/optimize-ct-limit.sh @@ -241,7 +241,7 @@ analyze_per_site_traffic() { if [ -n "$domain_data" ]; then max_conn=$(echo "$domain_data" | cut -d'|' -f3 | sort -rn | head -1) total_ips=$(echo "$domain_data" | cut -d'|' -f1 | sort -u | wc -l) - total_requests=$(echo "$domain_data" | cut -d'|' -f4 | awk '{s+=$1} END {print s}') + total_requests=$(echo "$domain_data" | cut -d'|' -f4 | awk 'BEGIN {s=0} {s+=$1} END {print s}') fi fi