How do I view the number of connections to Apache and the current number of connections

  • 2020-05-07 20:49:01
  • OfStack

Looked at the number of connections and the current number of connections
 
netstat -ant | grep $ip:80 | wc -l 
netstat -ant | grep $ip:80 | grep EST | wc -l 

View the number of IP visits
 
netstat -nat|grep ":80"|awk '{print $5}' |awk -F: '{print $1}' | sort| uniq -c|sort -n 

Linux command:
 
netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}' 
watch "netstat -n | awk '/^tcp/ {++S[\$NF]} END {for(a in S) print a, S[a]}'" 

Sample results returned:
LAST_ACK 5
SYN_RECV 30
ESTABLISHED 1597
FIN_WAIT1 51
FIN_WAIT2 504
TIME_WAIT 1057

Description:
SYN_RECV represents the number of requests waiting to be processed;
ESTABLISHED represents the normal data transmission state;
TIME_WAIT represents the number of requests that have been processed and are waiting for the end of the timeout;
FIN_WAIT1 means that the server end voluntarily requests to close the tcp connection;
FIN_WAIT2 means the client ends the connection;
LAST_ACK closed 1 TCP connection closed from both directions respectively, the two sides are closed by a single direction data by sending FIN, when both sides of communication to send the last one FIN, sender LAST_ACK at this point, when the sender receives confirmation (Fin Ack confirmation) after shutting down the complete real TCP connection;

Related articles: