精华内容
下载资源
问答
  • awk_按小时统计tomcat访问量

    千次阅读 2015-01-24 16:06:37
    按小时统计tomcat访问量awk命令

    按小时统计tomcat访问量awk命令:

    awk -F":" '{count[$2]++} END{for(i=0; i<24; i++){if(i<10){bb=0""i;}else{bb=i;} print bb"\t"count[bb]}}'  

    示例:

    展开全文
  • 用setArrtibute 方法给我们需要展示在页面的总访问量赋值 每有一位用户登录,在线人数加一,和上面类似同样使用setAttribute 存储数据 用户退出登录 在线人数减一 public void UpDate(ServletContext sc) { ...

    思路

    使用一个文件来存储网站的总访问量(在这里时以键值对的形式来存储 比如count=0 然后通过一个properties通过count去获取值也就是访问量),每登陆网站一次就让文件存储的时加一
    用setArrtibute 方法给我们需要展示在页面的总访问量赋值
    每有一位用户登录,在线人数加一,和上面类似同样使用setAttribute 存储数据 用户退出登录(即注销) 在线人数减一

    	ServletConfig config = null;
    	ServletContext sc = null;
    	private Set<String> names=new HashSet<>();//定义Set来存放name 用于统计在线人数
        
          //数据库连接
        
    	static Usermapper mapper;
        
        static SqlSession session;
    	static {
    		try {
    			String resource = "mybatis-config.xml";		
    			InputStream is = Resources.getResourceAsStream(resource);		
    			SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(is);				
    			session = sqlSessionFactory.openSession();
    			mapper = session.getMapper(Usermapper.class);
    		} catch (IOException e) {
    			e.printStackTrace();
    		}
    	}
    

    mybatis-config.xml
    注意如果使用myesplice的web工程 将mybatis-config 和 db.properties 放在直接src中否则会读不到

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE configuration
      PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
      "http://mybatis.org/dtd/mybatis-3-config.dtd">
    <configuration>
      <properties resource="db.properties">
      <property name="username" value="root"/>
      <property name="password" value="密码"/>
      </properties>
      
    <settings>
    	<setting name="cacheEnabled" value="true"/>
    </settings>
    
    <typeAliases>
    	<package name="fir"/>
    </typeAliases> 
    
    	<environments default="development">
    		<environment id="development">
    		<transactionManager type="JDBC"/>
    		<dataSource type="POOLED">
    			<property name="driver" value="${jdbc.driverClassName}"/>
    			<property name="url" value="${jdbc.url}"/>
    			<property name="username" value="${jdbc.username}"/>
    			<property name="password" value="${jdbc.password}"/>
    		</dataSource>
    		</environment>
    	</environments> 
    	
    	<mappers>
    		<mapper class="fir.Usermapper"/>
    	</mappers>
    </configuration>
    

    db.properties

    jdbc.driverClassName=com.mysql.jdbc.Driver
    jdbc.url=jdbc:mysql://localhost:3306/demo
    jdbc.username=root
    jdbc.password=密码
    
    public void UpDate(ServletContext sc) {
    		Properties pro = new Properties(); 
    		String n;
    		String filePath = "/Users/曹智斌/Desktop/count.txt";
    		//最开始的时候在文件中写 只此一行count=0 也就是访问量为0
    		InputStream in = null;
    		try {
    			in = new  FileInputStream(filePath);
    			pro.load(in);
    			//将上面字节流所督导的加载进pro 也就是在最开始所创建的properties
    			
    		} catch (FileNotFoundException e) {
    			e.printStackTrace();
    		} catch (IOException e) {
    			e.printStackTrace();
    		}	
    		n = pro.getProperty("count");
    		//在这里就是通过count来获取访问量  文件写的是count=访问量
    		//类似于Map中通过  键  来访问   值
    		//但是要注意的是此处获得的是一个字符并非是一个数字
    		//所以在下面调用Integer.parseInt方法   该方法是将所传进的字符  通过补全二进制中用于表示整型值的字节数,将字符转化成数字
    		int a = Integer.parseInt(n) + 1;
    		
    		sc.setAttribute("totalcount", a);
    		pro.setProperty("count", a );
    		try {
    			OutputStream os = new FileOutputStream(filePath);
    			pro.store(os, null);
    			//将通过setProperty 修改过的count 重新通过输出流写进filePath如今所指向的文件中
    		} catch (IOException e) {
    			e.printStackTrace();
    		}
    }
    
    在线人数统计
    public void login(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException, SQLException {
    		String username=req.getParameter("username");
    	    String password = req.getParameter("password");
    	    User user = mapper.query(username);
    	    if (user != null) {
    	    	if (user.getPassword().equals(password)) {
    	    		resp.setCharacterEncoding("utf-8");
    				PrintWriter out = resp.getWriter();
    				out.print("<script>alert('login Successs'); window.location='index.jsp' </script>");
    				out.flush();
    				out.close();								        
    	            req.getSession().setAttribute("username", username);
    	            //将用户名保存到set集合中
    	            names.add(username);
    	            //再将names集合保存到application内置对象中
    	            req.getServletContext().setAttribute("users", names);              
    	            //集合大小即为人数多少
    	            req.getServletContext().setAttribute("count", names.size());
    	    	}else {
    				PrintWriter out = resp.getWriter();
    				out.print("<script>alert('password Failed');window.location='index.jsp' </script>");
    				out.flush();
    				out.close();
    	    	}
    	    }else {
    	    	PrintWriter out = resp.getWriter();
    			out.print("<script>alert('not exist'); window.location='index.jsp' </script>");
    			out.flush();
    			out.close();								
    	    } 
    	    }
    
    //这句话的作用就是在窗口提示是否登陆成功 在index.jsp 上显示  如下图
    out.print("<script>alert('login Success');window.location='index.jsp' </script>");
    

    在这里插入图片描述

    注销

    //实现注销的方法
    	public void logout(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException{
    	    //移除当前用户输入的用户名
    	    names.remove(req.getSession().getAttribute("username"));
    	    //销毁当前用户的session内置对象
    	    req.getSession().invalidate();
    	    req.getServletContext().setAttribute("count", names.size());
    	    PrintWriter out = resp.getWriter();
    		out.print("<script>alert('logout Successs'); window.location='index.jsp' </script>");
    		out.flush();
    		out.close();
    	}
    

    注册
    注册前先根据输入的用户名在数据库查找是否存在,没有则插入信息,否则不会插入

    实体类

    public class User {
    	
    	
    	private String username;
    	private String password;
    	
    	
    	public String getUsername() {
    		return username;
    	}
    	public void setUsername(String username) {
    		this.username = username;
    	}
    	public String getPassword() {
    		return password;
    	}
    	public void setPassword(String password) {
    		this.password = password;
    	}
    
    	@Override
    	public String toString() {
    		return "User [username=" + username + ", password=" + password + "]";
    	}
    	
    

    mapper文件

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE mapper
      PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
      "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
    <mapper namespace="fir.Usermapper">
      <select id="query" resultType="fir.User">
        select username,password from user where username = #{username}
      </select>
    <insert id="Register">
        insert into user(username, password) values
         (#{username,jdbcType=VARCHAR},
          #{password,jdbcType=VARCHAR})
    </insert>
      <cache readOnly="true"></cache>
    </mapper>
    
    
    
    
    //查看是否存在
    private boolean IsExist(String username, String password) throws SQLException, IOException{
    		User user = mapper.query(username);
    		if (user == null) {
    			return false;
    		}else {
    			return true;
    		}
    		}
    插入数据
    private void register(String username, String password) throws SQLException {		
    		try {
    			mapper.Register(username, password);		
    		}catch (Exception e) {
    			e.printStackTrace();
    		}
    }
    

    提交

    @Override
        protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 
            req.setCharacterEncoding("utf-8");
            this.UpDate(sc);
            String str1 = req.getParameter("login");
            String str2 = req.getParameter("register");
            String str3 = req.getParameter("logout");
            if (str1 != null) {
            	try {
    				login(req,resp);
    			} catch (ServletException | IOException | SQLException e) {
    				e.printStackTrace();
    			}
            }
            if (str2 != null) {
            	String username = req.getParameter("username");
        		String password = req.getParameter("password");
        		System.out.println(username+password);
        		try {
    				if (!Isexist(username, password)) {
    					this.register(username, password);
    					PrintWriter out = resp.getWriter();
    					out.print("<script>alert('success');window.location='index.jsp' </script>");
    					out.flush();
    					out.close();				
    				} else {
    					PrintWriter out = resp.getWriter();
    					out.print("<script>alert('failed');window.location='index.jsp' </script>");
    					out.flush();
    					out.close();				
    				}
    			} catch (SQLException e) {
    				e.printStackTrace();
    			}
            }
            if (str3 != null) {
            	logout(req,resp);
            }	            
    }
    

    web.xml

    <servlet>
        <servlet-name>LOGIN</servlet-name>
        <servlet-class>fir.LOGIN</servlet-class>
      </servlet>
      <servlet-mapping>
        <servlet-name>LOGIN</servlet-name>
        <url-pattern>/LOGIN.do</url-pattern>
      </servlet-mapping>
    

    index.xml

    
    <%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8"
        pageEncoding="UTF-8" import="java.sql.*"%>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"+request.getServerName() + ":"
     + request.getServerPort() + path + "/";
    %>
    <!DOCTYPE html>
    <html>
    <head>
    <base href="/logn/">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>
    </head>
    <body>
     <h1>在线人数为:${count==null? 0:count}</h1>
     <h1>总访问量:${totalcount}</h1>
      ${users}
      <form action="Main.do" method="get">     
       用户名:<input  type="text" name="username">
       密 码: <input  type="password" name="password">
       <input type="submit" value="登陆" name="login">
       <input type="submit" value="注册" name="register">
       <input type="submit" value="注销" name="logout">
      </form>
    </body>
    </html>
    
    在运行的时候,如果出现找不到相应的例如 着了的 Main.do
    一般两个根本原因
    1.web.xml  和 index.jsp 中的url路径不匹配
    
    
    那么匹配就好了
    2.找不到编译的.class 文件
    
    url 匹配  那么就是.class 文件
    
    (1)Project 查看是否 勾选 Build Automically自动编译
    (2)不行的话 那么 Project --> clean-->clean project selected below
     (3) 还是不行的话 window --> show views --> other --> general --> Navigator
     应该就可以了
    
    
    
    

    结果
    在这里插入图片描述

    展开全文
  • 如何从nginx,tomcat的日志中提取出有用的信息来,比如 实时分析统计访问量.zip
  • 统计每分钟的访问量 awk -F: '{count[$2":"$3]++} END {for (minute in count) print minute, count[minute]}' /home/jyapp/apache-tomcat-7.0.59-interface/logs/localhost_access_log.2019-07-18.txt | sort 09:53...
    统计每分钟的访问量
    awk -F: '{count[$2":"$3]++} END {for (minute in count) print minute, count[minute]}' /home/jyapp/apache-tomcat-7.0.59-interface/logs/localhost_access_log.2019-07-18.txt | sort
    09:53 3
    10:56 32531
    10:57 7670
    11:00 14920
    11:01 20647
    11:19 14185
    11:20 10890
    11:23 11917
    11:24 10049
    11:25 18582
    11:26 792
    11:27 11528
    11:28 5979
    11:31 47962
    11:32 24836
    11:33 30062
    11:34 10216
    11:35 16459
    11:36 15487
    
    
    
    
    统计响应时间超过1秒的请求
    awk '($NF > 1000){print $0}' /home/jyapp/apache-tomcat-7.0.59-interface/logs/localhost_access_log.2019-07-18.txt
    172.18.100.202 - - [18/Jul/2019:10:56:55 +0800] http-bio-8082-exec-143"POST /core-interface/api/wealth/3103/v1 HTTP/1.1" 200 3140
    172.18.100.202 - - [18/Jul/2019:10:56:55 +0800] http-bio-8082-exec-61"POST /core-interface/api/wealth/3103/v1 HTTP/1.1" 200 1908
    172.18.100.202 - - [18/Jul/2019:10:56:55 +0800] http-bio-8082-exec-172"POST /core-interface/api/wealth/3103/v1 HTTP/1.1" 200 3454
    172.18.100.202 - - [18/Jul/2019:10:56:55 +0800] http-bio-8082-exec-88"POST /core-interface/api/wealth/3103/v1 HTTP/1.1" 200 1292
    172.18.100.202 - - [18/Jul/2019:10:56:55 +0800] http-bio-8082-exec-184"POST /core-interface/api/wealth/3103/v1 HTTP/1.1" 200 1908
    172.18.100.202 - - [18/Jul/2019:10:56:55 +0800] http-bio-8082-exec-185"POST /core-interface/api/wealth/3103/v1 HTTP/1.1" 200 3140
    172.18.100.202 - - [18/Jul/2019:10:56:55 +0800] http-bio-8082-exec-39"POST /core-interface/api/wealth/3103/v1 HTTP/1.1" 200 3453
    172.18.100.202 - - [18/Jul/2019:10:56:55 +0800] http-bio-8082-exec-59"POST /core-interface/api/wealth/3103/v1 HTTP/1.1" 200 3140
    172.18.100.202 - - [18/Jul/2019:10:56:55 +0800] http-bio-8082-exec-166"POST /core-interface/api/wealth/3103/v1 HTTP/1.1" 200 3140
    
    
    
    统计每个接口的请求次数
    awk '{aaa[$7]++;} END{for(i in aaa) { printf("%s\t%s\n", aaa[i], i); }}' localhost_access_log.2019-07-18.txt | sort -bn
    3	/manager/status/all?XML=true
    304712	/core-interface/api/wealth/3103/v1
    
    
    
    统计每个接口的请求次数并 从小到大排列
    [jyapp@JY2XNTE03 logs]$ awk '{aaa[$7]++;} END{for(i in aaa) { printf("%s\t%s\n", aaa[i], i); }}' localhost_access_log.2019-05-18.txt |sort -n
    1	/xqAppServer/api/APPBizRe172.18.100.202
    1	/xqAppServer/api/APPBizRest/queryM172.18.100.202
    288051	/xqAppServer/api/APPBizRest/queryBankWithdrawAmount/v1/
    491024	/xqAppServer/api/APPBizRest/queryMyWealth/v1/
    522403	/xqAppServer/api/APPBizRest/queryCreditorTransferInfo/v1/
    697232	/xqAppServer/api/APPBizRest/queryCashCalendar/v1/
    
    
    
    统计每个接口的请求次数,按大小排列,取top3
    [jyapp@JY2XNTE03 logs]$ awk '{aaa[$7]++;} END{for(i in aaa) { printf("%s\t%s\n", aaa[i], i); }}' localhost_access_log.2019-05-18.txt |sort -n|head -n 3
    1	/xqAppServer/api/APPBizRe172.18.100.202
    1	/xqAppServer/api/APPBizRest/queryM172.18.100.202
    288051	/xqAppServer/api/APPBizRest/queryBankWithdrawAmount/v1/
    
    
    
    
    统计每个接口的请求次数,按从大到小排列
    [jyapp@JY2XNTE03 logs]$ awk '{aaa[$7]++;} END{for(i in aaa) { printf("%s\t%s\n", aaa[i], i); }}' localhost_access_log.2019-05-18.txt |sort -t $'\t' -k1 -r
    697232	/xqAppServer/api/APPBizRest/queryCashCalendar/v1/
    522403	/xqAppServer/api/APPBizRest/queryCreditorTransferInfo/v1/
    491024	/xqAppServer/api/APPBizRest/queryMyWealth/v1/
    288051	/xqAppServer/api/APPBizRest/queryBankWithdrawAmount/v1/
    1	/xqAppServer/api/APPBizRest/queryM172.18.100.202
    1	/xqAppServer/api/APPBizRe172.18.100.202

     

    展开全文
  • 1 准备工作Advanced Web Statistics(AWStats) 是一个免费的功能强大的服务器日志分析工具,它可以告诉你所有的 Web 统计数据,包括访问量、访问者数量、页面、 点击、高峰时段、操作系统、浏览器版本、搜索引擎、...

    使用服务器日志分析工具 AWStats 分析 Tomcat 的访问日志。

    1 准备工作

    Advanced Web Statistics(AWStats) 是一个免费的功能强大的服务器日志分析工具,它可以告诉你所有的 Web 统计数据,包括访问量、访问者数量、页面、 点击、高峰时段、操作系统、浏览器版本、搜索引擎、关键字、机械访问、无效连接等等。可以工作在大多数服务器上(IIS 5.0+,Apache,Tomcat),可以从命令行或者 CGI 运行。


    • Linux 或 windows
    • Tomcat:7.0.70
    • Java:jdk1.7.0_80(64 bit)
    • ActivePerl:5.24.3(linux 系统自带, Win 环境需要额外安装)
    • AWStats:7.7

    2 安装及配置 AWStat

    将 AWStats 解压或安装,目录如下:

    在 $TOMCAT_HOME$/webapps 下创建 awstats 文件夹,将 AWStats 解压后目录中的文件拷贝过来,目录如下:

    并在 WEB-INF 目录下创建 web.xml 文件,内容如下:

    <?xml version="1.0" encoding="ISO-8859-1"?>    
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee"    
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    
        xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"    
        version="2.4">    
        
        <servlet>    
            <servlet-name>cgi</servlet-name>    
            <servlet-class>org.apache.catalina.servlets.CGIServlet</servlet-class>    
            <init-param>    
              <param-name>debug</param-name>    
              <param-value>0</param-value>    
            </init-param>    
            <init-param>    
              <param-name>cgiPathPrefix</param-name>    
              <param-value>WEB-INF/cgi-bin</param-value>    
            </init-param>    
             <load-on-startup>5</load-on-startup>    
        </servlet>    
             
        <servlet-mapping>    
            <servlet-name>cgi</servlet-name>    
            <url-pattern>/cgi-bin/*</url-pattern>    
        </servlet-mapping>    
             
        <welcome-file-list>    
            <welcome-file>index.html</welcome-file>    
            <welcome-file>index.htm</welcome-file>    
            <welcome-file>index.jsp</welcome-file>    
       </welcome-file-list>    
        
    </web-app>

    在 cgi-bin 目录下,重命名 awstats.model.conf 为 common.conf ,并创建 awstats.localhost.conf 输入:

    # awstats.xxx.conf:xxxx 为需要监控的站点域名,如果需要监控多个站点,可配置多个文件即可;
    
    Include "common.conf"   
    
    # 配置 tomcat 下的访问日志目录,注意前后缀需要与 tomcat 中的配置一致
    LogFile="D:/apache-tomcat-7.0.70-utf8(9081)/logs/localhost_access_log.%yyyy-%mm-%dd.txt"   
    # 配置日志格式,需要与 tomcat 访问日志的格式配置匹配
    # $TOMCAT_HOME$/conf/server.xml 中 pattern:配置日志的格式,可设置为 common (默认)或 combined ,也可自行配置格式。
    # common:%h %l %u %t &quot;%r&quot; %s %b
    # combined:%h %l %u %t %r %s %b %{Referer}i %{User-Agent}i
    # pattern="%h %l %u %t &quot;%r&quot; %s %b"
    LogFormat = "%host - %logname %time1 %methodurl %code %bytesd"
    # pattern="%h %u %t &quot;%r&quot; %s %b %{Referer}i &quot;%{User-Agent}i&quot;;"
    # LogFormat =“%host %logname %time1 %methodurl %code %bytesd %referer %uaquot”
    # 配置的域名
    SiteDomain="localhost"   
    # 配置的访问地址
    HostAliases="localhost 127.0.0.1"   
    # 默认进入 AWStats 的文件
    DefaultFile="index.jsp"   
     
    # 在 cgi-bin 建立 data 文件夹    
    # 此站点监控的统计数据的目录(!!需要手工创建!!)
    DirData="data"   
    DirCgi="/cgi-bin"   
    DirIcons="/awstats/icon"   
     
    # 允许在 web 页更新日志,默认为 0(命令行更新)    
    # 1 为可在监控页面中点击更新,0 为不允许;
    AllowToUpdateStatsFromBrowser=1

    LogFormat 配置说明如下:

    #   %host             Client hostname or IP address (or Sender host for mail log)  
    #   %host_r           Receiver hostname or IP address (for mail log)  
    #   %lognamequot      Authenticated login/user with format: "john"  
    #   %logname          Authenticated login/user with format: john  
    #   %time1            Date and time with format: \[dd/mon/yyyy:hh:mm:ss +0000\] or \[dd/mon/yyyy:hh:mm:ss\]  
    #   %time2            Date and time with format: yyyy-mm-dd hh:mm:ss  
    #   %time3            Date and time with format: Mon dd hh:mm:ss or Mon dd hh:mm:ss yyyy  
    #   %time4            Date and time with unix timestamp format: dddddddddd  
    #   %methodurl        Method and URL with format: "GET /index.html HTTP/x.x"  
    #   %methodurlnoprot  Method and URL with format: "GET /index.html"  
    #   %method           Method with format: GET  
    #   %url              URL only with format: /index.html  
    #   %query            Query string (used by URLWithQuery option)  
    #   %code             Return code status (with format for web log: 999)  
    #   %bytesd           Size of document in bytes  
    #   %refererquot      Referer page with format: "http://from.com/from.htm"  
    #   %referer          Referer page with format: http://from.com/from.htm  
    #   %uabracket        User agent with format: \[Mozilla/4.0 (compatible, ...)\]  
    #   %uaquot           User agent with format: "Mozilla/4.0 (compatible, ...)"  
    #   %ua               User agent with format: Mozilla/4.0_(compatible...)  
    #   %gzipin           mod_gzip compression input bytes: In:XXX  
    #   %gzipout          mod_gzip compression output bytes & ratio: Out:YYY:ZZpct.  
    #   %gzipratio        mod_gzip compression ratio: ZZpct.  
    #   %deflateratio     mod_deflate compression ratio with format: (ZZ)  
    #   %email            EMail sender (for mail log)  
    #   %email_r          EMail receiver (for mail log)  
    #   %virtualname      Web sever virtual hostname. Use this tag when same log  
    #                     contains data of several virtual web servers. AWStats  
    #                     will discard records not in SiteDomain nor HostAliases  
    #   %cluster          If log file is provided from several computers (merged by  
    #                     logresolvemerge.pl), use this to define cluster id field.  
    #   %extraX           Another field that you plan to use for building a  
    #                     personalized report with ExtraSection feature (See later).  
    #   If your log format has some fields not included in this list, use:  
    #   %other            Means another not used field  
    #   %otherquot        Means another not used double quoted field

    3 配置 Tomcat

    修改 $TOMCAT_HOME$/conf/context.xml ,在 Context 节点中追加:privileged=”true” 。

    修改 $TOMCAT_HOME$/conf/server.xml ,找到 Host ,并修改或追加 VALUE 节点如下:

    <Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true">
    
            <!-- SingleSignOn valve, share authentication between web applications
                 Documentation at: /docs/config/valve.html -->
            <!--
            <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
            -->
    
            <!-- Access log processes all example.
                 Documentation at: /docs/config/valve.html
                 Note: The pattern used is equivalent to using pattern="common" -->
            <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="%h %l %u %t &quot;%r&quot; %s %b" prefix="localhost_access_log." suffix=".txt"/>
    
    </Host>

    patter 配置说明如下:

        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  
    %A - Local IP address  
    %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)  
    %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)

    4 启动及验证

    启动 tomcat 后,输入:http://localhost:8080/awstats/cgi-bin/awstats.pl?config=localhost
    config 为需要查看的统计站点,与你配置相同即可;效果图如下:

    手动点击“立即更新“或自己实现定时更新。如可以设置一个 crotab -e 进行配置:0 */10 * * * curl http://localhost:8080/awstats/cgi-bin/awstats.pl?&config=localhost&month=11&year=2018&framename=mainright&update=1


    扫码关注微信公众号 程序员 35 ,获取最新技术干货,畅聊 #程序员的 35,35 的程序员# 。独立站点:https://cxy35.com

    展开全文
  • 学习笔记:年、日、月,周访问量统计 学习别人的心得: -------------  应某位同学的要求,发布了这个源码,即下面的tt.jar文件,直接放到TOMCAT下面就可以用了 ------------- 突然接到一个任务,要用JSP实现一个...
  • 2019-03-14 1、下载运维每天归档的日志 2、找运维要到 tomcat acess log 配置格式为 pattern="...先导入到excel中,预处理了一下,几个不需要的字段删除掉,本来想在excel中统计,速度太慢,统计了两个接口就受...
  • 在上一篇文章中,我们谈到了Weex、ReactNative等方案,那么如何设计一个下载量统计方案呢。  1.传统的tomcat + mysql批量写入更新  如果数据量不大很好办,传统的tomcat处理客户端上报http数据,通过mysql进行存储...
  • tomcat 格式化访问日志,而且可以从header、session中取值,很爽,节约大量的统计工作! 摘录官方网站一段: There is also support to write information from the cookie, incoming h...
  • 由于项目的需要,所以这几天对AWStats的使用方法做了一番研究,因此把这次的心得体会分享给大家,希望可以给予... 一、访问量,访问次数,页面浏览量,点击数,数据流量等  二、精确到每月、每日、每小时的数据 ...
  • 使用场景: 基于awstats的日志访问统计系统,用于分析统计网站页面访问量,为后期扩展提供依据。公司网站架构: 一部分应用采用haproxy+tomcat,一部分采用nginx+tomcat(nginx通过域名分发请求都后端的非80端口)。...
  • TOMCAT运行时OOM解决

    千次阅读 2016-09-07 18:31:13
    统计分析系统因为内部系统,访问量不是太高,一直都是完成功能,没有对TOMCAT的配置关注过,直到最近发生了如下的报错: Exception in thread ...
  • 建立InitServlet ,用于初始化我的Servletcontext,和在关闭tomcat时保存访问量,当用户登录一次我们取出ServletContext取出,并+1, 其中在Web初始化时加入这句话 详细代码如下: 登录界面 public void doGet...
  • Tomcat并发性能调优问题

    千次阅读 2008-05-02 07:47:00
    本人近来在做一个项目,是给一个大企业做一个电话系统,数据量和访问量都比较大。 系统后台由一个C服务程序记录电话记录,前台使用JAVA提供WEB查询与统计电话记录功能。 核心数据表每天产生大约4万条记录,会使用此...
  • 电话系统,数据量和访问量都比较大。 系统后台由一个C服务程序记录电话记录,前台使用JAVA提供WEB查询与统计电话记录功能。 核心数据表每天产生大约4万条记录,会使用此系统的大概有3000多企业员工,上班时间...
  • jquery实现跨域访问

    2013-08-02 19:01:19
    客户提出这么个需求:在外网首页加上一个用户访问量,本来也没什么,一般都很好实现,但是在这里就涉及到了跨域访问,之前也没弄类似的东西,后来搞了好半天才实现,在这里备注一下。 首先,在外网首页写上这么一段...

空空如也

空空如也

1 2 3 4 5
收藏数 81
精华内容 32
关键字:

tomcat访问量统计