MRTG: Difference between revisions

From CLONWiki
Jump to navigation Jump to search
Boiarino (talk | contribs)
No edit summary
Boiarino (talk | contribs)
No edit summary
 
(17 intermediate revisions by the same user not shown)
Line 1: Line 1:
'''General information'''
The Multi Router Traffic Grapher, or just simply MRTG, is free software for monitoring and measuring the traffic load on network links. It allows the user to see traffic load on a network over time in graphical form. It was originally developed by Tobias Oetiker and Dave Rand to monitor router traffic, but has developed into a tool that can create graphs and statistics for almost anything.
MRTG is written in Perl and can run on Windows, Linux, Unix, Mac OS and NetWare.
MRTG is free software licensed under the terms of the GNU General Public License.
'''How it works'''
MRTG uses the Simple Network Management Protocol [[SNMP]] to send requests with two object identifiers (OIDs) to a device. The device, which must be SNMP-enabled, will have a management information base (MIB) to look up the OIDs specified. After collecting the information it will send back the raw data encapsulated in an SNMP protocol. MRTG records this data in a log on the client along with previously recorded data for the device. The software then creates an HTML document from the logs, containing a list of graphs detailing traffic for the selected device.
'''Features'''
* Measures two values (I for Input, O for Output) per target.
* Gets its data via an SNMP agent, or through the output of a command line.
* Typically collects data every five minutes (it can be configured to collect data less frequently).
* Creates an HTML page per target that features four graphs (GIF or PNG images).
* Results are plotted vs time into day, week, month and year graphs, with the I plotted as a full green area, and the O as a blue line.
* Automatically scales the Y axis of the graphs to show the most detail.
* Adds calculated Max, Average and Current values for both I and O to the target's HTML page.
* Can also send warning emails if targets have values above a certain threshold.
'''See also'''
* [[Rrdtool]] - reimplementation of MRTG's graphing and logging features
* PRTG - Windows GUI implementation of MRTG's functionality (freeware available)
* Routers2 - Web front-end for MRTG/RRDtool combination
* Cacti - A similar tool using RRDtool.
MRTG is included in RHEL4; if want to install separately do following:
MRTG is included in RHEL4; if want to install separately do following:


  create user 'mrtg' with private group 'mrtg'
Create user 'mrtg' with private group 'mrtg'. On Linux, use GUI. If it reports problems in ''/etc/shadow'' file, use ''/usr/sbin/pwconv'' script.
 
Now do following:
   mkdir /www/mrtg2.15.0
   mkdir /www/mrtg2.15.0
   chown mrtg.mrtg /www/mrtg2.15.0
   chown mrtg.mrtg /www/mrtg2.15.0
Line 10: Line 44:
   make
   make
   make install
   make install
NOTE: mrtg-2.15.0 was used to install on 'clonweb'', mrtg-2.15.2 - on ''clonmon''.


Add MRTG-related part to apache config file /www/apache2.2.3/conf/httpd.conf:
Add MRTG-related part to apache config file /www/apache2.2.3/conf/httpd.conf:
Line 21: Line 57:
   </Directory>
   </Directory>


Copy contrib/mrtg-startup-script/mrtg to /etc/init.d/ and correct as following:
NOTE: temporary fix in:
 
  ERROR: CFG Error in "Interval": should be at least 5 Minutes (unless you use rrdtool)
  at /misc/clonweb/mrtg2.15.0/bin/../lib/mrtg2/MRTG_lib.pm line 772.
 
MRTG can be started by following command (do not start it yet !):
 
  env LANG=C /www/mrtg2.15.0/bin/mrtg /www/mrtg2.15.0/etc/mrtg.cfg
 
Copy contrib/mrtg-startup-script/mrtg to /etc/init.d/ and correct as following (do not forget to make unique second and third number after chkconfig):


  # chkconfig:    345 91 33
   # config:      /www/mrtg2.15.0/etc/mrtg.cfg
   # config:      /www/mrtg2.15.0/etc/mrtg.cfg
   MRTG="/www/mrtg2.15.0/bin/mrtg"
   MRTG="/www/mrtg2.15.0/bin/mrtg"
   CONFIG="/www/mrtg2.15.0/etc/mrtg.cfg"
   CONFIG="/www/mrtg2.15.0/etc/mrtg.cfg"


 
