Tuesday, May 27, 2008

MRTG - The Multi Router Traffic Grapher

MRTG applications is useful to monitor network and as well as servers utilizations( like CPU, Memory, Disk etc) by seeing MRTG graphs.

MIB MRTG refers to MIB ( Residing in memory, MIBs are data structures that are constantly updated via the SNMP daemon ) counter values as counter values.

Dependencies of MRTG


Configuring Simple SNMP on a Linux Server

1) Save the old configuration file

[root@leo]# cd /etc/snmp/
[root@leo]# mv snmpd.conf snmpd.conf.old
[root@leo]# vi snmpd.conf

2) Enter the following line in the new configuration file to set the Read Only community string to secrect123.

###snmpd.conf file ########

rocommunity secrect123

## source community
## ======== ====== =========
com2sec local localhost secrect123
com2sec network_1 secrect123
com2sec network_2 secrect123

## sec.model
## ================= ========= ========
group MyROGroup_1 v1 local
group MyROGroup_1 v1 network_1
group MyROGroup_2 v2c network_2

## incl/excl MIB.subtree mask
## ============== ========= =========== ====
view all-mibs included .1 80

## MIB
## context sec.model sec.level prefix read write notif
## ========== ======= ========= ========= ====== ==== ===== =====
access MyROGroup_1 "" v1 noauth exact all-mibs none none
access MyROGroup_2 "" v2c noauth exact all-mibs none none

3) start SNMP services on each reboot with the chkconfig command

[root@leo]# chkconfig snmpd on

4) Start SNMP to load the current configuration file.

[root@leo]# service snmpd start

5) Test SNMP

[root@leo]# snmpwalk -v 1 -c secrect123 localhost system

[root@leo]# snmpwalk -v 1 -c secrect123 localhost interface

Configuring MRTG

1) Use MRTG's cfgmaker command to create a configuration file named mrtg.cfg for the server using a Read Only community string of secrect123. Place all data files in the directory /var/www/mrtg.

[root@leo]# cfgmaker --output=/etc/mrtg/mrtg.cfg \
--global "workdir: /var/www/mrtg" -ifref=ip \
--global 'options[_]: growright,bits' \secrect123@localhost

2) Use MRTG's indexmaker command to create a Web index page using your new mrtg.cfg file as a guide. The MRTG Web GUI expects to find the index file in the default MRTG Web directory of /var/www/mrtg/, so the format of the command would be.

[root@leo]# indexmaker --output=/var/www/mrtg/index.html \ /etc/mrtg/mrtg.cfg

3) Add MRTG line in /etc/cron.d/mrtg and restart crond daemon

0-59/5 * * * * root env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg

4) Run MRTG using /etc/mrtg/mrtg.cfg as your argument three times.

[root@leo]# env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
[root@leo]# env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
[root@leo]# env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg

Configuring Apache To Work With MRTG

MRTG is useful because it can provide a graphical representation of your server's performance statistics via a Web browser.

#add lines at end to /etc/httpd/conf/httpd.conf

< Location /mrtg >
Order deny,allow
Deny from all
Allow from localhost
< /Location >

2) restart httpd daemon to run with new configuration

3) URL : http://localhost/mrtg

No comments: