Monday, April 11, 2011

How To: MRTG 2.17.2 + RRD Tool 1.4.5 on CentOS 5.5

Open Terminal & run each command below:


[root]# yum install -y gcc gd gd-devel perl libpng
[root]# wget http://oss.oetiker.ch/mrtg/pub/mrtg.tar.gz
[root]# tar zfx mrtg.tar.gz
[root]# cd mrtg-2.17.2
[root]# ./configure --prefix=/usr/local/mrtg2
[root]# make
[root]# make install
[root]# wget http://oss.oetiker.ch/rrdtool/pub/rrdtool.tar.gz
[root]# tar zfx rrdtool.tar.gz
[root]# cd rrdtool-1.4.5
[root]# ./configure --prefix=/usr/local/rrdtool
[root]# yum install libxml2-devel cairo-devel glib2-devel pango-devel
[root]# make
[root]# make install
[root]# mkdir /var/www/mrtg /home/mrtg
[root]# /usr/local/mrtg2/bin/cfgmaker --global "WorkDir: /var/www/mrtg" --global "Options[_]: growright, bits" --global "RunAsDaemon: Yes" --global "LogFormat: rrdtool" --global "PathAdd: /usr/local/rrdtool/bin" --global "LibAdd: /usr/local/rrdtool/lib/perl/5.8.8" -ifref=ip --output /home/mrtg/mrtg.cfg PublicASA@192.168.255.36
[root]# env LANG=C /usr/local/mrtg2/bin/mrtg /home/mrtg/mrtg.cfg
[root]# gedit /etc/cron.d/mrtg


##Add/Edit as below##
*/5 * * * * root env LANG=C /usr/local/mrtg2/bin/mrtg /home/mrtg/mrtg.cfg --logging /var/log/mrtg.log
##Save & Close##


[root]# chkconfig crond on
[root]# /usr/local/mrtg2/bin/indexmaker --output=/var/www/mrtg/index.html /home/mrtg/mrtg.cfg
[root]# gedit /etc/httpd/conf.d/mrtg.conf


##Add/Edit as below##
Alias /mrtg /var/www/mrtg

    Order deny,allow
    Deny from all
    Allow from 127.0.0.1 172.26.20.0/24
    Allow from ::1

##Save & Close##


[root]# chkconfig --add httpd
[root]# chkconfig httpd on
[root]# service httpd restart
[root]# wget http://nchc.dl.sourceforge.net/project/my14all/14all/1.1p25/14all-1.1p25.tar.gz
[root]# tar zfx 14all-1.1p25.tar.gz
[root]# cd 14all
[root]# cp 14all.cgi /var/www/cgi-bin
[root]# gedit /var/www/cgi-bin/14all.cgi


##Add/Edit as below##
use lib qw(/usr/local/mrtg2/lib/mrtg2);
$cfgfile = 'mrtg.cfg';
$cfgfiledir = '/home/mrtg';
##Save & Close##


##DONE##


Open browser & go to http://localhost/mrtg/


##Add/Edit /var/www/mrtg/index.html as you need##


#END#