网站内容更新监控(如何在Linux环境下部署AWStats分析系统来监控Web站点? )

优采云 发布时间: 2021-09-25 11:16

  网站内容更新监控(如何在Linux环境下部署AWStats分析系统来监控Web站点?

)

  这是我参加更多文字挑战的第19天。活动详情请查看:更多文字挑战

  一个致力于科技之路的终身学习者、践行者、分享者,一个忙碌偶尔偷懒的原创博主,一个偶尔无聊偶尔幽默的少年。

  欢迎朋友们在微信上搜索“杰哥的IT之旅”!

  原文链接:Linux环境下如何部署AWStats分析系统监控网站?

  前言

  在上一篇文章《Linux环境下部署HTTPD服务详解》中,我们介绍了Linux环境下部署httpd服务的基本设置、相关配置和相关说明,所以这个httpd服务必须为我们设置好提供服务。同时,在httpd服务器的访问日志文件中,也记录了大量的客户端访问信息。通过这些信息,您可以了解网站的访问情况等;

  那么,在这个文章中,我们将向大家介绍一款功能强大的免费工具AWStats,它可以以图形化的方式展示统计信息,完成自动化的日志分析和统计工作。

  一、AWStats 介绍

  AWStats是一个使用Perl语言开发的开源日志分析系统,可用于分析Apache网站服务器、Samba、Vsftpd等服务的访问日志信息,并结合定时任务crond服务进行持续增加日志内容定期分析。

  AWStats 包下载链接:

  /项目/啊...

  

  二、安装AWStats包

  将下载的AWStats软件包解压到httpd服务器的/usr/local/目录下。

  # tar zxf awstats-7.3.tar.gz

# mv awstats-7.3 /usr/local/awstats

复制代码

  为需要统计的站点建立配置文件,AWStats系统支持统计多个网站的日志文件,并使用网站来区分不同的站点。在进行日志文件分析之前,您需要为每个网站创建一个站点统计配置文件。这时候就需要在awstats/tools目录下执行awstats系统提供的awstats_configure.pl脚本创建过程。

  执行后会进入交互式配置终端,需要用户根据提示手动输入指定httpd主配置文件的路径。

  # cd /usr/local/awstats/tools/

# chmod +x awstats_configure.pl

# ./awstats_configure.pl

----- AWStats awstats_configure 1.0 (build 20140126) (c) Laurent Destailleur -----

This tool will help you to configure AWStats to analyze statistics for

one web server. You can try to use it to let it do all that is possible

in AWStats setup, however following the step by step manual setup

documentation (docs/index.html) is often a better idea. Above all if:

- You are not an administrator user,

- You want to analyze downloaded log files without web server,

- You want to analyze mail or ftp log files instead of web log files,

- You need to analyze load balanced servers log files,

- You want to 'understand' all possible ways to use AWStats...

Read the AWStats documentation (docs/index.html).

-----> Running OS detected: Linux, BSD or Unix

-----> Check for web server install

Enter full config file path of your Web server.

Example: /etc/httpd/httpd.conf

Example: /usr/local/apache2/conf/httpd.conf

Example: c:\Program files\apache group\apache\conf\httpd.conf

Config file path ('none' to skip web server setup):

> /usr/local/httpd/conf/httpd.conf # 输入 httpd.conf 配置文件的路径

复制代码

  执行完上一步的操作后,接下来需要设置日志类型。当提示是否修改日志类型时,输入“y”字母,配置脚本会自动修改httpd.conf配置文件,添加访问AWStats分析系统相关配置内容。

  -----> Check and complete web server config file '/usr/local/httpd/conf/httpd.conf'

Warning: You Apache config file contains directives to write 'common' log files

This means that some features can't work (os, browsers and keywords detection).

Do you want me to setup Apache to write 'combined' log files [y/N] ? y

Add 'Alias /awstatsclasses "/usr/local/awstats/wwwroot/classes/"'

Add 'Alias /awstatscss "/usr/local/awstats/wwwroot/css/"'

Add 'Alias /awstatsicons "/usr/local/awstats/wwwroot/icon/"'

Add 'ScriptAlias /awstats/ "/usr/local/awstats/wwwroot/cgi-bin/"'

Add '' directive

AWStats directives added to Apache config file.

-----> Update model config file '/usr/local/awstats/wwwroot/cgi-bin/awstats.model.conf'

