Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction A simplified interaction is shown on the next slide.

Similar presentations


Presentation on theme: "Introduction A simplified interaction is shown on the next slide."— Presentation transcript:

1 Manlug Meeting May 2012 Introduction to MRTG - Multi Router Traffic Grapher By Daniel Botting

2 Introduction A simplified interaction is shown on the next slide.
MRTG - The Multi Router Traffic Grapher was originally developed by Tobi Oetiker and David Rand. It is written in Perl and currently supports: Linux, Windows and Mac OSX. It was initially designed to monitor traffic links on network links, it has evolved into much more. MRTG generates HTML pages containing PNG images which provide a LIVE visual representation of the designated traffic. It is used to manage IP network devices such as servers, routers, switches etc. An administrator can monitor/manage network performance and use it to assist in trouble shooting. MRTG is an SNMP Manager or as you will see referred in SNMP explanations a Network Management Station (NMs). MRTG utilises SNMP (Simple Network Management Protocol) to probe the specified device which has an SNMPD daemon (SNMP AGENT) listening on UDP port 161. Also present will be SNMP TRAP (events) UDP port is on 162, this will advise in-between polls significant events such as powering on. SNMP data is arranged in a standardized hierarchy, this naming hierarchy is made up of “Management Information Bases (MIBS)”, these are structured text files that describe the data accessible through SNMP. The referenced data variables within the MIBS are Object Identifiers (OIDs). Examples will be provided further on. I had hoped as per the summary of the talk that I would be able to show SNMP data/events from a home grade router. In some cases this is possible and I will list these at the end and shortcomings I have become aware of. In most cases it is only professional managed type devices such as Cisco's or more expensive switches. This talk will not be a silver bullet but I hope will assist you on your way. A simplified interaction is shown on the next slide.

3 Simplified MRTG interaction

4 MRTG requirements In this example I will explain the setup for monitoring a server (Debian Squeeze). I believe that the instructions can be followed fairly closely for other distro's. To run Mrtg you will require the following, listed below: Apache webserver – install as root – aptitude install apache2 (Debian specific). MRTG - install as root – aptitude install mrtg SNMPD - install as root – aptitude install snmpd SNMP - install as root – aptitude install snmp (to allow you to test) Configuration of Apache is not covered in this talk, links are provided at the end for everything covered. I would strongly suggest that you thoroughly read up on SNMP before installing MRTG, I followed the guides I could find when researching for this talk and I had to wade through error after error. Once you have a better understanding of SNMP it all makes it much clearer and less frustrating. You will require patience and a sense of humor.

5 Installation – page 1 The guide I followed which is Debian specific came from most that are available seem to follow the same steps. You may find that you configuration file may look slightly different: All commands need to be run as root (denoted as '#'). Step 1 When you install the MRTG package it should create a directory, full path below: - /var/www/mrtg – I found mine did not, one point to look out for, create as required. Step 2 You now to edit the mrtg configuration file, this is located at: /etc/mrtg.cfg, amend as per screenshot:

6 Installation – page 2 Step 3
You will find a crontab running every 5 minutes as the root user, do not amend: # cat /etc/cron.d/mrtg 0-55/5 * * * * root if [ -x /usr/bin/mrtg ] && [ -r /etc/mrtg.cfg ]; then env LANG=C /usr/bin/mrtg /etc/mrtg.cfg >> /var/log/mrtg/mrtg.log 2>&1; fi Step 4 You now need to edit /etc/snmp/snmpd.conf, see first screenshot below. I found that if you uncomment the second for listening on both ipv4 and IPV6, the daemon will fail to start period!!

7 Installation – page 3 Step 5
You will need to assign the community name in /etc/snmp/snmpd.conf # sec.name source community # com2sec paranoid default public com2sec readonly default public #com2sec readwrite default private Please note that this does not need to be public, it can be anything you designate. Step 6 Now you need to restart the snmp service #/etc/init.d/snmpd restart Step 7 Use config maker utility to write this into the configuration file as root: #cfgmaker > /etc/mrtg.cfg

8 Installation – page 4 Step 8
Add a device to the configuration, example: #cfgmaker >> /etc/mrtg.cfg Step 9 Now create an index file for the webserver using #indexmaker /etc/mrtg.cfg > /var/www/mrtg/index.html You will now you need to reboot your box and wait for about five minutes. Navigate to, for example : You will find at the end when running PNG images are created every five minutes, previous one's overwritten, do ls -l to check.

9 Installation – page 5 Step 9
Example to monitor memory, the guide says you should place it in it's own file, I placed it in /etc/mrtg.cfg as the cron job was not running. The guide lists the whole file, see links at the end, but an example of an OID is, an OID for a better word is an address of a piece of data you are trying to reach:

10 Installation – page 6 Step 10
The guides available online seem to suggest you need '\' I removed them as I believe they are only there if you want to put the below into a script and escape characters, when entered below it kept bringing back an error. #/usr/bin/indexmaker --output=/var/www/mrtg/index.html \ --title="Memory and CPU Usage :)" \ --sort=name \ --enumerate \ /etc/mrtg/cpu.cfg \ /etc/mrtg/mem.cfg

11 Installation page 7 Step 11
#cfgmaker --global "WorkDir: /var/www/mrtg/" \ --global "Options[_]: growright,bits" \ --ifref=ip \ > /etc/mrtg/mrtg.conf I found that when running the below it errored with 'unable to resolve ip'. This is either resolved by putting in or editing /etc/snmp/snmpd.conf and uncommenting out: rocommunity public localhost And that is pretty much that :-)

12 Troubleshooting tips Not quite working?
Use the less command to look at: /var/syslog /var/daemon log /var/logmail/user To exit less type 'q'

13 Useful links Mrtg setup - http://www.debianhelp.co.uk/mrtg.htm
Apache2 setup - Snmp readup - And - Shortcomings as described page 2 A number of home grade routers don't have SNMP or if they do it is difficult to enable it, makes below: Thomson: Netgear DG834: If you have dd-wrt, try:


Download ppt "Introduction A simplified interaction is shown on the next slide."

Similar presentations


Ads by Google