Fix: Add guard to prevent division by zero at line 2359
The max_bot_traffic variable is extracted from a file which could
theoretically contain all zeros, causing division by zero. Added:
max_bot_traffic=${max_bot_traffic:-1}
This ensures the denominator is never zero while preserving the
intended logic when valid data exists.
This commit is contained in:
@@ -2352,6 +2352,7 @@ generate_report() {
|
|||||||
echo ""
|
echo ""
|
||||||
echo "Bot Traffic Timeline (hourly):"
|
echo "Bot Traffic Timeline (hourly):"
|
||||||
max_bot_traffic=$(awk '{print $1}' "$TEMP_DIR/hourly_bot_traffic.txt" | sort -rn | head -1)
|
max_bot_traffic=$(awk '{print $1}' "$TEMP_DIR/hourly_bot_traffic.txt" | sort -rn | head -1)
|
||||||
|
max_bot_traffic=${max_bot_traffic:-1} # Prevent division by zero
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
count=$(echo "$line" | awk '{print $1}')
|
count=$(echo "$line" | awk '{print $1}')
|
||||||
hour=$(echo "$line" | awk '{print $2}')
|
hour=$(echo "$line" | awk '{print $2}')
|
||||||
|
|||||||
Reference in New Issue
Block a user