分类: LINUX
2013-05-25 14:53:20
#!/bin/bash
#this is scirpts about apache customlog
#date is today
#date is yesterday
apadate=`date -d last-day "+%d/%b/%Y"`
#cat /usr/local/apache/logs/access_log |grep "$apadate" |more
#total size
#cat /usr/local/apache/logs/access_log |grep "$apadate" |awk 'BEGIN{print "total
size(B)"}{a+=$10}END{print a}'
cat /usr/local/apache/logs/access_log |grep "$apadate" |awk ' BEGIN{total=0;ok=0
;red=0;client=0;serv=0;tal_num=0;print "branches\tcorrect\tredirect\terr_clt\ter
r_srv\taggregate\n"}
{
if ($6~GET) total++;
{
if ($(NF-1)~/^2/) ok++;
else if ($(NF-1)~/^3/) red++;
else if ($(NF-1)~/^4/) client++;
else if ($(NF-1)~/^5/) serv++;
tal_num+=$(NF);
}
}
END{print total,"\t",ok,"\t",red,"\t",client,"\t",serv,"\t",tal_num ;}'