log::error "Service not found: ${filter_service}" return 1 fi fi [[ -n "$filter_ip" ]] && service_ip="$filter_ip" # Fetch aggregated data local data data=$(json::activity_aggregate \ "$(ctx::fw_events_log)" \ "$(ctx::events_log)" \ "$(config::interface)" \ "$(ctx::net)" \ "$(ctx::clients)" \ "$(ctx::meta)" \ "$hours" \ "$filter_peer" \ "$service_ip" 2>/dev/null) if [[ -z "$data" ]]; then log::wg_warning "No activity data found" return 0 fi # Measure column widths local w_peer=16 w_drops=1 while IFS='|' read -r type rest; do case "$type" in peer) local name drops name=$(echo "$rest" | cut -d'|' -f1) drops=$(echo "$rest" | cut -d'|' -f4) (( ${#name} > w_peer )) && w_peer=${#name} (( ${#drops} > w_drops )) && w_drops=${#drops} ;; service) local count count=$(echo "$rest" | cut -d'|' -f3) (( ${#count} > w_drops )) && w_drops=${#count} ;; esac done <<< "$data" (( w_peer += 2 )) # Compute column where drop count starts on peer row: # " " (2) + name (w_peer) + " ↓" (3) + rx (10) + " ↑" (3) + tx (10) + " " (2) # ↓ and ↑ are multi-byte (3 bytes, 1 visible) — 2 extra bytes each # Visible: 2 + w_peer + 2+1 + 10 + 2+1 + 10 + 2 = w_peer + 30 local drops_col=$(( w_peer + 30 ))