check_connecting_status.md
November 30, 2021 ยท View on GitHub
How to check connecting status Back
-
The summary of sockets:
ss -s -
Statistic of connections to a specific port like
80:netstat -nat | grep -i "80" | wc -l -
Statistic of connections to a specific protocol like
httpd:ps -ef | grep httpd | wc -l -
Statistic of established connections:
netstat -na | grep ESTABLISHED | wc -l -
Statistic of connections sorted by IP:
netstat -ntu | awk '{print \$5}' | cut -d: -f1 | sort | uniq -c | sort -n -
Statistic of top 10 visited urls via Nginx:
cat /var/log/nginx/access.log | awk '{print \$7}' | sort | uniq -c | sort -nr | head -n 10 -
Statistic of top 10 IPs to visit via Nginx:
cat /var/log/nginx/access.log | awk '{print \$1}' | sort | uniq -c | sort -nr | head -n 10 -
Statistic of top 10 time periods to visit via Nginx:
cat /var/log/nginx/access.log | grep -P "\[{1}(.+)]" -o | cut -c 14-15 | sort | uniq -c | sort -nr | head -
Statistic of TCP connections grouped by their state:
netstat -tan | grep ^tcp | awk '{++a[\$6]} END{for (i in a) print i, a[i]}'TIME_WAIT: Waiting for enough time to pass to be sure the remote TCP received the acknowledgment of its connection termination request.CLOSE_WAIT: Waiting for a connection termination request from the local user.ESTABLISHED: An open connection, data received can be delivered to the user. The normal state for the data transfer phase of the connection.LISTEN: Waiting for a connection request from any remote TCP end-point.