sed -n '/^ local w_peer/,/^function cmd::/p' \ /etc/wireguard/wgctl/commands/activity.command.sh | head -60 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 exact column where drop count starts on peer row: # " " (2) + name (w_peer) + " ↓" (3) + rx (10) + " ↑" (3) + tx (10) + " " (2) # Note: ↓ and ↑ are multi-byte (3 bytes) but display as 1 char — account for 2 extra bytes each # Visible: 2 + w_peer + 2+1 + 10 + 2+1 + 10 + 2 = w_peer + 30 local drops_col=$(( w_peer + 30 )) local hours_display="${hours}h" [[ "$hours" == "0" ]] && hours_display="all time" log::section "Activity Monitor (last ${hours_display})" echo "" local first_peer=true skip_peer=false while IFS='|' read -r record_type rest; do case "$record_type" in peer) local name rx tx drops IFS='|' read -r name rx tx drops <<< "$rest" skip_peer=false if $dropped_only && [[ "$drops" -eq 0 ]]; then skip_peer=true continue fi $first_peer || echo "" first_peer=false local rx_fmt tx_fmt rx_fmt=$(cmd::activity::_fmt_bytes "$rx") tx_fmt=$(cmd::activity::_fmt_bytes "$tx") local name_pad rx_pad tx_pad name_pad=$(printf "%-${w_peer}s" "$name") rx_pad=$(printf "%-10s" "$rx_fmt") tx_pad=$(printf "%-10s" "$tx_fmt") local drop_word="drops" [[ "$drops" -eq 1 ]] && drop_word="drop"