码迷,mamicode.com
首页 > 其他好文 > 详细

按项目时间段,爬虫对状态码进行统计

时间:2015-06-24 16:41:58      阅读:96      评论:0      收藏:0      [点我收藏+]

标签:项目   local   统计   时间段   

#!/bin/bash


read -p "which site do you want to Analysis, xxx|xxx:" site

read -p "which site do you want to Analysis, xxx.access.log.x:" log

read -p "which site do you want to Analysis, YisouSpider|Sogou web spider|Baiduspider:" spider

read -p "which code would you want to Analysis,499|500|502|200|301|504:" status_code


if [ $site = xxx ];then

cat /usr/local/nginx/logs/"$log" | awk ‘{if ($10 == "‘$status_code‘") {print $0}}‘ > /var/tmp/tjlog/xxx_$status_code.log

elif [ $site = xxx ];then

cat /usr/local/nginx/logs/"$log" | awk ‘{if ($10 == "‘$status_code‘") {print $0}}‘ > /var/tmp/tjlog/xxx_$status_code.log


else

echo "Nothing"

fi


echo "$site all $status_code number is: `cat /var/tmp/tjlog/"$site"_"$status_code".log | wc -l`"

echo "0   o‘clock $status_code number : `cat /var/tmp/tjlog/"$site"_"$status_code".log | grep "2015:00" | grep "$spider" | wc -l`"

echo "1   o‘clock $status_code number : `cat /var/tmp/tjlog/"$site"_"$status_code".log | grep "2015:01" | grep "$spider" | wc -l`"

echo "2   o‘clock $status_code number : `cat /var/tmp/tjlog/"$site"_"$status_code".log | grep "2015:02" | grep "$spider" | wc -l`"

echo "3   o‘clock $status_code number : `cat /var/tmp/tjlog/"$site"_"$status_code".log | grep "2015:03" | grep "$spider" | wc -l`"

echo "4   o‘clock $status_code number : `cat /var/tmp/tjlog/"$site"_"$status_code".log | grep "2015:04" | grep "$spider" | wc -l`"

echo "5   o‘clock $status_code number : `cat /var/tmp/tjlog/"$site"_"$status_code".log | grep "2015:05" | grep "$spider" | wc -l`"

echo "6   o‘clock $status_code number : `cat /var/tmp/tjlog/"$site"_"$status_code".log | grep "2015:06" | grep "$spider" | wc -l`"

echo "7   o‘clock $status_code number : `cat /var/tmp/tjlog/"$site"_"$status_code".log | grep "2015:07" | grep "$spider" | wc -l`"

echo "8   o‘clock $status_code number : `cat /var/tmp/tjlog/"$site"_"$status_code".log | grep "2015:08" | grep "$spider" | wc -l`"

echo "9   o‘clock $status_code number : `cat /var/tmp/tjlog/"$site"_"$status_code".log | grep "2015:09" | grep "$spider" | wc -l`"

echo "10  o‘clock $status_code number : `cat /var/tmp/tjlog/"$site"_"$status_code".log | grep "2015:10" | grep "$spider" | wc -l`"

echo "11  o‘clock $status_code number : `cat /var/tmp/tjlog/"$site"_"$status_code".log | grep "2015:11" | grep "$spider" | wc -l`"

echo "12  o‘clock $status_code number : `cat /var/tmp/tjlog/"$site"_"$status_code".log | grep "2015:12" | grep "$spider" | wc -l`"

echo "13  o‘clock $status_code number : `cat /var/tmp/tjlog/"$site"_"$status_code".log | grep "2015:13" | grep "$spider" | wc -l`"

echo "14  o‘clock $status_code number : `cat /var/tmp/tjlog/"$site"_"$status_code".log | grep "2015:14" | grep "$spider" | wc -l`"

echo "15  o‘clock $status_code number : `cat /var/tmp/tjlog/"$site"_"$status_code".log | grep "2015:15" | grep "$spider" | wc -l`"

echo "16  o‘clock $status_code number : `cat /var/tmp/tjlog/"$site"_"$status_code".log | grep "2015:16" | grep "$spider" | wc -l`"

echo "17  o‘clock $status_code number : `cat /var/tmp/tjlog/"$site"_"$status_code".log | grep "2015:17" | grep "$spider" | wc -l`"

echo "18  o‘clock $status_code number : `cat /var/tmp/tjlog/"$site"_"$status_code".log | grep "2015:18" | grep "$spider" | wc -l`"

echo "19  o‘clock $status_code number : `cat /var/tmp/tjlog/"$site"_"$status_code".log | grep "2015:19" | grep "$spider" | wc -l`"

echo "20  o‘clock $status_code number : `cat /var/tmp/tjlog/"$site"_"$status_code".log | grep "2015:20" | grep "$spider" | wc -l`"

echo "21  o‘clock $status_code number : `cat /var/tmp/tjlog/"$site"_"$status_code".log | grep "2015:21" | grep "$spider" | wc -l`"

echo "22  o‘clock $status_code number : `cat /var/tmp/tjlog/"$site"_"$status_code".log | grep "2015:22" | grep "$spider" | wc -l`"

echo "23  o‘clock $status_code number : `cat /var/tmp/tjlog/"$site"_"$status_code".log | grep "2015:23" | grep "$spider" | wc -l`"


按项目时间段,爬虫对状态码进行统计

标签:项目   local   统计   时间段   

原文地址:http://sempter.blog.51cto.com/4340646/1665023

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!