MRTG

From Edgar BV Wiki
Revision as of 12:53, 2 March 2007 by Red (talk | contribs) (New page: MRTG Configuration in /etc/mrtg First build a conf file which includes all the conf files you want mrtg to run. Each directive in this file will be used in all the sub-conf files. Each su...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

MRTG Configuration

in /etc/mrtg First build a conf file which includes all the conf files you want mrtg to run. Each directive in this file will be used in all the sub-conf files. Each sub conf file will spawn a seperate mrtg process (if run as daemon)

/etc/mrtg.conf


  1. Multi Router Traffic Grapher -- Sample Configuration File
  2. This file is for use with mrtg-2.5.4c
  1. Global configuration
  2. Put these into the templates
  3. Htmldir: /space/sites/mrtg
  4. Imagedir: /space/sites/mrtg/images
  5. IconDir: /space/sites/mrtg/icons
  6. Logdir: /var/log/mrtg
  1. Forks: 4
  2. RunAsDaemon: Yes
  3. Interval: 5
  4. WriteExpires: Yes
  1. Options[_]: growright
  1. Also add lines for each of the daemons to /etc/init.d/mrtg
  1. Included configuration files

Include: tripany.internal.cfg Include: euhost.cfg Include: USN.cfg


Doing this allows you to place the resultant HTML files in different subdirectories, ie. allow different sets of statistics to be seen by different people.

Then we set up the local files /etc/mrtg/euhost.cfg


Htmldir: /space/sites/mrtg/euhost Imagedir: /space/sites/mrtg/euhost/images IconDir: /space/sites/mrtg/icons LogDir: /var/log/mrtg Forks: 4 RunAsDaemon: Yes Interval: 5 WriteExpires: Yes

Options[_]: growright

  1. ------------------ EUHost Interfaces ------------------------
  1. Link to internet

Target[euhost.tripany.com.eth0]: \eth0:euhostrw@euhost.tripany.com:

  1. -#Total[euhost.tripany.com.eth0]: Total traffic for internet link on EUHost

SetEnv[euhost.tripany.com.eth0]: MRTG_INT_IP="212.61.33.42" MRTG_INT_DESCR="eth0" MaxBytes[euhost.tripany.com.eth0]: 12500000 Title[euhost.tripany.com.eth0]: Traffic Analysis for internet link on EUHost

PageTop[euhost.tripany.com.eth0]:

Traffic Analysis for internet link on EUHost

WithPeak[euhost.tripany.com.eth0]: wmy

PageFoot[euhost.tripany.com.eth0]:

<a href="euhost.tripany.com.eth0.total.2006.html">Total Traffic Stats for 2006</a>


The traffic data is polled using SNMP, so in the Target is the ethernet card you are polling and the community name.

The PageFoot and #-#Total lines are links to an external totaliser which I'll explain later.

Then we set up the index page which shows the current traffic information for all the interfaces in the local configuration files. This is done by running the indexmaker utility, so this has to be run every time a change is made (eg. by adding new interfaces).

The command to create the index file for all the configurations onto one page is:


indexmaker --output=/space/sites/mrtg/index.html --addhead="Tripany Bandwidth Monitoring" --title="Tripany MRTG" /etc/mrtg/euhost.cfg /etc/mrtg/tripany.internal.cfg /etc/mrtg/USN.cfg --autoprefix


To do this for just one of the specific configurations is


indexmaker --output=/space/sites/mrtg/euhost/index.html --addhead="Tripany Bandwidth Monitoring for EUHost" --title="EUHost MRTG" /etc/mrtg/euhost.cfg


To create the totaliser pages, you need mrtg_total.pl from http://www.geocities.com/josef_wendel/mrtg_total.html

Then add a crontab entry for each conf file you have #-#Total tags in 5 1 * * * root /usr/local/bin/mrtg_total.pl /etc/mrtg/euhost.cfg

This will generate the pages linked to in the page footer.


To monitor Spam statistics: http://users.2z.net/rpuhek/scripts_public/spamd/

The only edit here is to change the spam-stats.pl on the spamassassin machine to reflect the spamd logfile (which is /var/log/mail/spamd.log on debian, instead of syslog)

Also make sure that mrtguser has permissions to run the .pl file :)