Last Updated on 2 weeks by Sachin G

​The article provides steps for setting up the Multi Router Traffic Grapher (MRTG) on various Linux distributions. It outlines the necessary steps, including installing the EPEL repository, updating package repositories, installing the Apache web server, and configuring SNMP.

STEP 1: Install EPEL Repository

Click on the link below and install the EPEL repository according to your operating system.

Setup EPEL YUM Repositories on CentOS RHEL Fedora Linux

STEP 2:  Update Package Repositories:

Make sure your system’s package repositories are up to date by running the following commands:

Here we are creating a basic installation of the Apache web server.

STEP 3:  Install the Apache web server.

#yum -y install httpd

Start the Apache web service.

#systemctl start httpd.service

Enable service on auto boot

#systemctl enable httpd.service

STEP 3:  Install MRTG through YUM

command below is for the mrtg and snmp installation utility and dependency.

# yum -y install net-snmp mrtg net-snmp-utils

STEP 4: Configure SNMP 

For monitor network interface and other resources like CPU , memory , we should configure snmpd “/etc/snmp/snmpd.conf” .

STEP 5 : Edit the configuration file.

# vim /etc/snmp/snmpd.conf

Now make change as i have describe below.

(a) comment the line with hash on line number 41 like below.

# com2sec notConfigUser default public

(b) uncomment  the line number 74,75  ,remove NETWORK/24 and replace with your network.

Before changes

#com2sec local localhost COMMUNITY
#com2sec mynetwork NETWORK/24 COMMUNITY
After Changes 
com2sec local localhost techtransit
com2sec mynetwork 172.24.0.0/24 techtransit

(c) un comment  the line 78,79 . Replace techtransit from your any word.

group MyRWGroup v2c local
group MyROGroup v2c mynetwork

(d) uncomment the line 85 .

view all included  .1  80

(f) uncomment the line 93,94 . Replace techtransit from your name.

access MyROGroup "" v2c noauth 0 all none none
access MyRWGroup "" v2c noauth 0 all all all

STEP 6 : Start the snmpd service and enable it from autoboot.

#systemctl start snmpd.service

#systemctl enable snmpd.service

STEP 7 :

