Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| af5a2e9968 | |||
| f40634428c |
@@ -147,12 +147,51 @@ while IFS= read -r username; do
|
||||
done <<< "$users"
|
||||
|
||||
# ============================================================================
|
||||
# DISPLAY RESULTS
|
||||
# DISPLAY RESULTS (Prioritized by Traffic)
|
||||
# ============================================================================
|
||||
|
||||
# Sort and display domains
|
||||
OPTIMIZATION_COUNT=0
|
||||
# Build sortable list with priority (traffic-based)
|
||||
echo "Building prioritized analysis..." >&2
|
||||
|
||||
declare -a sorted_indices
|
||||
declare -a domain_sort_data
|
||||
|
||||
for idx in $(seq 1 $TOTAL_DOMAINS); do
|
||||
domain="${domain_list[$idx]}"
|
||||
peak="${peak_concurrent[$idx]}"
|
||||
optimize="${needs_optimization[$idx]}"
|
||||
|
||||
if [ "$peak" == "?" ]; then
|
||||
peak=0
|
||||
fi
|
||||
|
||||
# Create sort key: prioritize domains needing optimization with high traffic
|
||||
if [ "$optimize" == "YES" ]; then
|
||||
# High priority: domains needing optimization with traffic >= 5
|
||||
if [[ "$peak" =~ ^[0-9]+$ ]] && [ "$peak" -ge 5 ]; then
|
||||
sort_priority="0" # Highest priority
|
||||
else
|
||||
sort_priority="1" # Medium priority (needs optimization, low traffic)
|
||||
fi
|
||||
else
|
||||
sort_priority="2" # Low priority (already optimized)
|
||||
fi
|
||||
|
||||
domain_sort_data+=("$sort_priority|$peak|$idx")
|
||||
done
|
||||
|
||||
# Sort by priority then by peak concurrent requests (descending)
|
||||
mapfile -t sorted_data < <(printf '%s\n' "${domain_sort_data[@]}" | sort -t'|' -k1,1 -k2,2nr)
|
||||
|
||||
# Extract sorted indices
|
||||
for sort_entry in "${sorted_data[@]}"; do
|
||||
idx=$(echo "$sort_entry" | cut -d'|' -f3)
|
||||
sorted_indices+=("$idx")
|
||||
done
|
||||
|
||||
# Sort and display domains (prioritized)
|
||||
OPTIMIZATION_COUNT=0
|
||||
for idx in "${sorted_indices[@]}"; do
|
||||
domain="${domain_list[$idx]}"
|
||||
owner="${domain_owner[$idx]}"
|
||||
current="${current_max_children[$idx]}"
|
||||
@@ -165,11 +204,27 @@ for idx in $(seq 1 $TOTAL_DOMAINS); do
|
||||
continue
|
||||
fi
|
||||
|
||||
# Determine traffic indicator
|
||||
local traffic_indicator=""
|
||||
if [[ "$peak" =~ ^[0-9]+$ ]]; then
|
||||
if [ "$peak" -ge 20 ]; then
|
||||
traffic_indicator="${RED}⚠ CRITICAL TRAFFIC (${peak})${NC}"
|
||||
elif [ "$peak" -ge 10 ]; then
|
||||
traffic_indicator="${YELLOW}⚠ HIGH TRAFFIC (${peak})${NC}"
|
||||
elif [ "$peak" -ge 5 ]; then
|
||||
traffic_indicator="${CYAN}→ MEDIUM TRAFFIC (${peak})${NC}"
|
||||
else
|
||||
traffic_indicator="${WHITE}○ LOW TRAFFIC (${peak})${NC}"
|
||||
fi
|
||||
else
|
||||
traffic_indicator="${WHITE}○ TRAFFIC UNKNOWN${NC}"
|
||||
fi
|
||||
|
||||
# Format output
|
||||
if [ "$optimize" == "YES" ]; then
|
||||
cecho "${YELLOW}[$idx]${NC} $domain"
|
||||
cecho " Owner: $owner"
|
||||
cecho " Peak concurrent requests: ${WHITE}$peak${NC}"
|
||||
cecho " Traffic: $traffic_indicator"
|
||||
cecho " Current max_children: ${RED}$current${NC} → Recommended: ${GREEN}$recommended${NC}"
|
||||
cecho " Memory impact: ${GREEN}+${impact}MB${NC} if optimized"
|
||||
cecho " Status: ${YELLOW}NEEDS OPTIMIZATION${NC}"
|
||||
@@ -177,7 +232,7 @@ for idx in $(seq 1 $TOTAL_DOMAINS); do
|
||||
else
|
||||
cecho "${GREEN}[$idx]${NC} $domain"
|
||||
cecho " Owner: $owner"
|
||||
cecho " Peak concurrent requests: ${WHITE}$peak${NC}"
|
||||
cecho " Traffic: $traffic_indicator"
|
||||
cecho " max_children: $current (already optimized)"
|
||||
cecho " Status: ${GREEN}OK${NC}"
|
||||
fi
|
||||
|
||||
@@ -79,6 +79,25 @@ select_domain() {
|
||||
cecho "${WHITE}${BOLD}SELECT DOMAIN${NC}"
|
||||
echo ""
|
||||
|
||||
# Ask about filtering
|
||||
cecho "${CYAN}Filter options:${NC}"
|
||||
cecho " ${GREEN}n${NC}) No filter (show all)"
|
||||
cecho " ${GREEN}s${NC}) Search by name"
|
||||
cecho " ${GREEN}t${NC}) Show high-traffic domains"
|
||||
cecho " ${GREEN}o${NC}) Show domains needing optimization"
|
||||
cecho " ${RED}q${NC}) Cancel"
|
||||
echo ""
|
||||
cecho "${CYAN}─────────────────────────────────────────────────────────────────────${NC}"
|
||||
|
||||
read -p "Select filter: " filter_choice
|
||||
filter_choice=$(echo "${filter_choice,,}")
|
||||
|
||||
case "$filter_choice" in
|
||||
q)
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# Get all users with domains
|
||||
local users
|
||||
users=$(list_all_users)
|
||||
@@ -110,12 +129,59 @@ select_domain() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Apply filters
|
||||
declare -a filtered_domains
|
||||
|
||||
case "$filter_choice" in
|
||||
s)
|
||||
# Search by name
|
||||
echo ""
|
||||
read -p "Search pattern: " search_pattern
|
||||
for domain in "${domains[@]}"; do
|
||||
if [[ "$domain" =~ $search_pattern ]]; then
|
||||
filtered_domains+=("$domain")
|
||||
fi
|
||||
done
|
||||
;;
|
||||
t)
|
||||
# High-traffic domains
|
||||
for domain in "${domains[@]}"; do
|
||||
local peak=$(get_domain_peak_concurrent "$domain" 2>/dev/null || echo "0")
|
||||
if [[ "$peak" =~ ^[0-9]+$ ]] && [ "$peak" -ge 10 ]; then
|
||||
filtered_domains+=("$domain")
|
||||
fi
|
||||
done
|
||||
# Sort by peak traffic (highest first)
|
||||
;;
|
||||
o)
|
||||
# Domains needing optimization
|
||||
for domain in "${domains[@]}"; do
|
||||
local username="${domain_to_user[$domain]}"
|
||||
local issues=$(detect_php_config_issues "$username" "$domain" 2>/dev/null || echo "NONE|NONE|None")
|
||||
local has_high_issues=$(echo "$issues" | grep -cE "^[^|]*\|(CRITICAL|HIGH)\|" 2>/dev/null || echo "0")
|
||||
if [ "$has_high_issues" -gt 0 ]; then
|
||||
filtered_domains+=("$domain")
|
||||
fi
|
||||
done
|
||||
;;
|
||||
*)
|
||||
# No filter
|
||||
filtered_domains=("${domains[@]}")
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ ${#filtered_domains[@]} -eq 0 ]; then
|
||||
cecho "${YELLOW}No domains match filter criteria${NC}"
|
||||
read -p "Press Enter to continue..."
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Display numbered list with optimization status
|
||||
cecho "${CYAN}Available domains:${NC}"
|
||||
echo ""
|
||||
|
||||
local index=1
|
||||
for domain in "${domains[@]}"; do
|
||||
for domain in "${filtered_domains[@]}"; do
|
||||
local username="${domain_to_user[$domain]}"
|
||||
local php_version
|
||||
php_version=$(detect_php_version_for_domain "$username" "$domain" 2>/dev/null || echo "unknown")
|
||||
@@ -135,7 +201,14 @@ select_domain() {
|
||||
fi
|
||||
fi
|
||||
|
||||
printf " ${GREEN}%-3d${NC}) %-40s ${CYAN}[${username}]${NC} ${YELLOW}(${php_version})${NC} %s\n" "$index" "$domain" "$(echo -e "$status_indicator")"
|
||||
# Show peak traffic if available
|
||||
local traffic_info=""
|
||||
local peak=$(get_domain_peak_concurrent "$domain" 2>/dev/null || echo "")
|
||||
if [ -n "$peak" ] && [ "$peak" != "?" ]; then
|
||||
traffic_info="${CYAN}(peak: ${peak})${NC} "
|
||||
fi
|
||||
|
||||
printf " ${GREEN}%-3d${NC}) %-40s ${CYAN}[${username}]${NC} ${YELLOW}(${php_version})${NC} %s%s\n" "$index" "$domain" "$(echo -e "$traffic_info")" "$(echo -e "$status_indicator")"
|
||||
index=$((index + 1))
|
||||
done
|
||||
|
||||
@@ -150,9 +223,9 @@ select_domain() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! [[ "$selection" =~ ^[0-9]+$ ]] || [ "$selection" -lt 1 ] || [ "$selection" -gt ${#domains[@]} ]; then
|
||||
if ! [[ "$selection" =~ ^[0-9]+$ ]] || [ "$selection" -lt 1 ] || [ "$selection" -gt ${#filtered_domains[@]} ]; then
|
||||
echo ""
|
||||
cecho "${RED}Invalid selection. Please enter a number 1-${#domains[@]}${NC}"
|
||||
cecho "${RED}Invalid selection. Please enter a number 1-${#filtered_domains[@]}${NC}"
|
||||
echo ""
|
||||
continue
|
||||
fi
|
||||
@@ -161,7 +234,7 @@ select_domain() {
|
||||
done
|
||||
|
||||
# Return selected domain and username
|
||||
local selected_domain="${domains[$((selection - 1))]}"
|
||||
local selected_domain="${filtered_domains[$((selection - 1))]}"
|
||||
local selected_user="${domain_to_user[$selected_domain]}"
|
||||
|
||||
echo "$selected_domain|$selected_user"
|
||||
|
||||
Reference in New Issue
Block a user