Installing and Configuring MRTG + SNMP on CentOS 6
1. Install utilities:
yum install net-snmp net-snmp-utils net-snmp-devel zlib libpng gd mrtg
After installation, we have the following configuration files:
/etc/snmpd/snmpd.conf /etc/mrtg/mrtg.cfg /etc/cron.d/mrtg /etc/httpd/conf.d/mrtg.conf
2. Editing SNMP config /etc/snmpd/snmpd.conf
nano /etc/snmpd/snmpd.conf
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 Russia syscontact Root
3. Add the snmp service to startup and start
chkconfig snmpd on service snmpd restart
4. Checking
snmpwalk -v 1 -c public localhost IP-MIB::ipAdEntIfIndex
the answer should be like this:
IP-MIB::ipAdEntIfIndex.123.xx.yy.zzz = INTEGER: 2 IP-MIB::ipAdEntIfIndex.127.0.0.1 = INTEGER: 1
5. Configuring MRTG create a settings file /etc/mrtg/mrtg.cfg
cfgmaker --global 'WorkDir: /var/www/mrtg' --output /etc/mrtg/mrtg.cfg [email protected]
Let’s check the contents of /etc/mrtg/mrtg.cfg, look for WorkDir there and specify the correct path
WorkDir: /var/www/mrtg
6. Create the index.html file based on our /etc/mrtg/mrtg.cfg configuration file
indexmaker --output=/var/www/mrtg/index.html /etc/mrtg/mrtg.cfg
7. Checking the Cron Tab
cat /etc/cron.d/mrtg
The content should be like this:
*/5 * * * * root LANG=C LC_ALL=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg --lock-file /var/lock/mrtg/mrtg_l --confcache-file /var/lib/mrtg/mrtg.ok
Check if Cron Tab has been added to startup:
chkconfig --list crond
Output:
crond 0:выкл 1:выкл 2:вкл 3:вкл 4:вкл 5:вкл 6:выкл
If Cron Tab is not running and not added to startup, fix it:
chkconfig crond on service crond start
8.configure Apache /etc/httpd/conf.d/mrtg.conf
nano /etc/httpd/conf.d/mrtg.conf
Alias /mrtg /var/www/mrtg Order deny,allow Deny from all Allow from 127.0.0.1 Allow from ::1 # Allow from .example.com
127.0.0.1 change to ip, which is allowed to watch the result
Restart Apache
service httpd restart
9. Done, see the result
http://ваш_ip/mrtg/