分析网站日志

(1)、统计访问URL统计PV

1
# awk '{print $7}' fresh.yilumall.com-access_log |wc -l

分析网站日志
(2)、根据访问IP统计UV

1
# awk '{print $1}' fresh.yilumall.com-access_log |sort|uniq -c|wc -l

分析网站日志
(3)、查询访问最频繁的IP

1
# awk '{print $1}' fresh.yilumall.com-access_log |sort|uniq -c|sort -n -k 1 -r |more

分析网站日志
(4)、查询访问最频繁的URL

1
# awk '{print $7}' fresh.yilumall.com-access_log |sort|uniq -c|sort -n -k 1 -r |more

分析网站日志
(5)、状态码个数统计

1
# awk '{print $9}' fresh.yilumall.com-access_log |sort|grep 200 |wc -l

分析网站日志
(6)、根据时间段统计查看日志
下面以apache为例使用sed查看特定时间段的访问日志

1
# sed -n '/24\/May\/2020:00:12:39/,/25\/May\/2020:00:[0-9][0-9]:[0-9][0-9]/p' fresh.yilumall.com-access_log |more

需要注意的是如果起始时间在日志中不存在,则整个截取将返回0行结果。如果结束时间在日志中不存在,则会截取到日志的最后一条。所以在截取前得要找到日志中最合适的起始点和结束点,有时候为了方便可以使用[]匹配时间段。
分析网站日志

在特定时间段中过滤相关信息
例如查看2020/5/24 0点 ~ 2020/5/25 0点网站登录页面login.html被访问的情况

1
# sed -n '/24\/May\/2020:00:[0-9][0-9]:[0-9][0-9]/,/25\/May\/2020:00:[0-9][0-9]:[0-9][0-9]/p' fresh.yilumall.com-access_log |grep "/admin/login.html"

分析网站日志
查看2020/5/24 0点 ~ 2020/5/25 0点有哪些ip来访问站点,每个ip访问的次数

1
# sed -n '/24\/May\/2020:00:[0-9][0-9]:[0-9][0-9]/,/25\/May\/2020:00:[0-9][0-9]:[0-9][0-9]/p' fresh.yilumall.com-access_log |grep "/admin/login.html" |awk '{print $1}'|sort |uniq -c

分析网站日志

相关新闻

联系我们

全国服务热线

400-033-9553

电子邮件:admin@example.com
工作时间:09:00-17:00 周一至周五

在线客服
关注微信
关注微信
分享本页
返回顶部