Prerequisites
This little guide was written for Fedora Core 2, other versions of
RedHat/Fedora Linux may differ.
Make sure you have a working http server at the host before
setting up mrtg.
Initial setup
MRTG is controlled by a file named mrtg.cfg. In Fedora Core 2 this
file can be found at /etc/mrtg/mrtg.cfg . Remove the
old one, as we are going to create a new one.
cd /etc/mrtg mv mrtg.cfg mrtg.cfg.original
Now create a new file with the command
cfgmaker --output=/etc/mrtg/mrtg.cfg.new \ -ifref=ip \ --global 'Workdir: /var/www/mrtg/data' \ --global 'Options[_]: growright,bits,unknaszero' \ --global 'Weekformat[^]: V' \ public@localhost
This will create a configuration file in /etc/mrtg
with the name mrtg.cfg.new . The global statements
will tell mrtg that all data, and created files, should be placed
in the directory /var/www/mrtg/data , that the
IP-number will be used as a reference of the interface (in the
title on the web page etc.), that the plots will grow to the
right, the value in the plots will be bits per second (default is
bytes per second), and that we will get a data value of zero in
case of trouble reading data from the SNMP server.
Go through the file and comment the lines of those interfaces you
do not want to monitor, and uncomment those that you want to
monitor. Then add the data directory, remove any stale locking
files rename the file to mrtg.cfg, and run mrtg three times (this
will create all files, disregard the fault messages the first two
times, a fault message the third time is a sign to start worrying)
mkdir -p /var/www/mrtg/data cd /etc/mrtg rm -f mrtg.cfg_l* mv mrtg.cfg.new mrtg.cfg mrtg mrtg.cfg mrtg mrtg.cfg mrtg mrtg.cfg
Now create an index file for the /var/www/mrtg
directory (move the old one first)
cd /var/www/mrtg mv index.html index_mrtg.html indexmaker --output=/var/www/mrtg/index.html \ --columns=1 \ --autoprefix \ /etc/mrtg/mrtg.cfg
In the file /etc/httpd/conf.d/mrtg.conf make sure
that you have set up access rights the correct way. If you want
all to be able to see your graphs, do
<Location /mrtg> Order deny,allow Allow from all </Location>
If you on the other hand only want to grant access to the local
LAN, and localhost, do
<Location /mrtg> Order deny,allow Deny from all Allow from 127.0.0.1 Allow from 192.168.0 </Location>
You should now be able to se plots by surfing to
http://127.0.0.1/mrtg/
There are a lots of switches to the indexmaker program, take a
look at 'man indexmaker' and test some of them to get a better
layout for the graphs, or edit
/var/www/html/index.html yourself.
Источник: http://www.sm6rpz.se/linux/mrtg.php |