Webalizer是一个高效的、免费的web服务器日志分析程序。其分析结果以HTML文件格式保存,从而可以很方便的通过web服务器进行浏览。Internet上的很多站点都使用webalizer进行web服务器日志分析。----百度百科
Webalizer特性:
1. 为是用C写的程序,所以其具有很高的运行效率。在主频为200Mhz的机器上,webalizer每秒钟可以分析10000条记录,所以分析一个40M大小的日志文件只需要15秒。
2. webalizer支持标准的一般日志文件格式(Common Logfile Format);除此之外,也支持几种组合日志格式(Combined Logfile Format)的变种,从而可以统计客户情况以及客户操作系统类型。并且现在webalizer已经可以支持wu-ftpd xferlog日志格式以及squid日志文件格式了。
3. 支持命令行配置以及配置文件。
4. 可以支持多种语言,也可以自己进行本地化工作。
5. 支持多种平台,比如UNIX、linux、NT, OS/2 和 MacOS等
搭建环境以及所需的软件包:
系统:centos
软件:httpd 作为webalizer的页面服务器
gd
zlib
font
db4-devel
安装步骤如下:
1,依次安装如下软件:
1
2
3
4
5
|
[root@zabbix ~]
#yum -y install httpd
[root@zabbix ~]
#yum -y install gd*
[root@zabbix ~]
#yum -y install zlib*
[root@zabbix ~]
#yum -y install font*
[root@zabbix ~]
# yum install db4-devel
|
2,安装配置GeoIP插件:这里需要3个GeoIP编译包GeoIP-1.4.8,Geo-IP-1.27,Geo-IPfree-0.2且这三个编译包相互关联,必须逐一安装。
a,安装GeoIP-1.4.8包
1
2
3
4
5
6
7
|
[root@zabbix soft]
# wget http://www.findthatzip.com/search-41538008-hZIP/winrar-winzip-download-webalizer-geoip-2.1.10-13.tbz.htm
[root@zabbix soft]
#tar zxvf GeoIP-1.4.8.tar.gz
[root@zabbix soft]
#cd GeoIP-1.4.8
[root@zabbix soft]
#./configure --prefix=/usr/local/GeoIP
[root@zabbix soft]
#make && make install
[root@zabbix soft]
#cd /tmp/soft/GeoIP-1.4.8/data
[root@zabbix soft]
#cp GeoIP.dat /usr/shar/GeoIP/
|
由于自定义了安装路径,所以这里需要加载关联GeoIP模块库
1
2
|
[root@zabbix soft]
#echo '/usr/local/GeoIP/lib' >> /etc/ld.so.conf
[root@zabbix soft]
#/sbin/ldconfig /etc/ld.so.conf
|
b,安装Geo-IP-1.27包
1
2
3
4
5
|
[root@zabbix soft]
#wget http://www.maxmind.com/download/geoip/api/perl/Geo-IP-1.27.tar.gz
[root@zabbix soft]
#tar zxvf Geo-IP-1.27.tar.gz
[root@zabbix soft]
#cd Geo-IP-1.27
[root@zabbix soft]
# perl Makefile.PL LIBS='-L/usr/local/GeoIP/lib'INC='-I/usr/local/GeoIP/include'
[root@zabbix soft]
#make && make install
|
c,安装Geo-IPfree-0.2包
1
2
3
4
5
|
[root@zabbix soft]
# wget http://search.cpan.org/CPAN/authors/id/G/GM/GMPASSOS/Geo-IPfree-0.2.tar.gz
[root@zabbix soft]
#tar zxvf Geo-IPfree-0.2.tar.gz
[root@zabbix soft]
#cd Geo-IPfree-0.2
[root@zabbix soft]
#perl Makefile.PL
[root@zabbix soft]
#make && make install
|
3,准备ip查询库:
1
2
3
4
5
|
[root@zabbix soft]
# wget ftp://ftp.mrunix.net/pub/webalizer/webalizer-geodb-latest.tgz
[root@zabbix soft]
# tar zxvf webalizer-geodb-latest.tgz
GEODB.README
GeoDB.dat
[root@zabbix soft]
# cp GeoDB.dat /usr/share/GeoDB/
|
4,准备国旗图片库
1
2
3
|
[root@zabbix soft]
# wget ftp://ftp.mrunix.net/pub/webalizer/webalizer-flags.tgz
[root@zabbix soft]
# tar zxvf webalizer-flags.tgz
[root@zabbix soft]
# mv flags/ /var/www/html/
|
5,下载安装webalizer
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
[root@zabbix soft]
# wget ftp://ftp.mrunix.net/pub/webalizer/webalizer-2.23-05-src.tgz
[root@zabbix soft]
# tar zxvf webalizer-2.23-05-src.tgz
webalizer-2.23-05/
webalizer-2.23-05
/CHANGES
webalizer-2.23-05
/COPYING
webalizer-2.23-05
/Copyright
webalizer-2.23-05
/DNS
.README
webalizer-2.23-05
/INSTALL
webalizer-2.23-05
/Makefile
.
in
webalizer-2.23-05
/Makefile
.std
webalizer-2.23-05
/README
webalizer-2.23-05
/README
.FIRST
webalizer-2.23-05
/configure
webalizer-2.23-05
/configure
.
in
webalizer-2.23-05
/country-codes
.txt
webalizer-2.23-05
/dns_resolv
.c
webalizer-2.23-05
/dns_resolv
.h
webalizer-2.23-05
/graphs
.c
webalizer-2.23-05
/graphs
.h
webalizer-2.23-05
/hashtab
.c
webalizer-2.23-05
/hashtab
.h
webalizer-2.23-05
/install-sh
webalizer-2.23-05
/lang
.h
webalizer-2.23-05
/linklist
.c
webalizer-2.23-05
/linklist
.h
webalizer-2.23-05
/msfree
.png
webalizer-2.23-05
/output
.c
webalizer-2.23-05
/output
.h
webalizer-2.23-05
/parser
.c
webalizer-2.23-05
/parser
.h
webalizer-2.23-05
/preserve
.c
webalizer-2.23-05
/preserve
.h
webalizer-2.23-05
/sample
.conf
webalizer-2.23-05
/wcmgr
.1
webalizer-2.23-05
/wcmgr
.c
webalizer-2.23-05
/webalizer
.1
webalizer-2.23-05
/webalizer
.LSM
webalizer-2.23-05
/webalizer
.c
webalizer-2.23-05
/webalizer
.h
webalizer-2.23-05
/webalizer
.png
webalizer-2.23-05
/lang/
webalizer-2.23-05
/lang/webalizer_lang
.albanian
webalizer-2.23-05
/lang/webalizer_lang
.arabic
webalizer-2.23-05
/lang/webalizer_lang
.catalan
webalizer-2.23-05
/lang/webalizer_lang
.chinese
webalizer-2.23-05
/lang/webalizer_lang
.croatian
webalizer-2.23-05
/lang/webalizer_lang
.czech
webalizer-2.23-05
/lang/webalizer_lang
.danish
webalizer-2.23-05
/lang/webalizer_lang
.dutch
webalizer-2.23-05
/lang/webalizer_lang
.english
webalizer-2.23-05
/lang/webalizer_lang
.estonian
webalizer-2.23-05
/lang/webalizer_lang
.finnish
webalizer-2.23-05
/lang/webalizer_lang
.french
webalizer-2.23-05
/lang/webalizer_lang
.galician
webalizer-2.23-05
/lang/webalizer_lang
.german
webalizer-2.23-05
/lang/webalizer_lang
.greek
webalizer-2.23-05
/lang/webalizer_lang
.hungarian
webalizer-2.23-05
/lang/webalizer_lang
.icelandic
webalizer-2.23-05
/lang/webalizer_lang
.indonesian
webalizer-2.23-05
/lang/webalizer_lang
.italian
webalizer-2.23-05
/lang/webalizer_lang
.japanese
webalizer-2.23-05
/lang/webalizer_lang
.korean
webalizer-2.23-05
/lang/webalizer_lang
.latvian
webalizer-2.23-05
/lang/webalizer_lang
.lithuanian
webalizer-2.23-05
/lang/webalizer_lang
.malay
webalizer-2.23-05
/lang/webalizer_lang
.norwegian
webalizer-2.23-05
/lang/webalizer_lang
.polish
webalizer-2.23-05
/lang/webalizer_lang
.portuguese
webalizer-2.23-05
/lang/webalizer_lang
.portuguese_brazil
webalizer-2.23-05
/lang/webalizer_lang
.romanian
webalizer-2.23-05
/lang/webalizer_lang
.romanian-iso-8859-2
webalizer-2.23-05
/lang/webalizer_lang
.russian
webalizer-2.23-05
/lang/webalizer_lang
.serbian
webalizer-2.23-05
/lang/webalizer_lang
.simplified_chinese
webalizer-2.23-05
/lang/webalizer_lang
.slovak
webalizer-2.23-05
/lang/webalizer_lang
.slovene
webalizer-2.23-05
/lang/webalizer_lang
.spanish
webalizer-2.23-05
/lang/webalizer_lang
.swedish
webalizer-2.23-05
/lang/webalizer_lang
.thai
webalizer-2.23-05
/lang/webalizer_lang
.turkish
webalizer-2.23-05
/lang/webalizer_lang
.ukrainian
webalizer-2.23-05
/webalizer_lang
.h
[root@zabbix webalizer-2.23-05]
# ./configure --with-language=chinese
[root@zabbix webalizer-2.23-05]
# make
|
1
2
|
[root@zabbix soft]
# cd webalizer-2.23-05/lang
[root@zabbix soft]
# iconv -f gb2312 -t utf-8 -s -c --verbose webalizer_lang.simplified_chinese.bak -o webalizer_lang.simplified_chinese
|
说明:找到webalizer_lang.simplified_chinese 将文件格式转化为utf-8,可以借助外部工具,修改后放回即可。这里我使用EditPlus 3进行格式转换(文件用editplus打开-->文档-->文本编码-->转换文本编码-->选择编码方式为:utf-8-->保存),大家可以去网上下载一些软件,将文件格式转换即可,如无需汉化,此步骤可略过。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
[root@zabbix lang]
#cd ..
[root@zabbix lang]
# find / -name *.ttf
/data/php/fonts/DejaVuSans
.ttf
/tmp/install/zabbix-2
.0.8
/frontends/php/fonts/DejaVuSans
.ttf
/tmp/install/php-5
.5.28
/ext/gd/tests/Tuffy
.ttf
/tmp/install/php-5
.5.28
/ext/gd/tests/test8859
.ttf
/usr/java/jdk1
.8.0_51
/jre/lib/oblique-fonts/LucidaTypewriterOblique
.ttf
/usr/java/jdk1
.8.0_51
/jre/lib/oblique-fonts/LucidaTypewriterBoldOblique
.ttf
/usr/java/jdk1
.8.0_51
/jre/lib/oblique-fonts/LucidaSansOblique
.ttf
/usr/java/jdk1
.8.0_51
/jre/lib/oblique-fonts/LucidaSansDemiOblique
.ttf
/usr/java/jdk1
.8.0_51
/jre/lib/fonts/LucidaBrightRegular
.ttf
/usr/java/jdk1
.8.0_51
/jre/lib/fonts/LucidaBrightItalic
.ttf
/usr/java/jdk1
.8.0_51
/jre/lib/fonts/LucidaBrightDemiItalic
.ttf
/usr/java/jdk1
.8.0_51
/jre/lib/fonts/LucidaBrightDemiBold
.ttf
/usr/java/jdk1
.8.0_51
/jre/lib/fonts/LucidaSansRegular
.ttf
/usr/java/jdk1
.8.0_51
/jre/lib/fonts/LucidaSansDemiBold
.ttf
/usr/java/jdk1
.8.0_51
/jre/lib/fonts/LucidaTypewriterRegular
.ttf
/usr/java/jdk1
.8.0_51
/jre/lib/fonts/LucidaTypewriterBold
.ttf
|
[root@zabbix lang]#cd ..
编辑graphs.c添加一下语句
void gdImageString(gdImagePtr im, gdFontPtr font, int x, int y, unsigned char *s, int color)
{
gdImageStringFT(im, 0 , color, "/data/php/fonts/DejaVuSans.ttf", 9 , 0.0, x, y+9, s); // 注意这里修改成你自己字体路径
}
void gdImageStringUp(gdImagePtr im, gdFontPtr font, int x, int y, unsigned char *s, int color)
{
gdImageStringFT(im, 0 , color, "/data/php/fonts/DejaVuSans.ttf", 9 , -PI/2, x, y-9 , s);
本文转自 lqbyz 51CTO博客,原文链接:http://blog.51cto.com/liqingbiao/1749966