Files
Linux-Server-Management-Too…/modules/security/web-traffic-monitor.sh
T
cschantz a51d968185 Initial commit: Server Management Toolkit v2.0
- Complete security menu restructure (3-mode: Analysis/Actions/Live)
- Intelligent cPHulk enablement with CSF whitelist import
- Live network security monitoring dashboard
- Multi-source threat detection and classification
- 50+ organized security tools across 4-level menu hierarchy
- System health diagnostics with cPanel/WHM integration
- Reference database for cross-module intelligence sharing
2025-11-03 18:21:40 -05:00

34 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
source "$SCRIPT_DIR/lib/common-functions.sh"
print_banner "Web Traffic Monitor"
echo ""
echo "Monitoring Apache access logs in real-time..."
echo "Press Ctrl+C to exit"
echo ""
# Find apache log directory
if [ -d "/var/log/apache2/domlogs" ]; then
tail -f /var/log/apache2/domlogs/* 2>/dev/null | while read line; do
ip=$(echo "$line" | awk '{print $1}')
request=$(echo "$line" | awk '{print $6, $7}' | tr -d '"')
status=$(echo "$line" | awk '{print $9}')
# Color code by status
if [[ "$status" =~ ^5 ]]; then
color="\033[1;31m" # Red for 5xx
elif [[ "$status" =~ ^4 ]]; then
color="\033[1;33m" # Yellow for 4xx
elif [[ "$status" =~ ^2 ]]; then
color="\033[0;32m" # Green for 2xx
else
color="\033[0;37m" # White for others
fi
printf "${color}%-15s %s %s\033[0m\n" "$ip" "$status" "$request"
done
else
print_error "Apache domlogs directory not found"
fi