统计tcp连接状态数量
#!/usr/bin/bash
#count tcp status
#by racon 2022-04-22
while :
do
unset status
declare -A status
type=`ss -an| grep :80 | awk '{print $2}'`
for i in $type
do
let status[$i]++
done
for j in ${!status[@]}
do
echo "$j: ${status[$j]}"
done
sleep 1;clear
done
也可以不用while循环,通过watch -n1 ./count_tcp_status.sh来监视变化