Following commands can be used from now on (do not start it yet !):
NOTE: temporary fix in:
 
  ERROR: CFG Error in "Interval": should be at least 5 Minutes (unless you use rrdtool)
  at /misc/clonweb/mrtg2.15.0/bin/../lib/mrtg2/MRTG_lib.pm line 772.
 
Following commands can be used now:


   /etc/init.d/mrtg start
   /etc/init.d/mrtg start
Line 39: Line 79:
   /etc/init.d/mrtg restart
   /etc/init.d/mrtg restart


Add 'mrtg' to the list of services to be started at boot time (enable level 5 only):


   ############################
   chkconfig --add mrtg
  chkconfig --level 3 mrtg off
  chkconfig --level 4 mrtg off
  chkconfig --list mrtg
 
Copy/create config files (was copied from clasweb-bck):


   cd /www/mrtg2.15.0
   cd /www/mrtg2.15.0
   mkdir etc
   mkdir etc
  cd /www/mrtg2.15.0/etc
  scp clasweb-bck:/etc/mrtg/"*" .
OR: create configuration files using 'cfgmaker' (never worked for me):


   #example
   #example
Line 56: Line 106:
         --output /www/mrtg2.15.0/etc/mrtg.cfg \
         --output /www/mrtg2.15.0/etc/mrtg.cfg \
         mrtg@clonweb.jlab.org
         mrtg@clonweb.jlab.org
   DOEN NOT WORK YET ...
   DOES NOT WORK YET ...


OR: create configuration files manually (examples from clasweb-bck were used):


   #copy old stuff from clasweb-bck:
   etc/mrtg.cfg - main config file, includes *.inc files
  cd /www/mrtg2.15.0/etc
   etc/*.inc - hardware-specific config files
   scp clasweb-bck:/etc/mrtg/"*" .
 
Create 'web' directories:


  #create 'web' directories
   cd /www/mrtg2.15.0/share
   cd /www/mrtg2.15.0/share
   mkdir htmls
   mkdir htmls
Line 69: Line 120:
   mkdir logs
   mkdir logs


MRTG will produce and update following files while running:
  share/htmls/*.html - actual html files to be displayed
  share/images/*.png (and *.gif ?) - monthly, dayly and yearly charts
  share/logs/*.log and *.old - current charts


It maybe good idea to copy some old files htmls/*, images/* and logs/* from previously used MRTG (on clasweb-bck in our case).
It will preserve history: 'logs/*.log' contains recent history, while images/*.png contains longer history
  cd htmls
  scp clasweb-bck:/var/www/html/mrtg/Hall-B/htmls/* .
  cd ../images
  scp clasweb-bck:/var/www/html/mrtg/Hall-B/images/* .
  cd ../logs
  scp clasweb-bck:/var/www/html/mrtg/Hall-B/logs/* .
Start MRTG rigth the way to avoid interrupts in history:
  /etc/init.d/mrtg start
Generate 'index.html' script in 'share' directory. It will produce file for all channels. It can be splited manually on desired number of smaller files (it maybe possible to generate separate file for every *.inc, but it wanted WorkDir which is defined in mrtg.cfg, and
I did not bother to play with it):
  /www/mrtg2.15.0/bin/indexmaker /www/mrtg2.15.0/etc/mrtg.cfg --prefix=htmls --show=none --output=/www/mrtg2.15.0/share/index.html


  #web stuff from clasweb-bck:
  #scp clasweb-bck:/var/www/html/mrtg.html .
  #scp clasweb-bck:/var/www/html/mrtg.tar .
  #tar xvf mrtg.tar


  #add following to apache config file (/apps/apache2.2.3/conf/httpd.conf):
  Alias /mrtg "/www/mrtg2.15.0/share"
  <Directory "/www/mrtg2.15.0/share">
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
  </Directory>
  #adjust it if necessary


  #create desired index.html in /www/mrtg2.15.0/share, it will be used
Cron job (another method to update plots ???):
  #by browser if 'http://clonweb/mrtg/' typed


   #copy old stuff from previous htlms/*, images/* and lods/*,
   [root@clasweb-bck etc]# ll */mrtg
   #if 'mrtg' was running before; it will preserve history;
   -rw-r--r--    1 root    root          54 Feb 15  2005 cron.d/mrtg
   #'logs' contains recent history, while *.png contains
   -rwxr-xr-x    1 vvsap    clas        1140 Mar  2  2005 init.d/mrtg
   #longer history; start 'mrtg' right the way:
   [root@clasweb-bck etc]# more  cron.d/mrtg
   env LANG=C /www/mrtg2.15.0/bin/mrtg /www/mrtg2.15.0/etc/mrtg.cfg
   #0-59/5 * * * * root /usr/bin/mrtg /etc/mrtg/mrtg.cfg

