MRTG Setup Step by Step in RHEL 5

MRTG Setup Step by Step in RHEL 5

MRTG SETUP STEP BY STEP

RHEL 5

First of all install the Packages: -

net-snmp

net-snmp-utils

mrtg

httpd

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.127.0.0.1 = INTEGER: 1

IP-MIB::ipAdEntIfIndex.192.168.0.31 = 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]: /192.168.0.31:public@localhost:

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

MaxBytes[localhost_192.168.0.31]: 1000

Title[localhost_192.168.0.31]: 192.168.0.31 -- server.younisbrothers.com

PageTop[localhost_192.168.0.31]: <h1>192.168.0.31 -- server.younisbrothers.com</h1>

<div id="sysdetails">

<table>

<tr>

<td>System:</td>

<td>server.younisbrothers.com in Unknown</td>

</tr>

<tr>

<td>Maintainer:</td>

<td>root@localhost</td>

</tr>

<tr>

<td>Description:</td>

<td>eth0 </td>

</tr>

<tr>

<td>ifType:</td>

<td>ethernetCsmacd (6)</td>

</tr>

<tr>

<td>ifName:</td>

<td>eth0</td>

</tr>

<tr>

<td>Max Speed:</td>

<td>0.0 bits/s</td>

</tr>

<tr>

<td>Ip:</td>

<td>192.168.0.31 (server.younisbrothers.com)</td>

</tr>

</table>

</div>

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 127.0.0.1 192.168.0.0/24

# Allow from ::1

# Allow from .example.com

</Location>

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: --

or

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

Regards,

Athar Hussain

System Administrator

Worth Agro Chemicals

Cell:0302-8653620

0333-6294820