View the number of concurrent http and tcp connections under linux

linux check the number of httpd processes

ps -ef | grep httpd | wc -l

check the number of concurrent requests of Apache and its TCP connection status

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

(this statement is obtained from Mr. Wang, Technical Director of Sina Interactive Community Division, which is very good)

Example of returned result:

LAST_ACK 5
SYN_RECV 30
ESTABLISHED 1597
FIN_WAIT1 51
FIN_WAIT2 504
TIME_WAIT 1057

Among them, SYN_RECV indicates the number of requests waiting to be processed; ESTABLISHED indicates the normal data transmission status; TIME_WAIT indicates the number of requests that are processed and waiting for the timeout to end.

Source http://blog.s135.com/post/269/
Check the number of concurrent connections in linux
1. Check the number of concurrent requests of the Web server (Nginx Apache) and its TCP connection status:

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

netstat -n|grep ^tcp|awk '{print $NF}'|sort -nr|uniq -c

or :

netstat -n | awk '/^tcp/ {++state[$NF]} END {for(key in state) print key,"t",state[key]}'

The return result is generally as follows:

LAST_ACK 5 (waiting for Number of requests processed)
SYN_RECV 30
ESTABLISHED 1597 (normal data transfer status)
FIN_WAIT1 51
FIN_WAIT2 504
TIME_WAIT 1057 (number of requests processed, waiting for the timeout to end)

Other parameter descriptions:

CLOSED: No connection is active or in progress
LISTEN: The server is in waiting for incoming call
SYN_RECV: a connection request has arrived ,
waiting for confirmation : Both sides try to close TIME_WAIT at the same time: The other side has initialized a release LAST_ACK: Waiting for all groups to die 2. Check the number of Nginx running processes ps -ef | grep nginx | ​​wc -l The number returned is the number of running processes of nginx, if it is apache then execute














ps -ef | grep httpd | wc -l

3. Check the number of web server process connections:

netstat -antp | grep 80 | grep ESTABLISHED -c

4. Check the number of MySQL process connections:

ps -axef | grep mysqld -c

Source http:/ /itnihao.blog.51cto.com/1741976/830365

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326342886&siteId=291194637