CentOS View Apache,nginx concurrent connections and TCP connection status commands

Source: Internet
Author: User
Tags centos

Netstat command and awk to view the number of concurrent connections to the Web server and the TCP connection status.

The code is as follows Copy Code

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) print key, "T", State[key]} '

Fin_wait2 38
CLOSING 3
SYN_RECV 1
Close_wait 1
Time_wait 261
Established 71
Last_ack 2
Fin_wait1 9

Each state meaning of a TCP connection is described as follows

CLOSED no connection is active or in progress
LISTEN server waiting for incoming call
SYN_RECV A connection request has arrived, waiting for confirmation
Syn_sent application already started, open a connection
Established normal data transfer status/current concurrent connection number
FIN_WAIT1 application says it's done
Fin_wait2 the other side has agreed to release
Itmed_wait waiting for all the groupings to die.
CLOSING Both sides try to close both
Time_wait the other side has initialized a release
Last_ack waiting for all the groupings to die.
The value after the established parameter is the number of concurrent connections for the current system.

To view the number of Nginx run processes

The code is as follows Copy Code

Ps-ef | grep Nginx | The number that Wc-l returns is the number of nginx running processes, and if it is Apache, execute
Ps-ef | grep httpd | WC-L3, view the number of Web server process connections:

NETSTAT-ANTP | grep 80 | grep established-c4, view the number of MySQL process connections:

Ps-axef | grep mysqld-c


To view the number of Web server process connections:

NETSTAT-ANTP | grep 80 | grep established-c

To view the number of MySQL process connections:

Ps-axef | grep mysqld-c

Add

To view the current number of Apache connections:

  code is as follows copy code

Ps-ef |grep Httpd|wc-l
or Ps-aux |grep httpd |wc-l

View current number of Apache concurrent connections and TCP connection status:

Netstat-n | awk '/^tcp/{++s[$NF]} end {for (A in S) print A, s[a]} '

View number of connections and connection status:

Netstat-ant|grep $ip: 80|wc-l
netstat-ant|grep $ip: est|wc-l

View Tomcat current connection status:

Netstat-anlt|grep 8009|grep established
netsat-ant |grep 8009|wc-l

View MySQL Current Number of connections:

Mysqladmin-umysql-pmysql static
Mysqladmin-umysql-pmysql processlist

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.