Compare commits
7 Commits
3006abee21
...
2c13360667
| Author | SHA1 | Date | |
|---|---|---|---|
| 2c13360667 | |||
| a112bd53a9 | |||
| 209ded13fc | |||
| 87e0ff7d57 | |||
| 37c1df567c | |||
| fa79663d9e | |||
| 0a8cb302df |
@@ -11,6 +11,10 @@ server-toolkit/
|
|||||||
│
|
│
|
||||||
├── modules/ # Modular scripts organized by category
|
├── modules/ # Modular scripts organized by category
|
||||||
│ │
|
│ │
|
||||||
|
│ ├── diagnostics/ # 🔍 System Diagnostics
|
||||||
|
│ │ ├── system-health-check.sh # Comprehensive health analysis
|
||||||
|
│ │ └── loadwatch-analyzer.sh # System health from loadwatch monitoring logs
|
||||||
|
│ │
|
||||||
│ ├── security/ # 🛡️ Security & Threat Analysis
|
│ ├── security/ # 🛡️ Security & Threat Analysis
|
||||||
│ │ ├── bot-analyzer.sh # Full bot/threat analysis
|
│ │ ├── bot-analyzer.sh # Full bot/threat analysis
|
||||||
│ │ ├── live-attack-monitor.sh # Real-time attack monitoring dashboard
|
│ │ ├── live-attack-monitor.sh # Real-time attack monitoring dashboard
|
||||||
@@ -42,13 +46,15 @@ server-toolkit/
|
|||||||
│ │ ├── website-error-analyzer.sh # Comprehensive website error analysis
|
│ │ ├── website-error-analyzer.sh # Comprehensive website error analysis
|
||||||
│ │ └── 500-error-tracker.sh # Track and analyze 500 errors
|
│ │ └── 500-error-tracker.sh # Track and analyze 500 errors
|
||||||
│ │
|
│ │
|
||||||
│ ├── diagnostics/ # 🔍 System Diagnostics
|
│ ├── diagnostics/ # 🔍 System Diagnostics & Log Analysis
|
||||||
│ │ └── system-health-check.sh # Comprehensive health analysis
|
│ │ ├── system-health-check.sh # Comprehensive health analysis
|
||||||
|
│ │ └── loadwatch-analyzer.sh # System health monitoring from loadwatch logs
|
||||||
│ │
|
│ │
|
||||||
│ ├── performance/ # 📊 Performance Analysis
|
│ ├── performance/ # 📊 Performance Analysis
|
||||||
│ │ ├── hardware-health-check.sh # Hardware diagnostics
|
│ │ ├── hardware-health-check.sh # Hardware diagnostics
|
||||||
│ │ ├── mysql-query-analyzer.sh # MySQL performance analysis
|
│ │ ├── mysql-query-analyzer.sh # MySQL performance analysis
|
||||||
│ │ └── network-bandwidth-analyzer.sh # Network analysis
|
│ │ ├── network-bandwidth-analyzer.sh # Network analysis
|
||||||
|
│ │ └── (other performance modules)
|
||||||
│ │
|
│ │
|
||||||
│ └── maintenance/ # 🧹 System Maintenance
|
│ └── maintenance/ # 🧹 System Maintenance
|
||||||
│ └── cleanup-toolkit-data.sh # Clean temporary toolkit data
|
│ └── cleanup-toolkit-data.sh # Clean temporary toolkit data
|
||||||
@@ -110,10 +116,17 @@ source /root/server-toolkit/run.sh
|
|||||||
- **Log Integration**: Apache, PHP-FPM, cPanel error log analysis
|
- **Log Integration**: Apache, PHP-FPM, cPanel error log analysis
|
||||||
- **Smart Recommendations**: Context-aware suggestions for fixing issues
|
- **Smart Recommendations**: Context-aware suggestions for fixing issues
|
||||||
|
|
||||||
### 🔍 System Diagnostics
|
### 🔍 System Diagnostics & Performance Monitoring
|
||||||
- **Comprehensive Health Checks**: Hardware, services, security posture
|
- **Comprehensive Health Checks**: Hardware, services, security posture
|
||||||
|
- **Loadwatch Health Analyzer**: Historical system health analysis from monitoring logs
|
||||||
|
- Time-range analysis: 1h, 6h, 24h, 7d, 30d
|
||||||
|
- Memory pressure detection and swap usage trending
|
||||||
|
- CPU saturation analysis (idle, iowait, steal time)
|
||||||
|
- Process issue detection (zombies, high CPU/MEM consumers)
|
||||||
|
- MySQL performance monitoring
|
||||||
|
- Actionable recommendations based on findings
|
||||||
- **Smart Recommendations**: Context-aware suggestions based on findings
|
- **Smart Recommendations**: Context-aware suggestions based on findings
|
||||||
- **cPanel/WHM Integration**: Native support for cPanel environments
|
- **Multi-Panel Support**: cPanel, InterWorx, Plesk, standalone Apache
|
||||||
|
|
||||||
### 📊 Session Intelligence
|
### 📊 Session Intelligence
|
||||||
- **Reference Database**: Cross-module data sharing (.sysref)
|
- **Reference Database**: Cross-module data sharing (.sysref)
|
||||||
@@ -168,6 +181,15 @@ bash launcher.sh
|
|||||||
# Select: System Health Check
|
# Select: System Health Check
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Loadwatch System Health Analysis
|
||||||
|
|
||||||
|
```bash
|
||||||
|
bash launcher.sh
|
||||||
|
# Select: Performance & Diagnostics
|
||||||
|
# Select: Loadwatch Health Analyzer
|
||||||
|
# Choose time range: 1h, 6h, 24h, 7d, or 30d
|
||||||
|
```
|
||||||
|
|
||||||
## 🔧 Configuration
|
## 🔧 Configuration
|
||||||
|
|
||||||
Edit the configuration file:
|
Edit the configuration file:
|
||||||
|
|||||||
+38
-2
@@ -539,7 +539,8 @@ show_performance_menu() {
|
|||||||
echo ""
|
echo ""
|
||||||
echo -e "${BOLD}Logs & Diagnostics:${NC}"
|
echo -e "${BOLD}Logs & Diagnostics:${NC}"
|
||||||
echo -e " ${MAGENTA}9)${NC} Log Analyzer - Parse and analyze system logs"
|
echo -e " ${MAGENTA}9)${NC} Log Analyzer - Parse and analyze system logs"
|
||||||
echo -e " ${MAGENTA}10)${NC} Email Queue Monitor - Mail queue analysis"
|
echo -e " ${MAGENTA}10)${NC} Loadwatch Health Analyzer - System health from monitoring logs"
|
||||||
|
echo -e " ${MAGENTA}11)${NC} Email Queue Monitor - Mail queue analysis"
|
||||||
echo ""
|
echo ""
|
||||||
echo -e " ${RED}0)${NC} Back to Main Menu"
|
echo -e " ${RED}0)${NC} Back to Main Menu"
|
||||||
echo ""
|
echo ""
|
||||||
@@ -1346,6 +1347,40 @@ handle_wp_security_menu() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Loadwatch analyzer handler with time range selection
|
||||||
|
handle_loadwatch_analyzer() {
|
||||||
|
show_banner
|
||||||
|
echo -e "${MAGENTA}${BOLD}📊 Loadwatch Health Analyzer${NC}"
|
||||||
|
echo ""
|
||||||
|
echo -e "Select time range for analysis:"
|
||||||
|
echo ""
|
||||||
|
echo -e " ${CYAN}1)${NC} Last 1 Hour - Recent system activity"
|
||||||
|
echo -e " ${CYAN}2)${NC} Last 6 Hours - Mid-term trending"
|
||||||
|
echo -e " ${CYAN}3)${NC} Last 24 Hours - Full day analysis"
|
||||||
|
echo -e " ${CYAN}4)${NC} Last 7 Days - Weekly patterns"
|
||||||
|
echo -e " ${CYAN}5)${NC} Last 30 Days - Monthly overview"
|
||||||
|
echo ""
|
||||||
|
echo -e " ${RED}0)${NC} Back"
|
||||||
|
echo ""
|
||||||
|
echo -e "${CYAN}──────────────────────────────────────────────────────────────${NC}"
|
||||||
|
echo -n "Select time range: "
|
||||||
|
|
||||||
|
read -r range_choice
|
||||||
|
|
||||||
|
case $range_choice in
|
||||||
|
1) run_module "diagnostics" "loadwatch-analyzer.sh" "-r" "1h" ;;
|
||||||
|
2) run_module "diagnostics" "loadwatch-analyzer.sh" "-r" "6h" ;;
|
||||||
|
3) run_module "diagnostics" "loadwatch-analyzer.sh" "-r" "24h" ;;
|
||||||
|
4) run_module "diagnostics" "loadwatch-analyzer.sh" "-r" "7d" ;;
|
||||||
|
5) run_module "diagnostics" "loadwatch-analyzer.sh" "-r" "30d" ;;
|
||||||
|
0) return ;;
|
||||||
|
*)
|
||||||
|
echo -e "${RED}Invalid option${NC}"
|
||||||
|
sleep 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
# Performance submenu handler
|
# Performance submenu handler
|
||||||
handle_performance_menu() {
|
handle_performance_menu() {
|
||||||
while true; do
|
while true; do
|
||||||
@@ -1362,7 +1397,8 @@ handle_performance_menu() {
|
|||||||
7) run_module "performance" "apache-performance.sh" ;;
|
7) run_module "performance" "apache-performance.sh" ;;
|
||||||
8) run_module "performance" "php-fpm-monitor.sh" ;;
|
8) run_module "performance" "php-fpm-monitor.sh" ;;
|
||||||
9) run_module "performance" "log-analyzer.sh" ;;
|
9) run_module "performance" "log-analyzer.sh" ;;
|
||||||
10) run_module "performance" "email-queue-monitor.sh" ;;
|
10) handle_loadwatch_analyzer ;;
|
||||||
|
11) run_module "performance" "email-queue-monitor.sh" ;;
|
||||||
0) return ;;
|
0) return ;;
|
||||||
*) echo -e "${RED}Invalid option${NC}"; sleep 1 ;;
|
*) echo -e "${RED}Invalid option${NC}"; sleep 1 ;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
@@ -172,12 +172,12 @@ get_database_domain() {
|
|||||||
capture_live_queries() {
|
capture_live_queries() {
|
||||||
local output_file="${TEMP_SESSION_DIR}/live_queries.tmp"
|
local output_file="${TEMP_SESSION_DIR}/live_queries.tmp"
|
||||||
|
|
||||||
print_info "Capturing live queries..."
|
print_info "Capturing live queries..." >&2
|
||||||
|
|
||||||
mysql -e "SHOW FULL PROCESSLIST" 2>/dev/null | grep -v "SHOW FULL PROCESSLIST" > "$output_file"
|
mysql -e "SHOW FULL PROCESSLIST" 2>/dev/null | grep -v "SHOW FULL PROCESSLIST" > "$output_file"
|
||||||
|
|
||||||
local query_count=$(wc -l < "$output_file")
|
local query_count=$(wc -l < "$output_file")
|
||||||
print_success "Captured $query_count active queries"
|
print_success "Captured $query_count active queries" >&2
|
||||||
|
|
||||||
echo "$output_file"
|
echo "$output_file"
|
||||||
}
|
}
|
||||||
@@ -193,18 +193,19 @@ parse_slow_query_log() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f "$slow_log" ]; then
|
if [ ! -f "$slow_log" ]; then
|
||||||
print_warning "Slow query log not found"
|
print_warning "Slow query log not found" >&2
|
||||||
touch "$output_file"
|
touch "$output_file"
|
||||||
|
echo "$output_file"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
print_info "Parsing slow query log: $slow_log"
|
print_info "Parsing slow query log: $slow_log" >&2
|
||||||
|
|
||||||
# Extract queries that took > 1 second (adjustable)
|
# Extract queries that took > 1 second (adjustable)
|
||||||
grep -A 10 "Query_time:" "$slow_log" 2>/dev/null | tail -1000 > "$output_file"
|
grep -A 10 "Query_time:" "$slow_log" 2>/dev/null | tail -1000 > "$output_file"
|
||||||
|
|
||||||
local query_count=$(grep -c "Query_time:" "$output_file" 2>/dev/null || echo 0)
|
local query_count=$(grep -c "Query_time:" "$output_file" 2>/dev/null || echo 0)
|
||||||
print_success "Found $query_count slow queries"
|
print_success "Found $query_count slow queries" >&2
|
||||||
|
|
||||||
echo "$output_file"
|
echo "$output_file"
|
||||||
}
|
}
|
||||||
@@ -326,7 +327,7 @@ analyze_queries_for_problems() {
|
|||||||
local query_file="$1"
|
local query_file="$1"
|
||||||
local problems_file="${TEMP_SESSION_DIR}/query_problems.tmp"
|
local problems_file="${TEMP_SESSION_DIR}/query_problems.tmp"
|
||||||
|
|
||||||
print_info "Analyzing queries for problems..."
|
print_info "Analyzing queries for problems..." >&2
|
||||||
|
|
||||||
> "$problems_file"
|
> "$problems_file"
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -433,7 +433,7 @@ build_wordpress_section() {
|
|||||||
local db_host=$(grep "DB_HOST" "$wp_config" | grep -oP "'[^']+'" | tail -1 | tr -d "'" || true)
|
local db_host=$(grep "DB_HOST" "$wp_config" | grep -oP "'[^']+'" | tail -1 | tr -d "'" || true)
|
||||||
|
|
||||||
# Try to get site URL from wp-config defines
|
# Try to get site URL from wp-config defines
|
||||||
local site_url=$(grep -E "WP_SITEURL|WP_HOME" "$wp_config" | head -1 | grep -oP "https?://\K[^/'\"']+" || true)
|
local site_url=$(grep -E "WP_SITEURL|WP_HOME" "$wp_config" | head -1 | grep -oP "https?://\K[^/'\"]+" || true)
|
||||||
if [ -n "$site_url" ]; then
|
if [ -n "$site_url" ]; then
|
||||||
domain="$site_url"
|
domain="$site_url"
|
||||||
fi
|
fi
|
||||||
|
|||||||
+1
-1
@@ -644,7 +644,7 @@ find_user_wordpress_sites() {
|
|||||||
local domain=$(basename "$(dirname "$wp_dir")" 2>/dev/null)
|
local domain=$(basename "$(dirname "$wp_dir")" 2>/dev/null)
|
||||||
|
|
||||||
# Try to get actual domain from wp-config
|
# Try to get actual domain from wp-config
|
||||||
local site_url=$(grep "WP_SITEURL\|WP_HOME" "$wp_config" | head -1 | grep -oP "https?://\K[^/'\"]+")
|
local site_url=$(grep "WP_SITEURL\|WP_HOME" "$wp_config" | head -1 | grep -oP "https?://\K[^/'\"]+" 2>/dev/null || true)
|
||||||
|
|
||||||
if [ -n "$site_url" ]; then
|
if [ -n "$site_url" ]; then
|
||||||
echo "${site_url}|${wp_dir}"
|
echo "${site_url}|${wp_dir}"
|
||||||
|
|||||||
Executable
+1087
File diff suppressed because it is too large
Load Diff
@@ -498,7 +498,9 @@ analyze_apache() {
|
|||||||
if [ -n "$apache_error_log" ]; then
|
if [ -n "$apache_error_log" ]; then
|
||||||
# Check for MaxRequestWorkers limit hits
|
# Check for MaxRequestWorkers limit hits
|
||||||
local max_workers_hits=$(grep -c "server reached MaxRequestWorkers" "$apache_error_log" 2>/dev/null || echo "0")
|
local max_workers_hits=$(grep -c "server reached MaxRequestWorkers" "$apache_error_log" 2>/dev/null || echo "0")
|
||||||
if [ "$max_workers_hits" -gt 20 ]; then
|
max_workers_hits=$(echo "$max_workers_hits" | tr -d '\n\r' | grep -o '[0-9]*' | head -1)
|
||||||
|
max_workers_hits=${max_workers_hits:-0}
|
||||||
|
if [ "$max_workers_hits" -gt 20 ] 2>/dev/null; then
|
||||||
add_issue "CRITICAL" "APACHE - MaxRequestWorkers limit hit frequently" \
|
add_issue "CRITICAL" "APACHE - MaxRequestWorkers limit hit frequently" \
|
||||||
"Server reached MaxRequestWorkers limit ${max_workers_hits} times
|
"Server reached MaxRequestWorkers limit ${max_workers_hits} times
|
||||||
This causes connection refusal and 'server busy' errors" \
|
This causes connection refusal and 'server busy' errors" \
|
||||||
@@ -506,7 +508,7 @@ This causes connection refusal and 'server busy' errors" \
|
|||||||
OR investigate slow PHP scripts / database queries causing workers to hang
|
OR investigate slow PHP scripts / database queries causing workers to hang
|
||||||
Check: apachectl -M | grep mpm" \
|
Check: apachectl -M | grep mpm" \
|
||||||
88
|
88
|
||||||
elif [ "$max_workers_hits" -gt 5 ]; then
|
elif [ "$max_workers_hits" -gt 5 ] 2>/dev/null; then
|
||||||
add_issue "HIGH" "APACHE - MaxRequestWorkers limit reached" \
|
add_issue "HIGH" "APACHE - MaxRequestWorkers limit reached" \
|
||||||
"Limit hit ${max_workers_hits} times" \
|
"Limit hit ${max_workers_hits} times" \
|
||||||
"Monitor and consider increasing MaxRequestWorkers." \
|
"Monitor and consider increasing MaxRequestWorkers." \
|
||||||
@@ -515,7 +517,9 @@ Check: apachectl -M | grep mpm" \
|
|||||||
|
|
||||||
# Check for segfaults
|
# Check for segfaults
|
||||||
local segfaults=$(grep -c "segfault" "$apache_error_log" 2>/dev/null || echo "0")
|
local segfaults=$(grep -c "segfault" "$apache_error_log" 2>/dev/null || echo "0")
|
||||||
if [ "$segfaults" -gt 0 ]; then
|
segfaults=$(echo "$segfaults" | tr -d '\n\r' | grep -o '[0-9]*' | head -1)
|
||||||
|
segfaults=${segfaults:-0}
|
||||||
|
if [ "$segfaults" -gt 0 ] 2>/dev/null; then
|
||||||
add_issue "HIGH" "APACHE - Segmentation faults detected" \
|
add_issue "HIGH" "APACHE - Segmentation faults detected" \
|
||||||
"Found ${segfaults} segfault events
|
"Found ${segfaults} segfault events
|
||||||
May indicate corrupted modules or memory issues" \
|
May indicate corrupted modules or memory issues" \
|
||||||
@@ -808,8 +812,12 @@ New connections may be dropped" \
|
|||||||
|
|
||||||
# Check for TCP retransmissions
|
# Check for TCP retransmissions
|
||||||
local tcp_retrans=$(netstat -s 2>/dev/null | grep "segments retransmitted" | awk '{print $1}' || echo "0")
|
local tcp_retrans=$(netstat -s 2>/dev/null | grep "segments retransmitted" | awk '{print $1}' || echo "0")
|
||||||
|
tcp_retrans=$(echo "$tcp_retrans" | tr -d '\n\r' | grep -o '[0-9]*' | head -1)
|
||||||
|
tcp_retrans=${tcp_retrans:-0}
|
||||||
local tcp_out=$(netstat -s 2>/dev/null | grep "segments sent out" | awk '{print $1}' || echo "1")
|
local tcp_out=$(netstat -s 2>/dev/null | grep "segments sent out" | awk '{print $1}' || echo "1")
|
||||||
if [ "$tcp_out" -gt 1000000 ]; then
|
tcp_out=$(echo "$tcp_out" | tr -d '\n\r' | grep -o '[0-9]*' | head -1)
|
||||||
|
tcp_out=${tcp_out:-1}
|
||||||
|
if [ "$tcp_out" -gt 1000000 ] 2>/dev/null; then
|
||||||
local retrans_percent=$(echo "scale=2; $tcp_retrans * 100 / $tcp_out" | bc 2>/dev/null || echo "0")
|
local retrans_percent=$(echo "scale=2; $tcp_retrans * 100 / $tcp_out" | bc 2>/dev/null || echo "0")
|
||||||
if (( $(echo "$retrans_percent > 5" | bc -l 2>/dev/null) )); then
|
if (( $(echo "$retrans_percent > 5" | bc -l 2>/dev/null) )); then
|
||||||
# Get current MTU
|
# Get current MTU
|
||||||
@@ -1667,9 +1675,13 @@ save_health_baseline() {
|
|||||||
local network_interface=$(ip route | grep default | awk '{print $5}' | head -1)
|
local network_interface=$(ip route | grep default | awk '{print $5}' | head -1)
|
||||||
local network_mtu=$(ip link show "$network_interface" 2>/dev/null | grep mtu | awk '{print $5}' || echo "unknown")
|
local network_mtu=$(ip link show "$network_interface" 2>/dev/null | grep mtu | awk '{print $5}' || echo "unknown")
|
||||||
local tcp_retrans=$(netstat -s 2>/dev/null | grep "segments retransmitted" | awk '{print $1}' || echo "0")
|
local tcp_retrans=$(netstat -s 2>/dev/null | grep "segments retransmitted" | awk '{print $1}' || echo "0")
|
||||||
|
tcp_retrans=$(echo "$tcp_retrans" | tr -d '\n\r' | grep -o '[0-9]*' | head -1)
|
||||||
|
tcp_retrans=${tcp_retrans:-0}
|
||||||
local tcp_out=$(netstat -s 2>/dev/null | grep "segments sent out" | awk '{print $1}' || echo "1")
|
local tcp_out=$(netstat -s 2>/dev/null | grep "segments sent out" | awk '{print $1}' || echo "1")
|
||||||
|
tcp_out=$(echo "$tcp_out" | tr -d '\n\r' | grep -o '[0-9]*' | head -1)
|
||||||
|
tcp_out=${tcp_out:-1}
|
||||||
local tcp_retrans_percent="0"
|
local tcp_retrans_percent="0"
|
||||||
if [ "$tcp_out" -gt 1000000 ]; then
|
if [ "$tcp_out" -gt 1000000 ] 2>/dev/null; then
|
||||||
tcp_retrans_percent=$(echo "scale=2; $tcp_retrans * 100 / $tcp_out" | bc 2>/dev/null || echo "0")
|
tcp_retrans_percent=$(echo "scale=2; $tcp_retrans * 100 / $tcp_out" | bc 2>/dev/null || echo "0")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -390,11 +390,13 @@ generate_full_report() {
|
|||||||
|
|
||||||
# Critical issues
|
# Critical issues
|
||||||
local critical_count=$(grep -c "^PROBLEM" "$problems_file" 2>/dev/null || echo 0)
|
local critical_count=$(grep -c "^PROBLEM" "$problems_file" 2>/dev/null || echo 0)
|
||||||
|
critical_count=$(echo "$critical_count" | tr -d '\n\r' | grep -o '[0-9]*' | head -1)
|
||||||
|
critical_count=${critical_count:-0}
|
||||||
|
|
||||||
print_section "CRITICAL ISSUES: $critical_count found"
|
print_section "CRITICAL ISSUES: $critical_count found"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
if [ "$critical_count" -gt 0 ]; then
|
if [ "$critical_count" -gt 0 ] 2>/dev/null; then
|
||||||
grep "^PROBLEM" "$problems_file" | nl | while read num type domain owner db plugin table issue query_time query; do
|
grep "^PROBLEM" "$problems_file" | nl | while read num type domain owner db plugin table issue query_time query; do
|
||||||
echo -e "${RED}[$num] $plugin on $domain${NC}"
|
echo -e "${RED}[$num] $plugin on $domain${NC}"
|
||||||
echo " Database: $db"
|
echo " Database: $db"
|
||||||
|
|||||||
@@ -301,11 +301,19 @@ parse_logs() {
|
|||||||
local log_search_path
|
local log_search_path
|
||||||
local log_search_name
|
local log_search_name
|
||||||
if [ "$INTERWORX_MODE" = "yes" ]; then
|
if [ "$INTERWORX_MODE" = "yes" ]; then
|
||||||
# InterWorx: /home/user/var/domain.com/logs/transfer.log (VERIFIED: uses 'transfer.log' not 'access_log')
|
# InterWorx: Official docs from https://appendix.interworx.com/current/nodeworx/general/other/log-file-locations.html
|
||||||
|
# HTTP: /home/{user}/var/{domain}/logs/transfer.log
|
||||||
|
# HTTPS: /home/{user}/var/{domain}/logs/transfer-ssl.log
|
||||||
log_search_path="/home/*/var/*/logs"
|
log_search_path="/home/*/var/*/logs"
|
||||||
log_search_name="transfer.log"
|
log_search_name="transfer*.log"
|
||||||
else
|
else
|
||||||
# cPanel/Plesk: /var/log/apache2/domlogs/domain.com
|
# cPanel: /var/log/apache2/domlogs/domain.com or domain.com-ssl_log
|
||||||
|
# Plesk: Research verified paths from https://docs.plesk.com/en-US/obsidian/
|
||||||
|
# Apache HTTP: /var/www/vhosts/system/{domain}/logs/access_log
|
||||||
|
# Apache HTTPS: /var/www/vhosts/system/{domain}/logs/access_ssl_log
|
||||||
|
# nginx HTTP: /var/www/vhosts/system/{domain}/logs/proxy_access_log
|
||||||
|
# nginx HTTPS: /var/www/vhosts/system/{domain}/logs/proxy_access_ssl_log
|
||||||
|
# Note: /var/www/vhosts/{domain}/logs/ are hardlinks (backward compat)
|
||||||
log_search_path="$LOG_DIR"
|
log_search_path="$LOG_DIR"
|
||||||
log_search_name="*"
|
log_search_name="*"
|
||||||
fi
|
fi
|
||||||
@@ -320,10 +328,13 @@ parse_logs() {
|
|||||||
|
|
||||||
# Extract domain name based on control panel
|
# Extract domain name based on control panel
|
||||||
if [ "$INTERWORX_MODE" = "yes" ]; then
|
if [ "$INTERWORX_MODE" = "yes" ]; then
|
||||||
# InterWorx: extract from path /home/user/var/domain.com/logs/transfer.log
|
# InterWorx: extract from path /home/user/var/domain.com/logs/transfer*.log
|
||||||
domain=$(echo "$logfile" | sed -n 's|^/home/.*/var/\([^/]*\)/logs/.*|\1|p')
|
domain=$(echo "$logfile" | sed -n 's|^/home/.*/var/\([^/]*\)/logs/.*|\1|p')
|
||||||
|
elif [ "$SYS_CONTROL_PANEL" = "plesk" ]; then
|
||||||
|
# Plesk: extract from path /var/www/vhosts/system/domain.com/logs/{access_log,access_ssl_log,proxy_*}
|
||||||
|
domain=$(echo "$logfile" | sed -n 's|^/var/www/vhosts/system/\([^/]*\)/logs/.*|\1|p')
|
||||||
else
|
else
|
||||||
# cPanel: extract from filename
|
# cPanel: extract from filename /var/log/apache2/domlogs/domain.com or domain.com-ssl_log
|
||||||
domain=$(basename "$logfile" | sed 's/-ssl_log$//')
|
domain=$(basename "$logfile" | sed 's/-ssl_log$//')
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -1805,17 +1816,41 @@ main() {
|
|||||||
find_opts+=(-mtime -"$DAYS_BACK")
|
find_opts+=(-mtime -"$DAYS_BACK")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Find all transfer.log files in InterWorx structure
|
# Find all transfer*.log files in InterWorx structure (includes transfer.log and transfer-ssl.log)
|
||||||
log_count=$(find /home/*/var/*/logs -type f -name "transfer.log" "${find_opts[@]}" 2>/dev/null | wc -l)
|
log_count=$(find /home/*/var/*/logs -type f -name "transfer*.log" "${find_opts[@]}" 2>/dev/null | wc -l)
|
||||||
|
|
||||||
if [ "$log_count" -eq 0 ]; then
|
if [ "$log_count" -eq 0 ]; then
|
||||||
print_alert "Error: No InterWorx access logs found in /home/*/var/*/logs/"
|
# Try without time filter to see if ANY logs exist
|
||||||
if [ -n "$HOURS_BACK" ]; then
|
local total_logs=$(find /home/*/var/*/logs -type f -name "transfer*.log" 2>/dev/null | wc -l)
|
||||||
echo "No logs found from the last $HOURS_BACK hours"
|
|
||||||
elif [ -n "$DAYS_BACK" ]; then
|
if [ "$total_logs" -eq 0 ]; then
|
||||||
echo "No logs found from the last $DAYS_BACK days"
|
print_alert "Error: No InterWorx access logs found in /home/*/var/*/logs/"
|
||||||
|
echo ""
|
||||||
|
echo "Diagnostic information:"
|
||||||
|
echo " Checking for InterWorx structure:"
|
||||||
|
local iw_structure=$(find /home -maxdepth 3 -type d -path "*/var/*/logs" 2>/dev/null | head -5)
|
||||||
|
if [ -n "$iw_structure" ]; then
|
||||||
|
echo " Found InterWorx directories:"
|
||||||
|
echo "$iw_structure"
|
||||||
|
echo ""
|
||||||
|
echo " Checking for any log files:"
|
||||||
|
find /home/*/var/*/logs -type f -name "*.log" 2>/dev/null | head -10
|
||||||
|
else
|
||||||
|
echo " No InterWorx directory structure found (expected: /home/user/var/domain.com/logs/)"
|
||||||
|
fi
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
print_alert "No logs found matching time filter (last $HOURS_BACK hours)"
|
||||||
|
echo "Total logs available: $total_logs"
|
||||||
|
echo ""
|
||||||
|
read -p "Analyze all available logs instead? [y/N]: " choice
|
||||||
|
if [[ "$choice" =~ ^[Yy] ]]; then
|
||||||
|
log_count=$total_logs
|
||||||
|
find_opts=() # Clear time filter
|
||||||
|
else
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
print_info "Found $log_count InterWorx domain log files to analyze"
|
print_info "Found $log_count InterWorx domain log files to analyze"
|
||||||
@@ -1843,13 +1878,40 @@ main() {
|
|||||||
|
|
||||||
log_count=$(find "$LOG_DIR" -type f ! -name "*-bytes_log" ! -name "*.offset" ! -name "*error_log" "${find_opts[@]}" 2>/dev/null | wc -l)
|
log_count=$(find "$LOG_DIR" -type f ! -name "*-bytes_log" ! -name "*.offset" ! -name "*error_log" "${find_opts[@]}" 2>/dev/null | wc -l)
|
||||||
if [ "$log_count" -eq 0 ]; then
|
if [ "$log_count" -eq 0 ]; then
|
||||||
print_alert "Error: No log files found in $LOG_DIR"
|
# Try without time filter to see if ANY logs exist
|
||||||
if [ -n "$HOURS_BACK" ]; then
|
local total_logs=$(find "$LOG_DIR" -type f ! -name "*-bytes_log" ! -name "*.offset" ! -name "*error_log" 2>/dev/null | wc -l)
|
||||||
echo "No logs found from the last $HOURS_BACK hours"
|
|
||||||
elif [ -n "$DAYS_BACK" ]; then
|
if [ "$total_logs" -eq 0 ]; then
|
||||||
echo "No logs found from the last $DAYS_BACK days"
|
print_alert "Error: No log files found in $LOG_DIR"
|
||||||
|
echo ""
|
||||||
|
echo "Diagnostic information:"
|
||||||
|
echo " Log directory: $LOG_DIR"
|
||||||
|
echo " Directory exists: $([ -d "$LOG_DIR" ] && echo "yes" || echo "no")"
|
||||||
|
if [ -d "$LOG_DIR" ]; then
|
||||||
|
echo " Total files in directory: $(find "$LOG_DIR" -type f 2>/dev/null | wc -l)"
|
||||||
|
echo " Sample files:"
|
||||||
|
find "$LOG_DIR" -type f 2>/dev/null | head -5 | sed 's/^/ /'
|
||||||
|
fi
|
||||||
|
echo ""
|
||||||
|
echo "Control panel: $SYS_CONTROL_PANEL"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
print_alert "No logs found matching time filter"
|
||||||
|
if [ -n "$HOURS_BACK" ]; then
|
||||||
|
echo "No logs found from the last $HOURS_BACK hours"
|
||||||
|
elif [ -n "$DAYS_BACK" ]; then
|
||||||
|
echo "No logs found from the last $DAYS_BACK days"
|
||||||
|
fi
|
||||||
|
echo "Total logs available: $total_logs"
|
||||||
|
echo ""
|
||||||
|
read -p "Analyze all available logs instead? [y/N]: " choice
|
||||||
|
if [[ "$choice" =~ ^[Yy] ]]; then
|
||||||
|
log_count=$total_logs
|
||||||
|
find_opts=() # Clear time filter
|
||||||
|
else
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
print_info "Found $log_count log files to analyze"
|
print_info "Found $log_count log files to analyze"
|
||||||
|
|||||||
Reference in New Issue
Block a user