zoukankan      html  css  js  c++  java
  • goaccess生成nginx每日访问纪录

    使用php写的,方便点

    <?php
        // 定义全局参数
        $date = date("Ymd");
        $day = date("d", strtotime('-1 day'));
        $month = date("M");
        $year = date("Y");
        
        $LOG = "nginx_{$date}.log";
        $HTML = "nginx_{$date}.html";
        
        // 先生成当天的nginx日志文件
        $cmd = "sed -n '/{$day}/{$month}/{$year}/ p' /var/log/nginx/log/host.access.log > $LOG";
        `$cmd`;
        _debug($cmd);
        // 再使用goaccess生成网页
        $cmd = "/usr/local/bin/goaccess -f $LOG -a > /yfdata/mobile/$HTML";
        `$cmd`;
        _debug($cmd);
        _debug("success");
        
        function _debug($msg) {
            echo "$msg
    ";
        }
    ?>

     还可以使用命令行:

    可以结合sed等工具
    sed -n '/05/Dec/2010/,$ p' access.log | goaccess -a
    
    

    日期段:

    
    
    sed -n '/5/Nov/2010/,/5/Dec/2010/ p' access.log | goaccess -a
    这样似乎不能直接输出文件,曲线救国:
     
    sed -n '/8/Apr/2014/,$ p' /var/log/nginx/log/host.access.log > log.log
    goaccess -f log.log -a > /yfdata/mobile/nginx_20140508.html
  • 相关阅读:
    国内外手机号码正则表达式
    apt安装Neo4j
    经典决策树模型
    自动文档摘要评价方法
    scrapy-splash解析javascript
    ubuntu安装splash
    iptables的删除命令中的相关问题
    ARTS第七周
    ARTS第六周
    ARTS第五周
  • 原文地址:https://www.cnblogs.com/trying/p/3716425.html
Copyright © 2011-2022 走看看