MRTG Setup Step by Step in RHEL 5

MRTG Setup Step by Step in RHEL 5



First of all install the Packages: -





Then modify the snmp.conf file

mv /etc/snmp/snmp.conf /etc/snmp/snmp.conf.bk

Then again create this file & write the community string in it

vim /etc/snmp/snmp.conf

Write the community string & save the file.

rocommunity public

Now restart the service snmpd twice with following command

Service snmpd restart

Start this service at boot time also

chkconfig --level 35 snmpd on

Now check if as the snmp is working properly & to check the ip status give following command

snmpwalk -v 1 -c public localhost IP-MIB::ipAdEntIfIndex

If the out put displays like under mentioned lines then your configuration is correct.

IP-MIB::ipAdEntIfIndex. = INTEGER: 1

IP-MIB::ipAdEntIfIndex. = INTEGER: 2

Now the time is to configure your mrtg. So play the cfgmaker command like this

cfgmaker --ifref=ip --ifdesc=ip --global=”WorkDir: /var/www/mrtg” --global=”Options[_]: growright, bits”

--output=/etc/mrtg/mrtg.cfg public@localhost

Now open the configuration file & configure your Ethernet

vim /etc/mrtg/mrtg.cfg

Here you uncomment the section of your Ethernet & also give the value above 0 in front of MaxBytes. Here I am giving a sample configuration of Ethernet section for your convenience.

Target[localhost_192.168.0.31]: /

SetEnv[localhost_192.168.0.31]: MRTG_INT_IP="" MRTG_INT_DESCR="eth0"

MaxBytes[localhost_192.168.0.31]: 1000

Title[localhost_192.168.0.31]: --

PageTop[localhost_192.168.0.31]: <h1> --</h1>

<div id="sysdetails">




<td> in Unknown</td>








<td>eth0 </td>




<td>ethernetCsmacd (6)</td>







<td>Max Speed:</td>

<td>0.0 bits/s</td>




<td> (</td>




Now in this way your mrtg configuration is complete now play the indexmaker command to generate the index.html file

indexmaker /etc/mrtg/mrtg.cfg > /var/www/mrtg/index.html

If you find no errors after this command it means you have successfully configured mrtg & if you find any errors it means there is something left to configure in your /etc/mrtg/mrtg.cfg file. Now there is a command left for the last step of mrtg. The command is as under.

mrtg /etc/mrtg/mrtg.cfg

You will find error here and it will tell you the right syntax of your command in the last line of error report, which will be this.

env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg --logging /var/log/mrtg.log

Address for logs in this command is added additional it is for the convenience of seeing logs for mrtg. If this command gives you some errors then don’t worry & play this command twice again. If command returns silence & doesn’t report any error it means your command is played successful.

Now place the entry of this command in crontab file.

crontab –e

*/5 * * * * env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg --logging /var/log/mrtg.log

save the file & exit.

Now it is time to configure your httpd setting, open its configuration file & configure it like this

vim /etc/httpd/conf.d/mrtg.conf

<location /mrtg>

Order deny,allow

Deny from all

Allow from

# Allow from ::1

# Allow from


Now restart the service httpd twice with following command

service httpd restart

Start this service at boot time also

Chkconfig --level 35 httpd on

Now your configurations is complete open your web browser & write in its address bar the address of your server & it will open mrtg graph for you. The address command is as under: --


If you feel any difficulty in configuration please don’t hesitate to contact.


Athar Hussain

System Administrator

Worth Agro Chemicals