zoukankan      html  css  js  c++  java
  • 统计web 访问日志的请求数据

      tomcat日志格式  在配置文件 server.xml 中,具体参照官方文档 https://tomcat.apache.org/tomcat-8.0-doc/config/valve.html#Access_Log_Valve

      

    pattern

    A formatting layout identifying the various information fields from the request and response to be logged, or the word common or combined to select a standard format. See below for more information on configuring this attribute.

    • %a - Remote IP address 远端IP
    • %A - Local IP address 本地IP
    • %b - Bytes sent, excluding HTTP headers, or '-' if zero 发送字节数
    • %B - Bytes sent, excluding HTTP headers 发送字节数
    • %h - Remote host name (or IP address if enableLookups for the connector is false) 远端主机名
    • %H - Request protocol 请求协议
    • %l - Remote logical username from identd (always returns '-')  远端逻辑用户名
    • %m - Request method (GET, POST, etc.) 请求类型
    • %p - Local port on which this request was received. See also %{xxx}p below. 请求端口
    • %q - Query string (prepended with a '?' if it exists) 查询字符串
    • %r - First line of the request (method and request URI)  请求字符串(方法 & 请求URL)
    • %s - HTTP status code of the response  返回码
    • %S - User session ID 
    • %t - Date and time, in Common Log Format  日期
    • %u - Remote user that was authenticated (if any), else '-'
    • %U - Requested URL path
    • %v - Local server name
    • %D - Time taken to process the request, in millis
    • %T - Time taken to process the request, in seconds
    • %F - Time taken to commit the response, in millis
    • %I - Current request thread name (can compare later with stacktraces)

    根据日志格式,统计请求 返回码(200, 500,404 等)

    提取返回码命令  :

    grep ${TODAY} ${LogAccess} | grep -v "GET / HTTP/1.1" | awk '{print $11}' | wc -l

    192.145.17.126 10.177.68.157 10.177.68.157 - - [24/Aug/2018:16:48:17 +0800] "GET /CloudNetMonitor/src/app/business/netMonitor/theme/custom/img/mask-loading.gif HTTP/1.1" 200 5093 6
    192.145.17.126 10.177.68.157 10.177.68.157 - - [24/Aug/2018:16:48:17 +0800] "POST /CloudNetMonitor/rest/v1/netmonitor/web/smallFlow HTTP/1.1" 200 403 42
    192.145.17.126 10.177.68.157 10.177.68.157 - - [24/Aug/2018:16:48:17 +0800] "POST /CloudNetMonitor/rest/v1/netmonitor/web/probe/heartBeat/query HTTP/1.1" 200 2055 59
    192.145.17.126 10.177.68.157 10.177.68.157 - - [24/Aug/2018:16:48:18 +0800] "GET /CloudNetMonitor/src/app/business/netMonitor/src/overview/views/currentAlarm.html HTTP/1.1" 200 14350 5
    192.145.17.126 10.177.68.157 10.177.68.157 - - [24/Aug/2018:16:48:18 +0800] "GET /CloudNetMonitor/src/app/business/netMonitor/src/overview/controllers/currentAlarmCtrl.js HTTP/1.1" 200 12739 7
    192.145.17.126 10.177.68.157 10.177.68.157 - - [24/Aug/2018:16:48:18 +0800] "GET /CloudNetMonitor/src/app/business/netMonitor/src/overview/services/alarmService.js HTTP/1.1" 200 5005 4
    192.145.17.126 10.177.68.157 10.177.68.157 - - [24/Aug/2018:16:48:18 +0800] "GET /CloudNetMonitor/src/app/business/netMonitor/src/overview/controllers/ruleHideCtrl.js HTTP/1.1" 200 2890 4
    192.145.17.126 10.177.68.157 10.177.68.157 - - [24/Aug/2018:16:48:18 +0800] "POST /CloudNetMonitor/rest/v1/netmonitor/web/syslogAlarmSend/query/activity HTTP/1.1" 200 3337 46
    192.145.17.126 10.177.68.157 10.177.68.157 - - [24/Aug/2018:16:48:18 +0800] "GET /CloudNetMonitor/src/app/business/netMonitor/theme/image/major.png HTTP/1.1" 200 1325 4

    用定时脚本 每天23:59分 即可统计请求数量

  • 相关阅读:
    关于 使用python向qq好友发送消息(对爬虫的作用----当程序执行完毕或者报错无限给自己qq发送消息,直到关闭)
    关于爬虫的制定
    关于scrapy 使用代理相关问题
    scrapy 关于特殊字符的处理
    scrapy
    关于数据去重
    零基础掌握百度地图兴趣点获取POI爬虫(python语言爬取)(进阶篇)
    零基础掌握百度地图兴趣点获取POI爬虫(python语言爬取)(代码篇)
    计算机编号、硬盘序列号和Mac地址查询方法
    统计学(第七版)第二章 数据的收集
  • 原文地址:https://www.cnblogs.com/albertarmstrong/p/10269311.html
Copyright © 2011-2022 走看看