LINUX awk Operations

Source: Internet
Author: User

The company wants to carry on the system optimization, now to the Nginx service request time and the request quantity carries on the analysis.

Nginx request file under Linux to be cut

Get access log log analysis

1: Get URI and request time log to Tmp_0.log
Cat App_access.log | Awk-f ' | ' ' {print $ ' "$11} ' > Tmp_0.log

2: Count requests per request URI and request time (count), Total request time (sum), Avg time (avg), Maximum request time (max), Minimum request time (min)

awk ' {sum_arr[$1]+=$2;count_arr[$1]+=1; min_arr[$1]=min_arr[$1]== '? $: ($2<min_arr[$1]?$2:min_arr[$1]); max_ ARR[$1]=$2>MAX_ARR[$1]?$2:MAX_ARR[$1]} END {for (i in Sum_arr) {print "Action:" I ", Total_time:" Sum_arr[i] "Max:" Max_ Arr[i] "Count:" Count_arr[i] "min:" Min_arr[i] "avg:" Sum_arr[i]/count_arr[i];}} '

LINUX awk Operations

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.