This article is going to take you step by step into installing a fully-functional MRTG system, and give you some pointers on where to go from there. We are going to take advantage of some handy shortcuts, for the sake of time. Some of the steps may seem a bit weird initially, but this is the quickest and easiest way to get up and running. And that is the point of this exercise.
We will be relying on a number of pre-compiled packages to get us up and running. You should go fetch them now and have them available when we need them:
I opted to use MRTG Bundle for a number of reasons:
While MRTG also includes a set of PERL binaries, there are a couple things included in Active State's full PERL that we will be relying on in some of the more advanced tasks later on.
So, let's get started:
1.Make sure the system you will be running MRTG on has SNMP enabled. Set the Read community to something obscure, and not easily guessed. For the purposes of this demonstration, I will use the default "public" for the Read Community. You should use something more complicated. You should also ensure that remote systems cannot query your SNMP service for information unless you explicitly allow. These are all properties of the SNMP Service's property page, Security tab. Screen shot is available here.
2. Install Active PERL, taking the defaults. Reboot after installation.
3. Execute the MRTG Bundle installation package that you downloaded from Open Innovations.
4. Read and accept the GNU public license.
5. DO NOT accept the default installation location. If you read the instructions on the page, you will notice they want you to install to "C:". Enter "C:" in the text box where "c:mrtg" is suggested.
6. Once the installation directory is correctly set to "c:", hit Install and observe the files being placed in the appropriate directories. This will take some time, there are a lot of files.
7. Once finished, you should be left with an MRTG directory on your C drive.
8. If you have a list of routers or other network devices that you want to have auto-detected for you, edit the c:\mrtg\mrtg\bin\myrouters.txt file. Put each device on a separate line, using the format communitystring@IPAddress.
For instance, if you have a router at 10.0.0.1, with a community string of "public", you would put public@10.0.0.1 in the myrouters.txt file.
The initial entry (communitystring@ipaddressofserver) is there just for instructional purposes and should be replaced with a real entry. Entries in this file will be scanned during the next step of the installation, and an MRTG config file will be automatically generated during the next step of the installation. This is particularly handy with switches, where the large number of ports are tedious to configure manually within an MRTG config file. For the purposes of this demonstration, I am listing 2 of my Cisco switches, which are configured for the default "public" SNMP community. My myrouters.txt file can be viewed here.
9. Once your myrouters.txt file is complete and saved, open a command prompt and navigate to the c:mrtg directory
10. In c:\mrtg, execute the "install.bat" file.
11. Hit ENTER after reading the introduction screen. Note the warning that all input must be given in LOWER CASE during this installation process.
12. Answer "y" to the question about installing SNMP4W2K on the local machine (you can say no to this, but it gives you a good starting point on making config files for Windows servers), then hit ENTER.
13. Enter a 1 or 2 when asked how many CPUs the local computer has, then hit ENTER.
14. A new command window will launch, starting the installation of SNMP4W2K. Follow the prompts to complete that installation.
15. When the SNMP4W2K install is complete, the command window will close, and a Readme file is displayed. You can safely close that, or read it. Your call.
16. Notice our original command window has been patiently waiting for us to tell it that SNMP4W2K has finished installing.
17. Hit ENTER in the original command window to proceed with the MRTG installation
18. It will prompt you about the MyRouters.txt file. Enter "y" here if you have configured one as I instructed in Step 8, otherwise enter "n" and hit return to proceed.
19. Verify the installation options, enter "y" and hit ENTER to proceed with the installation.
20. The installation script will proceed to build your initial set of config files, querying the devices you specified in the myrouters.txt file for various interface information. It will then start the necessary services (Apache and Cron), and installation is complete
21. Open your favorite web browser, and point it to http://localhost:9191. You should be presented with a screen that resembles this.
22. Congratulations! MRTG is installed. You've earned a Fat Tire.
Upgrading MRTG:
Before you go much further, you will want to upgrade to the latest version of Routers2.cgi and RRDTool:
Upgrading Routers2.cgi:
1. Go to Routers2.cgi's home page and download the latest version of Routers2.cgi. Note that the current release version has a security flaw, so we will be using one of the Beta versions, v2.14-beta7. These versions roll often, so the link to Beta7 may be old by the time you read this. Use whatever the latest version is.
2. Unzip the files to your c:\MRTG directory (it will create a directory called routers2-v2.14 as a result)
3. Open a command window and navigate to the c:\mrtg\routers2-v2.14 directory
4. Execute the following: perl install.pl (note the following instructions may become inaccurate as future Routers2.cgi versions are released)
5. Hit Enter to continue past the introduction screen
6. You may receive warnings of various libraries not being installed. If you have installed the latest version of Active Perl, as I suggested, it is safe to ignore these warnings.
7. When it asks what drives to check, accept the default of "C" and hit ENTER
8. When it asks where you web root is, DO NOT ACCEPT THE DEFAULT. In most cases, the default will be c:inetpubwwwroot, which is incorrect. Our installation has put our web files in c:\mrtg\wwwroot. So type that in and hit ENTER.
9. Enter the same thing for the question about where the CGI files are kept: "c:\mrtg\wwwroot" and hit ENTER
10. The next question is about the location of the MRTG config files. Enter "c:\mrtg\mrtg\bin" and hit ENTER
11. The next question is about the names of the config files themselves, it is safe to just hit ENTER on this question, taking the default of "*.cfg"
12. Next it wants to know where the RRD database files are being held. It defaults to c:\mrtg\wwwroot, which is correct. Just hit ENTER.
13. Next it wants to know where your perl.exe file is located. It will default to c:\mrtg\perl\bin\perl.exe. Accept the default and hit ENTER
14. Next it asks where your routers2.conf file is located. Although it warns you not to change the default without a good reason, ours is located in c:\mrtg\mrtg\bin\routers2.conf. Enter that in and hit ENTER.
15. Accept the defaults for the next series of questions ("Activate Routing Table Extensions?", "How big should K be?", "Do you want to use authentication?" and "Can I email the author?"). Feel free to say YES to the emailing question, if you have ready access to a mail server.
16. Then you will be presented with a summary of the options we have just set, and asked if it's OK to proceed with the installation. Hit ENTER to proceed unless you have made a mistake somewhere along the line.
17. When asked if you want to overwrite routers2.conf, say "yes" and hit ENTER
18. Hit Enter again at the "All Done?" prompt
19. Copy mrtg\wwwroot\index.cgi c:\mrtg\wwwroot\index_cgi.bak
20. Copy mrtg\wwwroot\routers2.cgi c:\mrtg\wwwroot\index.cgi
21. Run "net stop apache", then "net start apache" to restart the web server.
22. You're all done with upgrading Routers2.cgi. Have another Fat Tire.
Upgrading RRDTool:
1. Go to the RRDTool distribution page and download the latest Win32 binaries (currently v1.0.48)
2. Unzip them into c:mrtgrrdtoolupdate
3. Open a command prompt and navigate to c:mrtgrrdtoolupdatesrc
4. Copy the .exe files from each of the 4 "*_release" directories (tool_release, stats_release, rrd_cgi_release, and bounds_release) to c:\mrtg\rrdtool, overwriting the files that were originally in that directory.
5. You're done. What the hell, have another Fat Tire!
Tweaking Routers2.conf:
When we upgraded to the latest version of Routers2.cgi, we lost a couple things that we want to get back. One of them was the 6-hour graph, which is now disabled by default. Also, the scale of the graphs is wacky, and shows the maximum possible values at the top, instead of scaling smartly based on the data coming in. This makes for much less useful graphs, especially in environments where the traffic levels are such that they don't even seem to register properly on the graphs.
So, open c:\mrtg\mrtg\bin\routers2.conf in your favorite test editor (TextPad is mine), and make the following changes:
Adding Devices to MRTG:
Adding devices to MRTG is a 2-step process. First, a new .cfg file must be created for the new device. Then Cron must be configured to regularly poll the device for the graph data. Remember, Cron is the facility we are using to query the devices every minute for metrics.
In the c:\mrtg directory, you will notice a number of handy batch files left behind by the Open Innovations bundle we initially used to install MRTG:
While these batch files are helpful, I found it easier to modify them slightly for my own use:
Routers.cgi Directives in the device.cfg Files:
I've shown you how your can customize MRTG's display by diving into the Routers2.conf file. If you look through the file, you will see there are many options you can tweak with, and it is fairly well documented.
However, I prefer to use the cfg files for the individual devices to make the majority of my tweaks. And with the latest version of Routers2.cgi, it's terribly easy to do so.
Let's say we want to change the default icon for my Cisco 2916 switch at 10.0.0.252. There are a bunch of icons already made for you in the c:\mrtg\rrdtool\rrdicons directory. I want to change the icons for my Cisco device to a small Cisco icon, which is made available as "cisco-sm.ico" in the rrdicons directory. I also want to change the menu from displaying "10.0.0.252" to something more friendly, like "2916M-XL". Here's how it's done:
1. With your favorite text editor, open the device's cfg file, in this case it's c:\mrtg\mrtg\bin\10.0.0.252.cfg
2. In the section towards the top, where the Global Defaults are set, add a line that says routers.cgi*Icon: cisco-sm.gif
3. Add another line that says routers.cgi*ShortDesc: 2916M-XL
4. Save the file.
The next time your web site is refreshed, it should reflect the changes.
A full list of Routers.cgi directives, and what each does, can be found here.
Conclusion:
If you notice any errors on this document, or have questions or feedback, please feel free to contact me at beaumonday@qwest.net
Beau Monday has been in the computer industry for 17 years and holds a myriad of certifications from Microsoft, Cisco, Checkpoint, Nokia, SANS, and others. Beau specializes in monitoring and securing Microsoft-based networks, and he's currently the Security Officer at SumTotal Systems in Seattle, where he makes his home with his wife and 2 cats. More of Beau's security articles can be seen at his weblog (http://bmonday.com)