Linux netstat view 80-Port Connection Number Example

Source: Internet
Author: User

Some statistical data on the server:

1) Statistics 80 port connection number
Netstat-nat|grep-i "|wc-l"

2) Statistics HTTPD Protocol connection number
Ps-ef|grep httpd|wc-l

3), the statistics are connected, the status is "established
Netstat-na|grep established|wc-l

4), find out which IP address is the most connected, it closed.
Netstat-na|grep Established|awk {print $5}|awk-f: {print $1}|sort|uniq-c|sort-r +0n

Netstat-na|grep Syn|awk {print $5}|awk-f: {print $1}|sort|uniq-c|sort-r +0n

---------------------------------------------------------------------------------------------

1, view the current number of concurrent access Apache:
Netstat-an | grep established | Wc-l

Compare the difference in the number of maxclients in httpd.conf.

2. See how many processes there are:
PS Aux|grep httpd|wc-l

3, you can use the following parameters to view the data
Server-status?auto

#ps-ef|grep Httpd|wc-l
1388
Count the number of httpd processes, and even a request initiates a process for use with the Apache server.
Indicates that Apache can handle 1388 concurrent requests, which can be adjusted automatically according to the load.

#netstat-nat|grep-i "|wc-l"
4341
Netstat-an will print the current network link state of the system, and Grep-i "80" is used to extract connections related to 80 ports, wc-l count the number of connections.
The final number returned is the total number of requests currently on all 80 ports.

#netstat-na|grep Established|wc-l
376
Netstat-an Prints the current network link state of the system, and grep established extracts the information that has been established for the connection. Then wc-l statistics.
The final number returned is the total number of established connections for all 80 ports currently.

netstat-nat| | grep ESTABLISHED|WC-To view detailed records of all established connections

View the number of concurrent requests for Apache and its TCP connection status:
Linux command:
Netstat-n | awk '/^tcp/{++s[$NF]} end {for (a in S) print A, s[a]} '

Return sample results:
Last_ack 5
SYN_RECV 30
Established 1597
Fin_wait1 51
Fin_wait2 504
Time_wait 1057
of which
SYN_RECV indicates the number of requests waiting to be processed;
Established indicates normal data transfer status;
Time_wait represents the number of requests that have finished processing and waiting for the timeout to end.

---------------------------------------------------------------------------------------------

View the number of httpd processes (that is, the number of concurrent requests that Apache can handle in prefork mode):
Linux command:
Ps-ef | grep httpd | Wc-l

View the number of concurrent requests for Apache and its TCP connection status:

Linux command:
Netstat-n | awk '/^tcp/{++s[$NF]} end {for (a in S) print A, s[a]} '
Return sample results:
Last_ack 5
SYN_RECV 30
Established 1597
Fin_wait1 51
Fin_wait2 504
Time_wait 1057

Description
SYN_RECV indicates the number of requests waiting to be processed;
Established indicates normal data transfer status;
Time_wait represents the number of requests that have finished processing and waiting for the timeout to end.

Netstat Common parameters

-A (all) shows all options, default does not show listen related
-T (TCP) displays only TCP-related options
-U (UDP) only displays UDP-related options
-N denies displaying aliases, and can display all numbers converted to numbers.
-l list only the Listen (listening) of the service, trillion thorn?/p>

-P Displays the name of the program that establishes the associated link
-R Displays routing information, routing table
-e display extended information, such as UID, etc.
-S statistics according to each protocol
-C executes the netstat command at every other fixed time.

Hint: The status of listen and listening can only be seen with-a or-l

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.