(865) 584-3355

Apple Certified Macintosh Experts
Serving East Tennessee since 1994
 

Server Configuration

mrtg is a unix (or Windows) based utility for monitoring router traffic to get an idea of your bandwidth usage. This is also very useful to determine if your ISP is providing the quality-of-service you are paying for.

You can run it on and OSX Server or OSX client machine as long as the Web Server service is enabled. In OSX Server do this in Server Admin; in OSX client, do this in the Sharing Preference panel.

This document will cover the basic setup with very few frills. Anything beyond the basic setup will require referencing the manpages and the mrtg website. To obtain the Mac version, make sure you are logged inas an Admin user and download it from http://www.mosxsw.com/port/mrtg/ 

*Update: the original Mac-specific port of mrtg appears to be no longer available. If you have Macports installed you should be able to get it installed through that interface. Read here for more info http://www.macports.org/ports.php?by=name&substr=mrtg  or   http://mrtg.darwinports.com/  I can't vouch for the ease of use or how the configuration instructions I've created still apply to the new version.  If you do install through macports, you may want to compare the install locations of that to what I've detailed here for version 2.9.4 and then hopefully just start at the configuring steps.  GOOD LUCK!

*Update 2: I have used MacPorts in conjunction with a GUI app called Porticus to successfully download an updated version of MRTG. The caveat is that once it is downloaded, you have to go digging on your system to find where it went. On my system it went to /opt/local/var/macports/software/mrtg/...  You can still configure it according to the instructions I've provided here [STARTING at the symbolic link in the web documents folder], but you'll need to be mindful of the paths. You are free to move the installed mrtg folder to somewhere a little more convenient, but if you do that, I believe updating via MacPorts won't be very easy.

*begin 2.9.4 installation steps* 

 Then do the following within Terminal on the computer you are designating as the mrtg server:

  1. cd directory containing mrtg-2.9.4-mosx.tgz
  2. su
  3. enter your root password
  4. tar xzf mrtg-2.9.4-mosx.tgz
  5. cd mrtg-2.9.4-mosx
  6. ./install.sh
  7. the instructions say you should exit at this point, but since everything else you need to do after this step requires root access, you should just stay in su.

Here is the output of the install script:

McMINI:~/Desktop/blank/mrtg-2.9.4-mosx root# ./install.sh
mkdir /usr/local/mrtg-2
mkdir /usr/local/mrtg-2/bin
mkdir /usr/local/mrtg-2/lib
mkdir /usr/local/mrtg-2/lib/mrtg2
mkdir /usr/local/mrtg-2/lib/mrtg2/Pod
mkdir /usr/local/mrtg-2/doc
mkdir /usr/local/mrtg-2/doc/mrtg2
mkdir /usr/local/mrtg-2/man
mkdir /usr/local/mrtg-2/man/man1
McMINI:~/Desktop/blank/mrtg-2.9.4-mosx root#

Then make a symbolic link in the web root - as long as your web root is still in /library/webserver/documents/ then the following will work:

ln -s /usr/local/mrtg-2 /library/webserver/documents/mrtg

Once you do that, then cd to /usr/local/mrtg-2/ and mkdir ./cfg/ then cd to /usr/local/mrtg-2/bin/

Before progressing, you will need to know the IP address and SNMP community information for the router you want to monitor such as This email address is being protected from spambots. You need JavaScript enabled to view it..1

then you will type in the following for ease of visibility as you input it. You could type it all on a single line without the backslashes '\' if you're a sucker for punishment. [Red is what is displayed, Green is what you type in exactly as displayed, blueis where the information will vary depending on your needs, yellow is commentary]

McMINI:/usr/local/mrtg-2/bin root#./cfgmaker --global 'WorkDir: /library/webserver/documents/mrtg' \ [enter] The directory you wish the web page to appear.
> --global 'Options[_]: bits,growright' \ [enter] This just makes the graphs display the data from right to left.
> --output /usr/local/mrtg-2/cfg/mrtg.cfg \ [enter] the location where cfg files will be saved.
> This email address is being protected from spambots. You need JavaScript enabled to view it..1 [enter] This is the SNMP community @ the router you want to monitor

[if you wish to monitor multiple routers you might wish to create subfolders within /usr/local/mrtg-2/ just for organizational purposes and make sure the 'WorkDir' part of the command points to the respective web folder such as for a gateway router: /library/webserver/documents/mrtg/gateway/ and you can output this config file as gateway.cfg if you wish.]

If you're communicating properly with the router, you will see several short lines confirming that it is creating the config info. If you are getting errors that indicate that you can't communicate with the router, double check what you typed, and then make sure you have direct access to the router's interface.

Once that is complete, run the mrtg command by typing /usr/local/mrtg-2/bin/mrtg /usr/local/mrtg-2/cfg/mrtg.cfgthis should communicate to the router and create the initial web page files. You may get a few rateup errors when you run this for the first time. That's fine.You should see several .html and.png files created in the directory. If you see this, test it by launching your web browser and going to http:///mrtg click on any of the html files to verify that the page formatted correctly and is displaying the graphs.

If you've gotten this far, you're almost done!

Download Cronnix from http://www.abstracture.de/projects-en/cronnix and install into /Applications/Utilities/

Run Cronnix and click on the Open icon to open the cron for a user and type in root. Click on New. Under the Simple tab, check all the boxes on the left for Minute, Hour, Day, Month, and Day of the Week. This will make mrtg run once every minute. In the Command box type the following:

/usr/local/mrtg-2/bin/mrtg /usr/local/mrtg-2/cfg/mrtg.cfg &

If you are monitoring more than one router you will have to add new cron jobs for the user and set them all the same way but the command will be something like:

/usr/local/mrtg-2/bin/mrtg /usr/local/mrtg-2/cfg/gateway.cfg &

When you save the cron jobs, you should see * * * * * /usr/local/... listed in the Cronnix window. One line for each router.

Once you save the cron jobs, quit Cronnix and go back to your web browser http://server.address/mrtg and wait a couple minutes. Refresh the browser and see if the time stamps on the files have incremented. If so, then you're done! Let the stats accumulate and the graphs grow. You should see very obvious results after about an hour or so. The longer you let it run, the more data it will gather and the more informative the graphs will become.