linux
下
MRTG
搭建实验文档
os
版本
:
Rad Hat Enterprise Linux 5
还须要有
apache
的支持
,
本次试验
apache
安装在
/usr/local/apache
下
所需软件安装包以下
,
均为源代码安装包
gd-
2.0.33
.tar.gz
zlib-
1.2.3
.tar.gz
libpng-
1.2.15
.tar.gz
jpegsrc.v6b.tar.gz
freetype-
2.1.9
.tar.gz
fontconfig-
2.3.2
.tar.gz
mrtg-
2.13.2
.tar.gz
1、安装在
MRTG
所需的组件
1
、安装
GD
库
安装命令以下
tar -zxvf gd-
2.0.33
.tar.gz
cd gd-
2.0.33
./configure
若是在输出信息中以下图
Support for PNG library: no
Support for JPEG library: no
Support for Freetype 2.x library: no
Support for Fontconfig library: no
Support for Xpm library: no
Support for pthreads: yes
若是都显示的为
yes
,咱们就能够直接去装
MRTG
了,这次环境中只有
一项显示为
yes,
因此还要安装其组件
2
、安装
zlib
库
tar -xvf zlib-
1.2.3
.tar.gz
cd zlib-
1.2.3
./configure
make
make install
3.
安装
libpng
库
tar -zxvf libpng-
1.2.15
.tar.gz
cd libpng-
1.2.15
./configure
cp scripts/makefile.std makefile(
能够不要
)
make
make install
4
、安装
JPEG
库
tar -zxvf jpegsrc.v6b.tar.gz
cd jpeg-6b
./configure --enable-static --enable-shared
必须有
make
make install
5
、安装安装
Freetype
tar -zxvf freetype-
2.1.9
.tar.gz
cd freetype-
2.1.9
./configure
make
make install
6
、安装
Fontconfig
(若是提示
expat to old,
则安装
expat
和
expat-devel
)
tar -zxvf fontconfig-
2.3.2
.tar.gz
cd fontconfig-
2.3.2
.tar.gz
./configure
make
make install
7
、编译
GD
库
cd gd-
2.0.33
./configure
make
make install
2、安装
mrtg
tar -zxvf mrtg-
2.13.2
.tar.gz
cd mrtg-
2.13.2
./configure --prefix=/usr/local/mrtg --with-gd=/usr/include --with-gd-lib=/usr/lib --with-gd-inc=/usr/include --with-png=/usr/include --with-png-lib=/usr/lib --with-zlib=/usr/include --with-zlib-lib=/usr/lib
make
make install
3、调整参数,对端口进行流量监控
1
、
生成
mrtg.cfg
文件,用于存放
mrtg
配置信息
/usr/local/mrtg/bin/cfgmake —output /usr/local/apache/htdocs/mrtg.cfg public@121.52.209.160 laoda@121.52.214.63 public@121.52.214.10
2
、修改
mrtg.cfg
文件参数
vi /usr/local/apache/htdocs/mrtg.cfg
把
#
去掉
把
Workdir
后的路径改为
/usr/local/apache/htdocs
:指定
mrtg
的工做目录
把
#Options[_]: growright, bits
:前面的
#
去掉
在加入一行
Language:Chinese
:使
mrtg
支持中文
3
、
env LANG=C /usr/local/mrtg/bin/mrtg /usr/local/apache/htdocs/mrtg.cfg
:多执行几遍,直到不出现信息
4
、生成页面文件
/usr/local/mrtg/bin/indexmaker --output /usr/local/apache/htdocs/index.html --title=ruishengIDC /usr/local/apache/htdocs/mrtg.cfg
(中间的参数能够省略)
5
、让数据自动刷新
crontab -e
而后写入
*/5 * * * * env LANG=C /usr/local/mrtg/bin/mrtg /usr/local/apache/htdocs/mrtg.cfg (
注:如以前未加
env LANG=C
的话,则这里也不用加)
,
意思为让系统在后台每五分钟执行一次
env LANG=C /usr/local/mrtg/bin/mrtg /usr/local/apache/htdocs/mrtg.cfg)
注:第三块调整参数时有前后顺序,如只出来的图上没有显示流量有多是步骤执行前后错误,使用
rm -f /usr/local/apache/htdocs/.mrtg.cfg.swp
清除一下缓存,而后在按照顺序执行一下便可