MRTG ADD-ON
By Rolph Haspers (kliko@haspers.nl)

#-----------------------------------------------------------------------
#Based on the following ADD-ON's By:
# - Marcel Leicher (marcel@silverpoint.nl)
# - Vincent Houwert (vincent@trueserver.nl)
#
#URL: http://gbgraph.menthenberg.nl/
#
#Special for hosting companies; MRTG-archive, Traffic usage graph, etc.
#-----------------------------------------------------------------------
#Version 1.9, on MRTG (www.mrtg.org) 2.9.12
#(c) 2001, Last change: June 10th 2001
#-----------------------------------------------------------------------

This version: 2.0c
Date: 24-08-2001
Please give feedback on bugs and sites using this add-on to kliko@haspers.nl
----------------------------------------------------------------------------
Files with this program:

Perl:
 * gb.pl
	This is the main program generating the PNG graphics
 * target.pl
	This is the part which generates the .data files, used by gb.pl
 * GD.ppd
	This is a file to install the GD library for Perl (see ActiveState.com)

PNG:
 * fun.png
   	A 'very ugly' example of a possible baseimage, see extra's.
 * gb.png
	An example output file
ASP:
 * data.asp
    	Example ASP-form to get host name and month for input to get the the PNG graphic.

-----------------------------------------------------------------------

Requirements:

* Windows system (not tested on Unix. Target.pl will work on UNIX. GB.pl won't unless the Perl-GD library is installed I guess)
* Perl 5.0 or higher (pref. 5.6.x)
* GD library for Perl (see below)
* MRTG 2.x (tested on 2.9.12, see MRTG instructions on how to install)
-----------------------------------------------------------------------

Installing:

1. Unzip all files in a subdirectory of mrtg (This must be a subdir of MRTG!!!)

2. If you have the GD library already installed continue to step #3.
   To install the GD library, go to your Command-prompt and go to your directory
   where you just unzipped these files and type the following:
    	C:>ppm
   (When this doesn't work, check your Perl installtion. The Perl directory should be in
    your path settings)
   You will now get another prompt. Type in install GD.ppd
      PPM>install GD.ppd
   
   Now the GD-library will be retrieved from Activestate and installed

3. Edit the variables in gb.pl

4. Edit the variable in target.pl
   If you want to make new .data file, change $firsttime to 1.
   This isn't necessary if you are running these scripts for the first time. It will delete
   all of your .data files for all targets in the config file specified, and fills it with 
   data from only the current month (can you follow me? I can't :) )

5. Run target.pl location_of_cfg_file
   Example: target.pl C:\Mrtg\bin\mrtg.cfg
   This will make the [targets].data files in the Log-directory or Work-directory specfied in mrtg.cfg

6. To view a graphic for one of your targets, put gb.pl in a directory of your website (with execute
   permission for Perl) and type in:
     http://your.domain.com/gb.pl?host=targetname&month=monthnumber
   Where:
 	host = the target you want view. When the datafiles are located in a subdirectory of the $DOCUMENT_ROOT
		 specified in gb.pl the host name will be: host=subdir/target
      month = the monthnumber of the month you want to view. Eg: 1 = January, 2 = February...etc.
   
   You can also put data.asp in the same directory and call data.asp.

7. Make a daily schedule which runs target for each .cfg file. One way is to make a batch file which
   runs all targets and schedule this batch file. For example, create target.bat:
   @echo off
   perl C:\mrtg\bin\data\target.pl C:\mrtg\bin\mrtg.cfg
   perl C:\mrtg\bin\data\target.pl C:\mrtg\bin\mrtg2.cfg
   etc...

Enjoy!


--------------------------------------------------------------------------
Extra's in gb.pl:

* BaseImg:
  In gb.pl you can modify the look&feel of the graph, by adding a "base image". 
 
* Colors:
  On the same way as the above option you can add "bluein=xxx","redin=xxx" 
  and "greenin=xxx" options for coloring the graphs IN-traffic bars. 
  Adding "blueout=xxx", "redout=xxx", "greenout=xxx", you can change  the color of
  the OUT-traffic bars.
  See gb.pl for example.

--------------------------------------------------------------------------

Known using sites:

LeaseWeb: http://www.leaseweb.nl
Centurion Systems: http://www.centsi.com

--------------------------------------------------------------------------
Version history:
24-08-2001 - version 2.0d  Removed some minor bugs
20-06-2001 - version 2.0a. Improved graphing methods. Removed bug with dates. Improved count methods.
17-06-2001 - Version 0.9d. Removed another minor bug and added an example ASP-form.
16-06-2001 - Version 0.9c. Removed a minor bug.
14-06-2001 - Version 0.9b. Made original work for Windows.
12-06-2001 - Release of the original version 1.9. Release by:
			 - Marcel Leicher (marcel@silverpoint.nl)
			 - Vincent Houwert (vincent@trueserver.nl)

See history below for the original version.

   0.1  - Basic GB/D graph with input from file
        - Dotted blue Average-line
   0.2  - Larger image
        - Total this, Total last month, Average and Peak in text
        - Calculate expected use on basis of average
   0.3  - Variable graph-color
   0.4  - DayInMonth variable; so no static 31 days
        - GB/TB conversion for month-total/expected
   0.9  - total code makeover
        - overall debug mogelijkheid met &debug=1
        - extra filecheck
        - diverse for() lussen toegevoegd om code optimize
        - functies als trim/sprintf gebruikt om strings netter (te formater)
        - auto output format in bytes, k, m, g, t, en peta bytes.
        - totaal berekening met array functie, max berekening omgeschreven,
          avg nu over aantal dagen dat er waardes zijn ipv over aantal dagen maand
        - grijs raster toegevoegd
        - y-waarde met 1 decimaal, rechts uitgelijnt
        - uitlijnen totaal overzicht op rechts incl. afrondenen formateren 0.1f.
   1.0  - using new .data filetype, with date in it.
   1.2  - added archiving function
   1.3  - added tab's
   1.4  - 2 color graph, baseimg option
   1.9  - lot's of debugging and optimizing, perl and php.