Server nginx with Shell statistics concurrency

Source: Internet
Author: User

# 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

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.