#!/bin/sh

echo "Most connections from (top 50):"
counts=$(ss -tunH | awk '{sub(/:[0-9]+$/,"",$6); print $6}' | sort | uniq -c | sort -nr | head -n 50)
echo "${counts}" | tr -d '[]'
echo ""

top_ip=$(echo "${counts}" | awk 'NR==1 {print $2}')
echo "Open connections from ${top_ip} (first 10):"
ss -tunp dst "${top_ip}" | head -n 10
echo ""

echo "Sockets summary:"
ss -s
