- #!/bin/bash
- cat << EOF
- ------------------------------------
- 日志分析小工具
- ------------------------------------
- EOF
-
- LANG=en_US
-
- Usage() {
- echo "Usage: $0 Logfile"
- }
-
- if [ $# -eq 0 ] ;then
- Usage
- exit 0
- else
- Log=$1
- fi
-
- Tmpfile=$(mktemp)
-
- Year=$(date |awk '{print $6}')
- Mon=$(date |awk '{print $2}')
- Day=$(date |awk '{print $3}')
-
- Yesterday=$((Day-1))
-
- echo -e "\n\033[31m-------the ${Year}-${Mon}-${Yesterday} log statistics as shown:--------\033[0m"
-
- echo -e "\n\033[32m the UV in total yesterday:\033[0m\n"
-
- cat $Log| sed -n "/${Yesterday}\/${Mon}\/${Year}:00/,/${Day}\/${Mon}\/${Year}:00/p" | awk '{print $7}'|wc -l
-
- echo -e "\n\033[32m Most of the time yesterday:\033[0m\n"
-
- cat $Log |awk '{print $4}' |cut -c 14-18 |sort|uniq -c | sort -nr | head -10
-
- echo -e "\n\033[32m Most of the page yesterday:\033[0m\n"
-
- cat $Log |sed -n "/${Yesterday}\/${Mon}\/${Year}:00/,/${Day}\/${Mon}\/${Year}:00/p" | awk '{print $11}' |sort |uniq -c |sort -rn |head -10
-
- echo -e "\n\033[32m Most of the ip yesterday:\033[0m\n"
-
- cat $Log| sed -n "/${Yesterday}\/${Mon}\/${Year}:00/,/${Day}\/${Mon}\/${Year}:00/p" | awk '{print $1}' | sort |uniq -c |sort -rn |head -10 > $Tmpfile
- cat $Tmpfile | while read line;
- do
- num=$(echo $line|awk '{print $1}')
- echo -n "访问次数:$num "
- ip=$(echo $line|awk '{print $2}')
- curl -s ip.cn?ip=$ip
- done
posted @
2018-05-28 11:28
老僧观天下
阅读(
161)
评论()
编辑
收藏
举报