Block IP having more than 50 connections using netstat

Block IP having more than 50 connections using netstat
For CSF firewall :

$ netstat -apln |grep :80 | awk ‘{print $5}’| cut -d “:” -f1|sort -n | uniq -c | sort -n | awk ‘{if ( $1 > 50 ) print $2}’ | xargs csf -d

For APF firewall :

$ netstat -apln |grep :80 | awk ‘{print $5}’| cut -d “:” -f1|sort -n | uniq -c | sort -n | awk ‘{if ( $1 > 50 ) print $2}’ | xargs apf -d