Add traffic-based prioritization to batch analyzer

- Sort domains by priority: high-traffic optimization > low-traffic optimization > optimized
- Display traffic indicators: CRITICAL (20+), HIGH (10+), MEDIUM (5+), LOW (<5)
- Helps users focus on domains that matter most (high-traffic + need optimization)
- Uses color coding to make traffic levels visually obvious
- Includes peak concurrent request count in traffic indicator
- Makes it easy to identify which domains to optimize first

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
cschantz
2026-02-17 23:07:17 -05:00
parent f40634428c
commit af5a2e9968
+60 -5
View File
@@ -147,12 +147,51 @@ while IFS= read -r username; do
done <<< "$users" done <<< "$users"
# ============================================================================ # ============================================================================
# DISPLAY RESULTS # DISPLAY RESULTS (Prioritized by Traffic)
# ============================================================================ # ============================================================================
# Sort and display domains # Build sortable list with priority (traffic-based)
OPTIMIZATION_COUNT=0 echo "Building prioritized analysis..." >&2
declare -a sorted_indices
declare -a domain_sort_data
for idx in $(seq 1 $TOTAL_DOMAINS); do 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]}" domain="${domain_list[$idx]}"
owner="${domain_owner[$idx]}" owner="${domain_owner[$idx]}"
current="${current_max_children[$idx]}" current="${current_max_children[$idx]}"
@@ -165,11 +204,27 @@ for idx in $(seq 1 $TOTAL_DOMAINS); do
continue continue
fi 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 # Format output
if [ "$optimize" == "YES" ]; then if [ "$optimize" == "YES" ]; then
cecho "${YELLOW}[$idx]${NC} $domain" cecho "${YELLOW}[$idx]${NC} $domain"
cecho " Owner: $owner" 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 " Current max_children: ${RED}$current${NC} → Recommended: ${GREEN}$recommended${NC}"
cecho " Memory impact: ${GREEN}+${impact}MB${NC} if optimized" cecho " Memory impact: ${GREEN}+${impact}MB${NC} if optimized"
cecho " Status: ${YELLOW}NEEDS OPTIMIZATION${NC}" cecho " Status: ${YELLOW}NEEDS OPTIMIZATION${NC}"
@@ -177,7 +232,7 @@ for idx in $(seq 1 $TOTAL_DOMAINS); do
else else
cecho "${GREEN}[$idx]${NC} $domain" cecho "${GREEN}[$idx]${NC} $domain"
cecho " Owner: $owner" cecho " Owner: $owner"
cecho " Peak concurrent requests: ${WHITE}$peak${NC}" cecho " Traffic: $traffic_indicator"
cecho " max_children: $current (already optimized)" cecho " max_children: $current (already optimized)"
cecho " Status: ${GREEN}OK${NC}" cecho " Status: ${GREEN}OK${NC}"
fi fi