代码之家  ›  专栏  ›  技术社区  ›  Big-G

输出用户流的Apache日志分析器

  •  1
  • Big-G  · 技术社区  · 16 年前

    我有一个客户在一个网站上,他刚刚执行了一些意想不到的事情,我有他的IP地址,因为它与购买的交易记录。

    有没有一个程序可以让我一步一步地查看一个选中的用户在站点上使用apache日志所做的事情。

    e、 g.IP地址a.b.c.d设置。。。

    IP address a.b.c.d
    Time Date / Path
    18:02     / index.htm
    18:03     / shop.htm
    18:04     / product1.htm
    

    谢谢你的帮助。

    1 回复  |  直到 16 年前
        1
  •  3
  •   orithena    16 年前

    那是一种恶作剧。我希望您已经将apache日志类型设置为“Combined”,并且可以使用bashshell。然后命令

    grep $IP $LOGFILE | awk '{ print $4$5, $7, "("$11")" }'
    

    [07/Mar/2010:14:11:45+0100] /Doku/strawberrylimes.html ("-")
    [07/Mar/2010:14:11:45+0100] /doku.css ("http://da.andaka.org/Doku/strawberrylimes.html")
    [07/Mar/2010:14:11:45+0100] /images/zutaten.jpg ("http://da.andaka.org/Doku/strawberrylimes.html")
    [07/Mar/2010:14:11:56+0100] /images/prost.jpg ("http://da.andaka.org/Doku/strawberrylimes.html")
    [07/Mar/2010:14:11:56+0100] /images/vollermixer.jpg ("http://da.andaka.org/Doku/strawberrylimes.html")
    [07/Mar/2010:14:11:57+0100] /favicon.ico ("-")
    

    $IP $LOGFILE 用你的价值观。。。结果来自我的Web服务器,只访问一页。)

    如果您只对.html文件的请求感兴趣,请使用另一个grep扩展命令行:

    grep $IP $LOGFILE | awk '{ print $4$5, $7, "("$11")" }' | grep -E '.+ .+\.html.* .+'
    

    最后一个grep会过滤掉所有这样做的行 在输出的第二列中有一个“.html”字符串。但它也会过滤掉目录上的所有请求!

    推荐文章