# netstat-an| grep ': 80 ' | awk '/tcp/{a[$NF]++}end{for (i in a) print i,a[i]} '
# echo "Current concurrency: ' netstat-ant | grep:80 | awk ' {print $} ' | Awk-f ":" ' {print $} ' | Sort | uniq-c | Sort-r-N | awk ' begin{total=0}{total+=$1}end{print total} ';
Current number of concurrent: 8
Post statistics server concurrency statistics script, according to the information on the Internet and the need to organize, the IP for their own IP address, statistics is 80 port access concurrency for the Linux platform. Remove the last awk segment to count the current number of accesses per IP
# echo "Current concurrency: ' netstat-nt | grep ip:80 | awk ' {print $} ' | Awk-f ":" ' {print $} ' | Sort | uniq-c | Sort-r-N | awk ' begin{total=0}{total+=$1}end{print total} ';
#统计并发
# echo "Current concurrency: ' netstat-nt | grep:80 | awk ' {print $} ' | Awk-f ":" ' {print $} ' | Sort | uniq-c | Sort-r-N | awk ' begin{total=0}{total+=$1}end{print total} ';
Statistics Concurrency script:
# Cat Concurrent.sh
#!/bin/bash
While:
Do
echo "Current concurrency: ' netstat-nt | grep:80 | awk ' {print $} ' | Awk-f ":" ' {print $} ' | Sort | uniq-c | Sort-r-N | awk ' begin{total=0}{total+=$1}end{print total} ' >>/opt/logs/concurrent/logs/concurrent.txt
Sleep 1
Done
[Email protected]~]# cat concurrent_date.sh
#!/bin/bash
Date= ' Date +%f '
Kill-9 ' Ps-ef | grep concurrent.sh | Grep-v grep | awk ' {print $} '
Sleep 5
echo "============== $Date ==============" >>/opt/logs/bf_sum.txt
Sort-r/opt/logs/concurrent/logs/concurrent.txt |head >>/opt/logs/bf_sum.txt
echo "==============end==============" >>/opt/logs/bf_sum.txt
Mv/opt/logs/concurrent/logs/concurrent.txt/opt/logs/concurrent/logs/concurrent.${date}.txt
Nohup/opt/logs/concurrent/concurrent.sh &
find/opt/logs/concurrent/logs/-type f-name "*.txt"-mtime +7-exec rm-r {} \;
Server nginx with Shell statistics concurrency