linux下MRTG搭建
还需要有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
一、安装在MRTG所需的组件
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
- 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(freetype-devel fontconfig-devel )
tar -zxvf fontconfig-2.3.2.tar.gz
cd fontconfig-2.3.2.tar.gz
- ./configure
- make
- make install
7、编译GD库
安装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,所以还要安装其组件
- make
- make install
二、安装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
三、调整参数,对端口进行流量监控
1、 生成mrtg.cfg文件,用于存放mrtg配置信息
- /usr/local/mrtg/bin/cfgmaker --output /usr/local/apache/htdocs/mrtg.cfg public@121.52.209.160 (public为SNMP团体名称,ip为被监控的设备。)
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
【编辑推荐】