2017-03-08 36 views
0

我正在使用ngxtop进行nginx日志监视。使用ngxtop按特定日期进行过滤

ngxtop --no-follow 

这将输出访问日志中所有数据的请求计数。 我只对当前日期前一天的请求数感兴趣。

有没有一种方法可以输出特定日期的请求计数?

回答

0

nxtop使用Python作为其筛选标志(-i)。

使用的变量名是那些http://nginx.org/en/docs/http/ngx_http_log_module.html

所以,你可以按日期这样的筛选:

ngxtop --no-follow -i 'time_local > "12/Jan/2018:20:00:00"' print remote_addr time_local request

注意,多个过滤器需要通过一个Python表达式来指定,而不是多个-i标志,例如 -i 'time_local > "12/Jan/2018:00:00:00"' and time_local < "20/Jan/2018:00:00:00"