Thursday, December 15, 2011

How to Configure MRTG Server

What is MRTG:
The Multi Router Traffic Grapher (MRTG) is a powerful open source tool to monitor the traffic load on network links. MRTG generates HTML pages containing PNG images which provide a LIVE visual representation of this traffic. MRTG is written in perl and works on Unix/Linux as well as Windows and even Netware systems. MRTG is free software licensed under the Gnu GPL.
Go to http://oss.oetiker.ch/mrtg for all the details about MRTG and download.

MRTG Sample Image

Step # 1 : Make sure snmp server installed
==========================================
Please note that snmpd configuration does not require using mrtg with remote network devices such as Routers and switches. If you just want mrtg graphs for router or switch then please refer to step# 4 (as all these devices comes preconfigured with snmpd software).

Run rpm command query option to find out whether snmp service is installed or not:

# rpm -qa | grep snmp

If snmp installed then please refer step # 2; otherwise snmp server and utils were not present and your need to install them using following steps (login as a root user):

(a) Visit rpmfind.net to get snmp server and utility rpms's. If you are a fedora, centos user then use yum command as follows to install it:

# yum install net-snmp-utils net-snmp

(b) If you are RHEL subscriber then use up2date command as follows to install:

#up2date -v -i net-snmp-utils net-snmp

Step # 2 : Determine if snmp server is running or not
=====================================================
Run 'ps' command to see if snmp server is running or not:

# ps -aux | grep snmp
Output:
root 5512 0.0 2.3 5872 3012 pts/0 S 22:04 0:00 /usr/sbin/snmpd

Alternatively, you can try any of the following two commands as well:

# lsof -i :199
Output:
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
snmpd 5512 root 4u IPv4 34432 TCP *:smux (LISTEN)

OR try out netstat command:

# netstat -natv | grep ':199'
Output:
tcp 0 0 0.0.0.0:199 0.0.0.0:* LISTEN

If you found service is running or listing on port 199 then please see step #3; otherwise start service using following command:
# service snmpd start

Make sure snmpd service starts automatically if the system reboots (add snmpd service):
# chkconfig --add snmpd

Open snmpd.conf file to add/edit community string:
#vi /etc/snmp/snmpd.conf

Add the below line in the file, save and exit:
ROCOMMUNITY didar

Step3: Making snmp to walk :)
=============================
Before doing smnpwalk, login to the device you want to monitor e.g. switch, router, linux box, windows2003 server and add the same community string that you have entered few minutes ago in snmpd.conf file.

# snmpwalk -v 1 -c didar(community name) a.b.c.d(device ip e.g. router, switch)

Step4: Making document root to store mrtg graphs/html pages
============================================================
#cd /var/www/html/
#mkdir -p cat (just a folder name)

#Step5: Creating config file
============================
#cfgmaker --global ‘Workdir: /var/www/html/cat’ --global ‘Options[_] : bits,growright’ --output /etc/mrtg/cat.cfg didar@A.B.C.D

syntax: cfgmaker --global ‘Workdir: ’ --global ‘Options[_] : bits,growright’ --output @

#Step6: Creating index file
===========================
#indexmaker --output= /var/www/html/cat/index.html /etc/mrtg/cat.cfg

#Step7:
==================================================
##env LANG=C /usr/bin/mrtg /etc/mrtg/cat.cfg

#Step8: Adding a cron job to update the graph in every five minute
=================================================================
#crontab -e (Add the following line at the end of the file)
*/5 **** /usr/bin/mrtg /etc/mrtg/cat.cfg --logging /var/log/mrtg.log

Cheers!!

4 comments:

RAJIB said...

didar vi practical korte chai,
Windows a ki vabe korbo.

Ashik said...

didar.. env variable koi? eita to must set koretee hobe.. without dt cfg file wont create..

#env LANG=C /usr/bin/mrtg /etc/mrtg/didar.cfg

Run this command 3 times....

dn it will create the cfg file....

didarsust said...

@Rajib: you can try it with below link:

http://oss.oetiker.ch/mrtg/doc/mrtg-nt-guide.en.html

didarsust said...

Thanks boss.

Restore Archived Log into VMware Aria Operations for Logs (formerly known as vRealize Log Insight - vRLI)

As we cannot keep all logs in searchable space in vRLI production system due to performance and slowness issue, it is always recommended to ...