In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article shows you how awk analyzes web logs, which is concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
The editor mainly talks about how to get the execution time quickly by analyzing the log through awk.
I. web log file format
The code is as follows:
222.83.181.42-[09/Oct/2010:04:04:03 + 0800] GET / pages/international/tejia.php HTTP/1.1 "15708"-"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Sicent; WoShiHoney.B; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)"-"0.037
Separated by spaces, the last field [0.037] is the page execution time, and the seventh field is the page access address.
Second, execute the code
The code is as follows:
Awk 'BEGIN {
Print "Enter log file:"
Getline logs
# logs= "/ var/log/nginx/access.log-20101008"
OFMT= ".3f"
While (getline
< logs) { split($7,atmp,"?"); aListNum[atmp[1]]+=1; aListTime[atmp[1]]+=$NF; ilen++; } close(logs); print "\r\ntotal:",ilen,"\r\n======================================\r\n"; for(k in aListNum) { print k,aListNum[k],aListTime[k]/aListNum[k] | "sort -r -n -k3"; } }' 结果:Performance:
422780 logs, the statistical completion speed is about 5 seconds.
The above is how awk analyzes web logs. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.