(summary) View the concurrent connections and connection status of Nginx Apache MySQL under Linux

Source: Internet
Author: User

1. View the number of concurrent requests for 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]}‘

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

The returned results are generally as follows:

Last_ack 5 (number of requests waiting to be processed)
SYN_RECV 30
Established 1597 (normal data transfer status, can be understood as close to the number of concurrent connections)
Fin_wait1 51
Fin_wait2 504
Time_wait 1057 (number of requests processed, waiting for timeout to end)

Additional parameter Description:

closed: No connection is active or in progress

SYN_RECV: A connection request has arrived, wait for confirmation
syn_sent: Application has started, open a connection
FIN_WAIT1: Application says it has completed
itmed_wait: Waits for all groups to die
closing: Both sides simultaneously try to close
time_ Wait: The other side has initialized a release
last_ack: Wait for all groups to die

2. View the number of nginx concurrent processes
ps -ef | grep nginx | wc -l
The number returned is Nginx is not the number of processes, if Apache is executed
ps -ef | grep httpd | wc -l

You can also use the following command:
watch -n 1 -d "pgrep nginx|wc -l"

3. View the number of Web server process connections:
netstat -antp | grep 80 | grep ESTABLISHED -c

4. View the number of MySQL process connections:
ps -axef | grep mysqld -c

(summary) View the concurrent connections and connection status of Nginx Apache MySQL under Linux

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.