# show status (replace the “techtransit” to your comunity name)
[root@server ~]# snmpwalk -v2c -c techtransit localhost system
SNMPv2-MIB::sysDescr.0 = STRING: Linux server.techtransit.org 3.10.0-229.14.1.el7.x86_64 #1 SMP Tue Sep 15 15:05:51 UTC 2015 x86_64
SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.10
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (8004) 0:01:20.04
SNMPv2-MIB::sysContact.0 = STRING: Root <root@localhost> (configure /etc/snmp/snmp.local.conf)
SNMPv2-MIB::sysName.0 = STRING: server.techtransit.org
SNMPv2-MIB::sysLocation.0 = STRING: Unknown (edit /etc/snmp/snmpd.conf)
SNMPv2-MIB::sysORLastChange.0 = Timeticks: (2) 0:00:00.02
SNMPv2-MIB::sysORID.1 = OID: SNMP-MPD-MIB::snmpMPDCompliance
SNMPv2-MIB::sysORID.2 = OID: SNMP-USER-BASED-SM-MIB::usmMIBCompliance
SNMPv2-MIB::sysORID.3 = OID: SNMP-FRAMEWORK-MIB::snmpFrameworkMIBCompliance
SNMPv2-MIB::sysORID.4 = OID: SNMPv2-MIB::snmpMIB
SNMPv2-MIB::sysORID.5 = OID: TCP-MIB::tcpMIB
SNMPv2-MIB::sysORID.6 = OID: IP-MIB::ip
SNMPv2-MIB::sysORID.7 = OID: UDP-MIB::udpMIB
SNMPv2-MIB::sysORID.8 = OID: SNMP-VIEW-BASED-ACM-MIB::vacmBasicGroup
SNMPv2-MIB::sysORID.9 = OID: SNMP-NOTIFICATION-MIB::snmpNotifyFullCompliance
SNMPv2-MIB::sysORID.10 = OID: NOTIFICATION-LOG-MIB::notificationLogMIB
SNMPv2-MIB::sysORDescr.1 = STRING: The MIB for Message Processing and Dispatching.
SNMPv2-MIB::sysORDescr.2 = STRING: The management information definitions for the SNMP User-based Security Model.
SNMPv2-MIB::sysORDescr.3 = STRING: The SNMP Management Architecture MIB.
SNMPv2-MIB::sysORDescr.4 = STRING: The MIB module for SNMPv2 entities
SNMPv2-MIB::sysORDescr.5 = STRING: The MIB module for managing TCP implementations
SNMPv2-MIB::sysORDescr.6 = STRING: The MIB module for managing IP and ICMP implementations
SNMPv2-MIB::sysORDescr.7 = STRING: The MIB module for managing UDP implementations
SNMPv2-MIB::sysORDescr.8 = STRING: View-based Access Control Model for SNMP.
SNMPv2-MIB::sysORDescr.9 = STRING: The MIB modules for managing SNMP Notification, plus filtering.
SNMPv2-MIB::sysORDescr.10 = STRING: The MIB module for logging SNMP Notifications.
SNMPv2-MIB::sysORUpTime.1 = Timeticks: (2) 0:00:00.02
SNMPv2-MIB::sysORUpTime.2 = Timeticks: (2) 0:00:00.02
SNMPv2-MIB::sysORUpTime.3 = Timeticks: (2) 0:00:00.02
SNMPv2-MIB::sysORUpTime.4 = Timeticks: (2) 0:00:00.02
SNMPv2-MIB::sysORUpTime.5 = Timeticks: (2) 0:00:00.02
SNMPv2-MIB::sysORUpTime.6 = Timeticks: (2) 0:00:00.02
SNMPv2-MIB::sysORUpTime.7 = Timeticks: (2) 0:00:00.02
SNMPv2-MIB::sysORUpTime.8 = Timeticks: (2) 0:00:00.02
SNMPv2-MIB::sysORUpTime.9 = Timeticks: (2) 0:00:00.02
SNMPv2-MIB::sysORUpTime.10 = Timeticks: (2) 0:00:00.02

Creating Configuration :

Now we will create a configuration file for mrtg data storage, run the command below and output will redirect in the mrtg configuration file.Replace your community name and ip of your server.You can also change WorkDir .

[root@server ~]#cfgmaker --snmp-options=:::::2 --ifref=descr --ifdesc=descr --global 'WorkDir: /var/www/html/mymrtg' [email protected] > /etc/mrtg/mrtg.cfg

If you want the graph data in bits instead of bytes , uncomment the below lines from /etc/mrtg/mrtg.cfg configuration file.

#vim /etc/mrtg/mrtg.cfg

Options[_]: growright, bits

Uncomment the below line , which should on line 75  and save and exit from the configuraiton file.

Target[172.24.0.69_eth0]: \eth0:[email protected]:::::2
noHC[172.24.0.69_eth0]: yes
SetEnv[172.24.0.69_eth0]: MRTG_INT_IP="172.24.0.69" MRTG_INT_DESCR="eth0"
MaxBytes[172.24.0.69_eth0]: 250000000
Title[172.24.0.69_eth0]: eth0 -- server.techtransit.org
PageTop[172.24.0.69_eth0]: <h1>eth0 -- server.techtransit.org</h1>
Create Index File on mrtg document root through below command.
indexmaker --columns=1 /etc/mrtg/mrtg.cfg > /var/www/html/mymrtg/index.html

Now, MRTG configured on apache configuration file.

Edit the mrtg apache configuration file.

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

Edit the file like below , change the ip with your ip .

Alias /mrtg /var/www/html/mymrtg

<Location /var/www/html/mymrtg>
Require local
Require ip 172.24.0.69
# Require host example.org
</Location>

Start Apache :

#systemctl start httpd.service

Now the configuration has been done, and the access URL for Graph will be as below.

http://server-hostname or IP Address/mymrtg