Basic MRTG configuration for monitoring network interfaces

From Notes_Wiki

Home > CentOS > CentOS 6.x > Monitoring tools > MRTG configuration > Basic MRTG configuration for monitoring network interfaces

Use of cacti is recommended over trying to use MRTG


Steps to configure basic MRTG based monitoring server are:

  1. Use command 'snmpwalk -v 1 -c <community> <hostname> IP-MIB::ipAdEntIfIndex' to query SNMP server and list set of IP addresses assigned to host / router. If it does not lists anything then we need to configure SNMP server for hosts as mentioned at SNMP server configuration for Linux hosts or for switches as mentioned at Configuring cisco switch as SNMP server
  2. Ensure that package 'mrtg' is installed.
  3. For each host to be monitored follow these steps:
    1. Create host specific document root using 'mkdir /var/www/html/<IP or name>'
    2. Create configuration file using
      cfgmaker --global 'WorkDir: /var/www/html/<IP or name>' --output /etc/mrtg/<IP or name>.cfg <community>@<IP or FQDN>
    3. Create index page for MRTG configuration
      indexmaker --output=/var/www/html/<IP or name>/index.html /etc/mrtg/<IP or name>.cfg
    4. Copy mrtg png files to document root using 'cp /var/www/mrtg/* /var/www/html/<IP or name>/'
    5. Run mrtg few times using:
      env LANG=C /usr/bin/mrtg /etc/mrtg/<IP or name>.cfg
      ignore errors shown during first few runs
    6. Use 'service httpd start' to start web server if it is not already running.
    7. Test pages by visiting 'http://<MRTG server IP>/<Monitored host IP or name>/index.html'
    8. If everything is fine add following cron entry using 'crontab -e' command
      */5 * * * * env LANG=C /usr/bin/mrtg /etc/mrtg/<IP or name>.cfg -logging /var/log/mrtg.log
    9. Optionally restrict to MRTG graphs using apache '.htaccess' configuration. Create file '/var/www/html/<IP or NAME>/.htaccess' with following lines
      AuthName "MRTG Graphs/Html restricted access"
      AuthType Basic
      AuthUserFile /var/members/.htpasswd
      require user mrtgadmin
    10. To create '/var/members/.htpasswd' file use: (one time only)
      htpasswd -c /var/members/.htpasswd mrtgadmin
    11. In case server is not asking password then add following to '/etc/httpd/conf/httpd.conf'
      <Directory "/var/www/html/<IP or Name>">
      Options All
      AllowOverride All
      </Directory>
      and then do 'service httpd reload'


Note: Running MRTG like this is not efficient. One should use 'rrdtool' if we want to monitor many different hosts using MRTG.

Steps have been learned from http://www.cyberciti.biz/nixcraft/linux/docs/uniqlinuxfeatures/mrtg/


Home > CentOS > CentOS 6.x > Monitoring tools > MRTG configuration > Basic MRTG configuration for monitoring network interfaces