Latest revision as of 14:39, 20 February 2009

General information

The Multi Router Traffic Grapher, or just simply MRTG, is free software for monitoring and measuring the traffic load on network links. It allows the user to see traffic load on a network over time in graphical form. It was originally developed by Tobias Oetiker and Dave Rand to monitor router traffic, but has developed into a tool that can create graphs and statistics for almost anything.

MRTG is written in Perl and can run on Windows, Linux, Unix, Mac OS and NetWare.

MRTG is free software licensed under the terms of the GNU General Public License.

How it works

MRTG uses the Simple Network Management Protocol SNMP to send requests with two object identifiers (OIDs) to a device. The device, which must be SNMP-enabled, will have a management information base (MIB) to look up the OIDs specified. After collecting the information it will send back the raw data encapsulated in an SNMP protocol. MRTG records this data in a log on the client along with previously recorded data for the device. The software then creates an HTML document from the logs, containing a list of graphs detailing traffic for the selected device.

Features

  • Measures two values (I for Input, O for Output) per target.
  • Gets its data via an SNMP agent, or through the output of a command line.
  • Typically collects data every five minutes (it can be configured to collect data less frequently).
  • Creates an HTML page per target that features four graphs (GIF or PNG images).
  • Results are plotted vs time into day, week, month and year graphs, with the I plotted as a full green area, and the O as a blue line.
  • Automatically scales the Y axis of the graphs to show the most detail.
  • Adds calculated Max, Average and Current values for both I and O to the target's HTML page.
  • Can also send warning emails if targets have values above a certain threshold.

See also

  • Rrdtool - reimplementation of MRTG's graphing and logging features
  • PRTG - Windows GUI implementation of MRTG's functionality (freeware available)
  • Routers2 - Web front-end for MRTG/RRDtool combination
  • Cacti - A similar tool using RRDtool.


MRTG is included in RHEL4; if want to install separately do following:

Create user 'mrtg' with private group 'mrtg'. On Linux, use GUI. If it reports problems in /etc/shadow file, use /usr/sbin/pwconv script.

Now do following:

 mkdir /www/mrtg2.15.0
 chown mrtg.mrtg /www/mrtg2.15.0
 cd /usr/local/src
 chown mrtg.mrtg mrtg-2.15.0
 cd mrtg-2.15.0
 ./configure --prefix=/www/mrtg2.15.0
 make
 make install

NOTE: mrtg-2.15.0 was used to install on 'clonweb, mrtg-2.15.2 - on clonmon.

Add MRTG-related part to apache config file /www/apache2.2.3/conf/httpd.conf:

 Alias /mrtg "/www/mrtg2.15.0/share"
 <Directory "/www/mrtg2.15.0/share">
   Options Indexes FollowSymLinks
   AllowOverride None
   Order allow,deny
   Allow from all
 </Directory>

NOTE: temporary fix in:

 ERROR: CFG Error in "Interval": should be at least 5 Minutes (unless you use rrdtool)
 at /misc/clonweb/mrtg2.15.0/bin/../lib/mrtg2/MRTG_lib.pm line 772.

