MRTG 安装手顺
一、安装环境及所需软件:
OS:RedHat AS 4.0
MRTG:mrtg-2.16.1.zip
zlib:zlib-1.1.4.tar.gz
libnp:libpng-1.0.15.tar.gz
gd:gd-2.0.11.tar.gz
apache2: httpd-2.2.8.tar.gz
二、安装手顺
zlib:
tar xzvf zlib-1.1.4.tar.gz
cd zlib-1.1.4
mv zlib-1.1.4 zlib
./configure && make
libpng:
tar xzvf libpng-1.0.15.tar.gz
mv libpng-1.0.15.tar.gz libpng
cd libpng
make -f scripts/makefile.std CC=gcc ZLIBLIB=../zlib ZLIBINC=../zlib
rm *.so.* *.so
gd:
tar xzvf gd-2.0.11.tar.gz
mv gd-2.0.11.tar.gz gd
cd gd
CPPFLAGS="-I../zlib -I../libpng" LDFLAGS="-L../zlib -L../libpng"
./configure --disable-shared --without-freetype --without-jpeg
make
cp .libs/* .
httpd:
tar xzvf httpd-2.2.8.tar.gz
cd httpd-2.2.8
./configure
make
make install
rrdtool:
rrdtool-1.2.27.tar.gz
tar xzvf rrdtool-1.2.27.tar.gz
cd rrdtool-1.2.27
./configure --prefix=/usr/local/rrdtool --disable-tcl
make
make install
14all:
14all-1.1p25.tar.gz
tar xzvf 14all-1.1p25.tar.gz
cd 14all-1.1p25
cp ./14all-1.1p25.cgi /usr/local/apache2/htdocs/cgi-bin
chmod 755 /usr/local/apache2/htdocs/cgi-bin/14all-1.1p25
chmod 777 /usr/local/mrtg-2/ -R
安装mrtg:
tar xzvf mrtg-2.16.1.zip
unzip mrtg-2.6.1.zip
cd mrtg-2.16.1
./configure --prefix=/usr/local/mrtg-2 \
--with-gd=/usr/local/src/gd \
--with-z=/usr/local/src/zlib \
--with-png=/usr/local/src/libpng
make && make install
配置mrtg:
cfgmaker --global 'WorkDir: /usr/local/apache2/htdocs/mrtg' \
--global 'Options[_]: bits,growright' \
--output /usr/local/mrtg-2/cfg/mrtg.cfg \
启动SNMP
vi /etc/snmpd/snmpd.conf
添加:
view systemview included .1
access notConfigGroup "" any noauth exact mib2 none none
view all included .1 80
view mib2 included .iso.org.dod.internet.mgmt.mib-2 fc
/etc/init.d/snmpd start
mkdir -p /home/mrtg/cfg/mrtg
./cfgmaker --global "WorkDir: /usr/local/apache2/htdocs/mrtg" --global "Options[_]: bits,growright" --output /usr/local/mrtg-2/cfg/mrtg.cfg
添加对RRDTOOL的支持:
vi /usr/local/mrtg-2/cfg/mrtg.cfg
LogFormat: rrdtool
PathAdd: /usr/local/rrdtool/bin/
LibAdd: /usr/local/rrdtool/lib/perl/
部署cron
crontab -e
*/5 * * * * /usr/local/mrtg-2/bin/mrtg /usr/local/mrtg-2/cfg/mrtg.cfg --logging /var/log/mrtg.log 2>&1
/usr/local/mrtg-2/bin/indexmaker --output=/usr/local/apache2/htdocs/mrtg/index.html /usr/local/mrtg-2/cfg/mrtg.cfg
安装14all.cgi
cp ./14all-1.1p25.cgi /usr/local/apache2/htdocs/cgi-bin
vi /usr/local/apache2/htdocs/cgi-bin/14all.1.1p25.cgi
变更如下:
chmod 755 /usr/local/apache2/htdocs/cgi-bin/14all-1.1p25
chmod 777 /usr/local/mrtg-2/ -R
测试URL:
添加自定义服务:
vi /usr/local/mrtg-2/cfg/mrtg.cfg
添加以下内容:
Target[cpu]: `/usr/local/mrtg-2/bin/cpu.sh`
MaxBytes[cpu]: 125000
Title[cpu]: CPU -- localhost_2
Options[cpu]: gauge,nopercent,growright
YLegend[cpu]: CPU loading (%)
ShortLegend[cpu]:%
LegendO[cpu]: & PROCESS NUMBER;
LegendI[cpu]: & CPU SYSTEM;
Legend2[cpu]: & PROCESS NUMBER;
Legend1[cpu]: & CPU SYSTEM;
PageTop[cpu]:
;CPU -- localhost_2
;
cpu.sh
#!/bin/bash
cpuusr=`top -b -n1 |grep Cpu |awk '{print $2}'`
process_number=`ps auxwww |wc -l`
echo $process_number
echo $cpusys
重新生成网页文件:
/usr/local/mrtg-2/bin/indexmaker --output=/usr/local/apache2/htdocs/mrtg/index.html /usr/local/mrtg-2/cfg/mrtg.cfg
Target:是要执行的脚本
Xsize:生成图表的横向宽度(最大600)
Ysize:生成图表的纵向高度(最大200)
Title:标题
kMG: Change the default multiplier prefixes
Ytics:纵向划分为几个块(格子)
MaxBytes:图表纵向数值的最大上限
PageTop:页面上面的提示
kilo:一般是写1024,如果需要的话,是1000在计算机里的单位
Legend1:(LegendI)标识说明
Legend2:(LegendO)标识说明
LegendI:从SHELL返回的数据中的第一个
LegendO:从SHELL返回的数据中的第二个
Options: growright,表示图表向右延展
监控网络设备:
安装
routers2-v2.17:
tar xzvf routers2-v2.17.tar.gz
cd routers2-v2.17
./install.pl
根据提示回答:
INSTALLING SOFTWARE
Perl is : /usr/bin/perl
MRTG files : /usr/local/mrtg-2/cfg/*.cfg
RRD files : /usr/local/apache2/htdocs/mrtg
Doc root : /usr/local/apache2/htdocs
CGI bin : /usr/local/apache2/cgi-bin
Config file : /usr/local/apache2/htdocs/mrtg/routers2.conf
Routingtable: INACTIVE
Compact page: ENABLED
Caching : DISABLED
'usebigk' : yes
Auth option : NONE
Mail Steve : no
Other options can be set later by modifying the Config file
Continue to install [no]? yes
可能出现can’t locate RRDs.pm错误,修改生成的mrtg文件,查找LibAdd,修改为:
vi /usr/local/mrtg-2/mrtg/cfg/mrtg.cfg
LibAdd: /usr/local/rrdtool/lib/perl/5.8.5/i386-linux-thread-multi
url:
阅读(1247) | 评论(0) | 转发(0) |