File awstats.model.conf updated.

复制代码

  为指定网站创建配置文件,根据提示输入“y”创建站点配置文件,指定目标网站名称存放站点配置文件路径(/etc/awstats)等;直接按 键,直到退出配置工具。

  -----> Need to create a new config file ?

Do you want me to build a new AWStats config/profile

file (required if first install) [y/N] ? y # 确认创建新的站点配置文件

-----> Define config file name to create

What is the name of your web site or profile analysis ?

Example: www.mysite.com

Example: demo

Your web site, virtual server or profile name:

> www.jacktiangjwan.com # 指定要统计的目标网站名称

-----> Define config file path

In which directory do you plan to store your config file(s) ?

Default: /etc/awstats

Directory path to store config file(s) (Enter for default):

> # 直接按 Enter 键接受默认设置

-----> Create config file '/etc/awstats/awstats.www.jacktiangjwan.com.conf'

Config file /etc/awstats/awstats.www.jacktiangjwan.com.conf created.

复制代码

  按照上述目标网站的名称建立的站点统计配置文件将存放在/etc/awstats目录下,文件名为:awstats.conf。然后需要修改网站统计配置文件中指定的web日志文件和指定分析存放统计数据的目录,修改后的配置如下;

  # vi /etc/awstats/awstats.www.jacktiangjwan.com.conf # 修改配置文件,将以下原有的三行配置进行替换成如下即可;

LogFile="/usr/local/httpd/logs/access_log"

SiteDomain="www.jacktiangjwan.com"

DirData="/var/lib/awstats"

# mkdir /var/lib/awstats

复制代码

  使用awstats提供的awstats_updateall.pl脚本更新所有站点的日志统计信息。执行脚本时,系统会自动分析新增的日志内容,并将分析结果更新到统计数据库中。

  # chmod +x awstats_updateall.pl

# ./awstats_updateall.pl now

Running '"/usr/local/awstats/wwwroot/cgi-bin/awstats.pl" -update -config=www.jacktiangjwan.com -configdir="/etc/awstats"' to update config www.jacktiangjwan.com

Create/Update database for config "/etc/awstats/awstats.www.jacktiangjwan.com.conf" by AWStats version 7.3 (build 20140126)

From data in log file "/usr/local/httpd/logs/access_log"...

Phase 1 : First bypass old records, searching new record...

Searching new records from beginning of log file...

Jumped lines in file: 0

Parsed lines in file: 4

Found 0 dropped records,

Found 0 comments,

Found 0 blank records,

Found 4 corrupted records,

Found 0 old records,

Found 0 new qualified records.

复制代码

  由于web日志文件的内容会不断更新,我们可以设置定时任务,定时自动执行任务,完成日志分析工作。

  # crontab -e

*/5 * * * * /usr/local/awstats/tools/awstats_updateall.pl now

# /etc/init.d/crond start

# chkconfig --level 35 crond on

复制代码

  以上步骤完成后,此时需要验证是否操作成功,需要在/etc/hosts文件中添加客户端的IP地址和指定的网站名称,并重启httpd服务和 crond 计时任务;

  # vi /etc/hosts

127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4

::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.3.123 www.jacktiangjwan.com

# service httpd restart

# service crond restart

停止 crond:[确定]

正在启动 crond:[确定]

复制代码

  三、访问AWStats分析系统

  在客户端打开浏览器地址栏访问站点:... 然后可以看到AWStats日志分析系统的页面(如下图)。该页面按访问时间、用户来源、使用的浏览器等类别列出。详细网站访问状态;还可以在左栏查看每小时、每天、每周、每月的网站访问次数、网页数量、文件数量等信息;另外,还有很多其他的功能,这里就不一一展示了,有兴趣的朋友可以自己搭建环境研究一下。

  

  访问awstats分析系统时,需要指定awstats目录、脚本位置、统计目标等相关信息。这样不方便大家记忆,输入比较麻烦。因此,我们可以在 web 根目录中创建一个自动重定向的 html。网页文件。在/usr/local/httpd/htdocs/目录下创建abc.html文件,在文件中写入上述访问URL。用户只需要访问,就可以自动跳转到网站的AWStats日语分析系统页面。

  # vi /usr/local/httpd/htdocs/abc.html

复制代码

  

0 个评论

要回复文章请先登录注册


官方客服QQ群

微信人工客服

QQ人工客服


线