MRTG can be started by following command (do not start it yet !):

 env LANG=C /www/mrtg2.15.0/bin/mrtg /www/mrtg2.15.0/etc/mrtg.cfg

Copy contrib/mrtg-startup-script/mrtg to /etc/init.d/ and correct as following (do not forget to make unique second and third number after chkconfig):

 # chkconfig:    345 91 33
 # config:       /www/mrtg2.15.0/etc/mrtg.cfg
 MRTG="/www/mrtg2.15.0/bin/mrtg"
 CONFIG="/www/mrtg2.15.0/etc/mrtg.cfg"

Following commands can be used from now on (do not start it yet !):

 /etc/init.d/mrtg start
 /etc/init.d/mrtg stop
 /etc/init.d/mrtg restart

Add 'mrtg' to the list of services to be started at boot time (enable level 5 only):

 chkconfig --add mrtg
 chkconfig --level 3 mrtg off
 chkconfig --level 4 mrtg off
 chkconfig --list mrtg

Copy/create config files (was copied from clasweb-bck):

 cd /www/mrtg2.15.0
 mkdir etc
 cd /www/mrtg2.15.0/etc
 scp clasweb-bck:/etc/mrtg/"*" .

OR: create configuration files using 'cfgmaker' (never worked for me):

 #example
 #cfgmaker --global 'WorkDir: /home/httpd/mrtg'  \
 #         --global 'Options[_]: bits,growright' \
 #         --output /home/mrtg/cfg/mrtg.cfg    \
 #          community@router.abc.xyz
 DOES NOT WORK YET ...
 /www/mrtg2.15.0/bin/cfgmaker --global 'WorkDir: /www/mrtg2.15.0/etc'  \
        --global 'Options[_]: bits,growright' \
        --output /www/mrtg2.15.0/etc/mrtg.cfg \
        mrtg@clonweb.jlab.org
 DOES NOT WORK YET ...

OR: create configuration files manually (examples from clasweb-bck were used):

 etc/mrtg.cfg - main config file, includes *.inc files
 etc/*.inc - hardware-specific config files

Create 'web' directories:

 cd /www/mrtg2.15.0/share
 mkdir htmls
 mkdir images
 mkdir logs

MRTG will produce and update following files while running:

 share/htmls/*.html - actual html files to be displayed
 share/images/*.png (and *.gif ?) - monthly, dayly and yearly charts
 share/logs/*.log and *.old - current charts

It maybe good idea to copy some old files htmls/*, images/* and logs/* from previously used MRTG (on clasweb-bck in our case). It will preserve history: 'logs/*.log' contains recent history, while images/*.png contains longer history

 cd htmls
 scp clasweb-bck:/var/www/html/mrtg/Hall-B/htmls/* .
 cd ../images
 scp clasweb-bck:/var/www/html/mrtg/Hall-B/images/* .
 cd ../logs
 scp clasweb-bck:/var/www/html/mrtg/Hall-B/logs/* .

Start MRTG rigth the way to avoid interrupts in history:

 /etc/init.d/mrtg start

Generate 'index.html' script in 'share' directory. It will produce file for all channels. It can be splited manually on desired number of smaller files (it maybe possible to generate separate file for every *.inc, but it wanted WorkDir which is defined in mrtg.cfg, and I did not bother to play with it):

 /www/mrtg2.15.0/bin/indexmaker /www/mrtg2.15.0/etc/mrtg.cfg --prefix=htmls --show=none --output=/www/mrtg2.15.0/share/index.html


Cron job (another method to update plots ???):

 [root@clasweb-bck etc]# ll */mrtg
 -rw-r--r--    1 root     root           54 Feb 15  2005 cron.d/mrtg
 -rwxr-xr-x    1 vvsap    clas         1140 Mar  2  2005 init.d/mrtg
 [root@clasweb-bck etc]# more  cron.d/mrtg
 #0-59/5 * * * * root /usr/bin/mrtg /etc/mrtg/mrtg.cfg