Basic MRTG configuration for monitoring network interfaces
From Notes_Wiki
<yambe:breadcrumb>MRTG configuration</yambe:breadcrumb>
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:
- 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
- Ensure that package 'mrtg' is installed.
- For each host to be monitored follow these steps:
- Create host specific document root using 'mkdir /var/www/html/<IP or name>'
- Create configuration file using
- cfgmaker --global 'WorkDir: /var/www/html/<IP or name>' --output /etc/mrtg/<IP or name>.cfg <community>@<IP or FQDN>
- Create index page for MRTG configuration
- indexmaker --output=/var/www/html/<IP or name>/index.html /etc/mrtg/<IP or name>.cfg
- Copy mrtg png files to document root using 'cp /var/www/mrtg/* /var/www/html/<IP or name>/'
- Run mrtg few times using:
- env LANG=C /usr/bin/mrtg /etc/mrtg/<IP or name>.cfg
- ignore errors shown during first few runs
- Use 'service httpd start' to start web server if it is not already running.
- Test pages by visiting 'http://<MRTG server IP>/<Monitored host IP or name>/index.html'
- 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
- 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
- To create '/var/members/.htpasswd' file use: (one time only)
- htpasswd -c /var/members/.htpasswd mrtgadmin
- 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/
<yambe:breadcrumb>MRTG configuration</yambe:breadcrumb>