Log analysis
Random tail a Access_log file, here is a classic access record
218.19.140.242–-[10/dec/2010:09:31:17 +0800] "get/query/trendxml/district/todayreturn/month/2009-12-14/ 2010-12-09/haizhu_tianhe.xml http/1.1″200 1933 "-" "mozilla/5.0 (Windows; U Windows NT 5.1; ZH-CN; rv:1.9.2.8) gecko/20100722 firefox/3.6.8 (. NET CLR 3.5.30729) "
A useful log Analysis script
Once you understand the various definitions of the log, here are some of the scripts that you'll find on the web for log analysis
1. View the number of Apache processes
Ps-aux | grep httpd | Wc-l
2. Analysis Log view the number of IP connections for the day
Cat Default-access_log | grep "10/dec/2010″| awk ' {print $} ' | Sort | uniq-c | Sort-nr
3. See what URL the specified IP visited on that day
Cat Default-access_log | grep "10/dec/2010″| grep "218.19.140.242″| awk ' {print $7} ' | Sort | uniq-c | Sort-nr
4. View the top 10 URLs for today's visit
Cat Default-access_log | grep "10/dec/2010″| awk ' {print $7} ' | Sort | uniq-c | Sort-nr | Head-n 10
5. See what the specified IP has done
Cat Default-access_log | grep 218.19.140.242 | awk ' {print $1″\t ' $8} ' | Sort | uniq-c | Sort-nr | Less
6. View the most visited minutes (find hotspots)
awk ' {print $4} ' Default-access_log |cut-c 14-18|sort|uniq-c|sort-nr|head
7. Statistics a text contains the number of characters
Cat Pic.access.log |grep/2012/|wc-l
Cat C_access.log |grep "/message/publishmsg/\|/message/publish/" >test1.log
Linux Utility Log Analysis script