Linux Troubleshooting Make Easy.

Linux Learning & Troubleshooting Make Easy.

Install and Configure MRTG


Its Compatible with  RHEL / CentOS and Fedora Linux.

MRTG generates Html pages containing Png images which provide a Live visual representation of this traffic.

Required Packages:
    #  mrtg : Multi Router Traffic Grapher
    #  net-snmp and net-snmp-utils : SNMP (Simple Network Management Protocol) is a protocol used
        for network management. The NET-SNMP project includes various SNMP tools.




Install MRTG and dependancy packages :
#  yum install mrtg net-snmp net-snmp-utils

To monitor localhost including interface and other stuff such as CPU, memory etc, configure snmpd.
Edit the file /etc/snmp/snmpd.conf:
#  vi /etc/snmp/snmpd.conf

Update it as follows to only allow access from localhost:

   com2sec local     localhost           public
   group MyRWGroup v1         local
   group MyRWGroup v2c        local
   group MyRWGroup usm        local
   view all    included  .1                               80
   access MyRWGroup ""      any       noauth    exact  all    all    none
   syslocation Bangalore, India
   syscontact Root <shekar@mydomain.com>

Save and close the file. Restart snmpd:
#  chkconfig snmpd on
#  service snmpd restart

Make sure you see interface IP:
# snmpwalk -v 1 -c public localhost IP-MIB::ipAdEntIfIndex

Configure MRTG Service:

Use cfgmaker command to creates /etc/mrtg/mrtg.cfg file:
#  cfgmaker --global 'WorkDir: /var/www/mrtg' --output /etc/mrtg/mrtg.cfg public@localhost

    #!  --global 'WorkDir: /var/www/mrtg' : add global config entries to set workdir to store MRTG graphs.
    #! --output /etc/mrtg/mrtg.cfg: configr output filename
    #!  public@localhost : public is the community name of the device you want to create a configuration for.
         If you are using the wrong community name you will get no response from the device.

Run indexmaker to create web pages which display the status of an array of mrtg interface status pages:
#  indexmaker --output=/var/www/mrtg/index.html /etc/mrtg/mrtg.cfg

Verify Cron Job:
/etc/cron.d/mrtg runs mrtg command to monitor the traffic load on network links:
#  cat /etc/cron.d/mrtg

Just make sure crond is running and you are done with configuration:
#  chkconfig --list crond

You need Apache web server to view graphs, simply type the following to install httpd:
# yum install httpd
# chkconfig httpd on
# service httpd on


Enter the URL in your webbrowser :

http://your-ip.address/mrtg/


No comments: