FreeBSD 研习课程讲义
Prev 统计分析 Next

  • 前言

    为正确的掌握 Proxy Server 的运作现况,以便於管理及改促进其效能,藉由其 log 记录档案之统计,可以进一步的正确掌握,作为调整效能之叁考。

    可以了解使用本伺服器的使用者,连上哪些网站,更可以明白哪些网站是热门所驱,可做为 Web Sever 超连结之用或加强管制学生浏览不当网页。

  • 下载

    fly
    http://ftp.nsysu.edu.tw/Unix/Proxy/fly/fly-1.6.5.tar.gz

    pwebstats (官方网页 http://martin.gleeson.com/pwebstats/ )
    ftp://ftp.psg.com/pub/pwebstats/pwebstats-1.3.8.tar.gz
    or
    ftp://ftp.unimelb.edu.au/pub/www/tools/unix/pwebstats/pwebstats-1.3.8.tar.gz

  • 安装
    • fly
      利用 root 安装
      • # cd /tmp
        # fetch http://ftp.nsysu.edu.tw/Unix/Proxy/fly/fly-1.6.5.tar.gz
      • # tar zxvf fly-1.6.5.tar.gz
      • # cd fly-1.6.5
        # make
        # cp fly /usr/local/bin

    • pwebstats 利用 root 安装
      • # cd /tmp
        # fetch ftp://ftp.psg.com/pub/pwebstats/pwebstats-1.3.8.tar.gz
      • # tar zxvf pwebstats-1.3.8.tar.gz
      • # mv pwebstats-1.3.8 /usr/local/www/data/pwebstats
  • Configure
    • # cd /usr/local/www/data/pwebstats
      # vi pwebstats

      检查 pwebstats 这个 script 第一行,perl 的路径是否正确,可先用 whereis perl,务必两者要相同

    • # cd /usr/local/www/data/pwebstats/templates/domains/
      # vi domains.txt

      检查 Taiwan 名称,将 Province of China 删除。

    • # vi /usr/local/www/data/pwebstats/conf/squid-proxy.conf

      修改pwebstats设定档

      # pwebstats configuration file for http server
      #
      # Unique nickname for server.
      # use only a-z, A-Z and _
      # e.g. server:proxy
      server:ABC_KS //建立databases名称,会建立於pwebstats下

      # Header for index page.
      # e.g. Server_header:The TelDem Enterprises Caching Proxy Server
      Server_header:高县代理伺服器 //网页呈现标题

      # Location of latest log file
      logfile:/home/squid/var/logs/access.log.0 //最新log档位置

      # Type of log file - use 'squid-emulated' if you have the httpd log
      # emulation option turned on in squid.
      logtype:squid

      # Location for the output of pwebstats.
      # e.g. outdir:/home/servers/http/teldem/proxy-usage
      outdir:/usr/local/www/htdocs/pwebstats //分析结果输出位置

      # directory containing GIF templates
      # e.g. templates:/home/servers/http/pwebstats/templates
      templates:/usr/local/www/htdocs/pwebstats/templates //分析图档所在位置

      # Stats collection interval
      # can be one of daily, weekly, monthly, quarterly
      interval:daily //分析周期

      # Verbose? Yes
      verbose:true

      # Location of 'fly'
      # e.g. fly_prog:/home/servers/http/pwebstats/fly/fly
      fly_prog:/usr/local/bin/fly //画图所需程式位置

      # regular expression matching your local hostnames and IP numbers
      # e.g. local_patt:\.unimelb\.edu\.au$|^128\.250|^localhost$|250\.128\.in\-addr\.arpa
      local_patt:\.ks\.edu\.tw$|^163\.16 //本机正反解

      # threshold for host count lists
      host_threshold:100 //连线百大排行

      # threshold for remote host count lists
      remote_host_threshold:100 //出去要百大排行

      # threshold for request count lists
      item_threshold:100

      # threshold for domain count lists
      domain_threshold:5

      # don't generate request/accesses information
      # (recommended for proxy stats)
      exclude_reqs:true

      # completely ignore access from this set of hostnames ( | is the delimeter)
      # complete_exclude_host:foo1.users.bar.com|foo2.users.bar.com|foo3.users.bar.com
      #
      # You might like to add the IP numbers and/or hostnames of your squid neighbours
      # so you just get the information about local users.
      #complete_exclude_host:
      # completely ignore access to this pattern of URLs
      # complete_exclude_url_patt:^/foo/bar/*$|^/robots.txt$
      #complete_exclude_url_patt:
      # completely ignore access from this set of users ( | is the delimeter)
      # complete_exclude_user:tom|dick|harry
      #complete_exclude_user:
      # do IP number -> hostname resolution
      #dns_lookup:true

  • 修改 pwebstats 显示中文

    修改 /usr/local/www/data/pwebstats/pwebstats 大约在 549 行附近,有 HTML 语言,加入

    <meta http-equiv=\"content-type\" content=\"text/html; charset=big5\">

    加入在 <head>...</head> 中

  • 更新
    • 建立 crontab
      以 root 身份

      # crontab -e

      0 3 * * * /usr/local/www/htdocs/pwebstats/pwebstats -c \
      /usr/local/www/htdocs/pwebstats/conf/squid-proxy.conf


Prev Home Next
系统效能分析 UP 自动组态档介绍