Saturday, September 7, 2013

Configure MRTG Server in Linux Environment

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.

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 go to step # 2; otherwise you 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 didar15
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 mrtg
Step5: Creating configuration File
#cfgmaker –global ‘Workdir: /var/www/html/mrtg’ –global ‘Options[_] : bits,growright’ –output /etc/mrtg/sw.cfg didar15@A.B.C.D
syntax: cfgmaker –global ‘Workdir: ’ –global ‘Options[_] : bits,growright’ –output @
Step6: Creating Index File
#indexmaker –output= /var/www/html/mrtg/index.html /etc/mrtg/sw.cfg
Step7: Set Language Support
#env LANG=C /usr/bin/mrtg /etc/mrtg/sw.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/sw.cfg –logging /var/log/mrtg.log
Cheers!!

No comments:

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