|
Packit |
667938 |
=head1 NAME
|
|
Packit |
667938 |
|
|
Packit |
667938 |
mrtg-unix-guide - The MRTG 2.17.7 Linux/Unix Installation Guide
|
|
Packit |
667938 |
|
|
Packit |
667938 |
=head1 DESCRIPTION
|
|
Packit |
667938 |
|
|
Packit |
667938 |
MRTG comes to you in Source Code. This means that you have to compile
|
|
Packit |
667938 |
parts of it before you can use it on a Unix machine. These instructions
|
|
Packit |
667938 |
help you to do so.
|
|
Packit |
667938 |
|
|
Packit |
667938 |
=head1 PREPARATION
|
|
Packit |
667938 |
|
|
Packit |
667938 |
In order to compile and use mrtg you need a C compiler and a copy of perl
|
|
Packit |
667938 |
installed on your machine. In most cases this will already be available.
|
|
Packit |
667938 |
In case it is not, here are some starting points. Below I'll give you
|
|
Packit |
667938 |
a detailed run through the whole compilation process.
|
|
Packit |
667938 |
|
|
Packit |
667938 |
=over
|
|
Packit |
667938 |
|
|
Packit |
667938 |
=item GCC
|
|
Packit |
667938 |
|
|
Packit |
667938 |
The GNU C compiler comes preinstalled on most of the free Unicies out
|
|
Packit |
667938 |
there. For commercial derivatives you may have to download and compile
|
|
Packit |
667938 |
it first. If you have no compiler at all there is a chicken and egg
|
|
Packit |
667938 |
problem, but there are also precompiled versions of gcc available for
|
|
Packit |
667938 |
most operating systems.
|
|
Packit |
667938 |
|
|
Packit |
667938 |
http://gcc.gnu.org/
|
|
Packit |
667938 |
|
|
Packit |
667938 |
=item Perl
|
|
Packit |
667938 |
|
|
Packit |
667938 |
Large parts of the MRTG system are written in the Perl scripting language.
|
|
Packit |
667938 |
Make sure there is a recent copy of perl on your machine (try perl -v). At
|
|
Packit |
667938 |
least version 5.005 is required for mrtg to work well. If you use SNMPV3 and
|
|
Packit |
667938 |
other new features you should use at least 5.8.
|
|
Packit |
667938 |
|
|
Packit |
667938 |
You can get the latest perl from
|
|
Packit |
667938 |
|
|
Packit |
667938 |
http://www.perl.com/
|
|
Packit |
667938 |
|
|
Packit |
667938 |
=back
|
|
Packit |
667938 |
|
|
Packit |
667938 |
MRTG generates traffic graphs in the PNG format. To be able to do this it
|
|
Packit |
667938 |
needs several 3rd party libraries. When compiling these libraries I urge you
|
|
Packit |
667938 |
to make sure you compile them as B<static> libraries. There is just much
|
|
Packit |
667938 |
less trouble ahead if you are doing it like this. See the Instructions in
|
|
Packit |
667938 |
the next section for inspiration. Note that many free unices have all
|
|
Packit |
667938 |
the required libraries already in place so there is no need to install
|
|
Packit |
667938 |
another copy. To check it is best to skip all the library instructions below
|
|
Packit |
667938 |
and go straight into the mrtg compile.
|
|
Packit |
667938 |
|
|
Packit |
667938 |
If the first attempt fails and you do not get a working version of mrtg,
|
|
Packit |
667938 |
try compiling new copies of all libraries as explained below. Do this
|
|
Packit |
667938 |
B<BEFORE> you send email to me about problems compiling mrtg.
|
|
Packit |
667938 |
|
|
Packit |
667938 |
=over
|
|
Packit |
667938 |
|
|
Packit |
667938 |
=item gd
|
|
Packit |
667938 |
|
|
Packit |
667938 |
This is a basic graph drawing library created by Thomas Boutell.
|
|
Packit |
667938 |
Note that all releases after Version 1.3 only create
|
|
Packit |
667938 |
PNG images. This is because a) Thomas got into trouble because the GIF
|
|
Packit |
667938 |
format which it used to produce uses a compression technology patented
|
|
Packit |
667938 |
by Unisys. b) PNG is more efficient and patent free. MRTG can work
|
|
Packit |
667938 |
with old and new version of the GD library. You can get a recent copy
|
|
Packit |
667938 |
of GD from:
|
|
Packit |
667938 |
|
|
Packit |
667938 |
http://www.boutell.com/gd/
|
|
Packit |
667938 |
|
|
Packit |
667938 |
=item libpng
|
|
Packit |
667938 |
|
|
Packit |
667938 |
Is required by gd in order to produce PNG graphics files. Get it from:
|
|
Packit |
667938 |
|
|
Packit |
667938 |
http://www.libpng.org/pub/png/libpng.html
|
|
Packit |
667938 |
|
|
Packit |
667938 |
=item zlib
|
|
Packit |
667938 |
|
|
Packit |
667938 |
Is needed by libpng to compress the graphics files you create.
|
|
Packit |
667938 |
Get a copy from
|
|
Packit |
667938 |
|
|
Packit |
667938 |
http://www.gzip.org/zlib
|
|
Packit |
667938 |
|
|
Packit |
667938 |
=back
|
|
Packit |
667938 |
|
|
Packit |
667938 |
And last but not least you also need mrtg itself. In case you have not
|
|
Packit |
667938 |
yet downloaded it, you can find a copy on my website:
|
|
Packit |
667938 |
|
|
Packit |
667938 |
http://oss.oetiker.ch/mrtg/pub
|
|
Packit |
667938 |
|
|
Packit |
667938 |
=head1 LIBRARY COMPILATION
|
|
Packit |
667938 |
|
|
Packit |
667938 |
In this section I will give you step by step instructions on how to compile
|
|
Packit |
667938 |
the various libraries required for the compilation of mrtg. Note that these
|
|
Packit |
667938 |
libraries may already be installed if you have a I<*BSD> or I<Linux> system
|
|
Packit |
667938 |
so you can skip recompiling them. The B<wget> program used below is a
|
|
Packit |
667938 |
simple web downloader. You can also enter the address into your B<netscape>
|
|
Packit |
667938 |
if you don't have B<wget> available.
|
|
Packit |
667938 |
|
|
Packit |
667938 |
First let's create a directory for the compilation. Note that this may
|
|
Packit |
667938 |
already exist on your system. No problem, just use it.
|
|
Packit |
667938 |
|
|
Packit |
667938 |
mkdir -p /usr/local/src
|
|
Packit |
667938 |
cd /usr/local/src
|
|
Packit |
667938 |
|
|
Packit |
667938 |
If you do not have zlib installed:
|
|
Packit |
667938 |
|
|
Packit |
667938 |
wget http://www.zlib.net/zlib-1.2.3.tar.gz
|
|
Packit |
667938 |
gunzip -c zlib-*.tar.gz | tar xf -
|
|
Packit |
667938 |
rm zlib-*.tar.gz
|
|
Packit |
667938 |
mv zlib-* zlib
|
|
Packit |
667938 |
cd zlib
|
|
Packit |
667938 |
./configure
|
|
Packit |
667938 |
make
|
|
Packit |
667938 |
cd ..
|
|
Packit |
667938 |
|
|
Packit |
667938 |
If you don't have libpng installed
|
|
Packit |
667938 |
|
|
Packit |
667938 |
wget ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng-1.2.40.tar.gz
|
|
Packit |
667938 |
gunzip -c libpng-1.2.34.tar.gz | tar xf -
|
|
Packit |
667938 |
mv libpng-* libpng
|
|
Packit |
667938 |
cd libpng
|
|
Packit |
667938 |
env CFLAGS="-O3 -fPIC" ./configure --prefix=$INSTALL_DIR
|
|
Packit |
667938 |
make
|
|
Packit |
667938 |
rm *.so.* *.so
|
|
Packit |
667938 |
cd ..
|
|
Packit |
667938 |
|
|
Packit |
667938 |
And now you can compile gd
|
|
Packit |
667938 |
|
|
Packit |
667938 |
For versions up to 1.8.4, try:
|
|
Packit |
667938 |
|
|
Packit |
667938 |
wget http://www.boutell.com/gd/http/gd-1.8.4.tar.gz
|
|
Packit |
667938 |
gunzip -c gd-*.tar.gz |tar xf -
|
|
Packit |
667938 |
rm gd-*.tar.gz
|
|
Packit |
667938 |
mv gd-* gd
|
|
Packit |
667938 |
cd gd
|
|
Packit |
667938 |
|
|
Packit |
667938 |
The \ characters at the end of the following lines mean that all the
|
|
Packit |
667938 |
following material should actually be written on a single line.
|
|
Packit |
667938 |
|
|
Packit |
667938 |
perl -i~ -p -e s/gd_jpeg.o//g Makefile
|
|
Packit |
667938 |
make INCLUDEDIRS="-I. -I../zlib -I../libpng" \
|
|
Packit |
667938 |
LIBDIRS="-L../zlib -L. -L../libpng" \
|
|
Packit |
667938 |
LIBS="-lgd -lpng -lz -lm" \
|
|
Packit |
667938 |
CFLAGS="-O -DHAVE_LIBPNG"
|
|
Packit |
667938 |
cd ..
|
|
Packit |
667938 |
|
|
Packit |
667938 |
For versions starting around 2.0.11, try:
|
|
Packit |
667938 |
|
|
Packit |
667938 |
wget http://www.boutell.com/gd/http/gd-2.0.33.tar.gz
|
|
Packit |
667938 |
gunzip -c gd-2.0.33.tar.gz |tar xf -
|
|
Packit |
667938 |
mv gd-2.0.33 gd
|
|
Packit |
667938 |
cd gd
|
|
Packit |
667938 |
env CPPFLAGS="-I../zlib -I../libpng" LDFLAGS="-L../zlib -L../libpng" \
|
|
Packit |
667938 |
./configure --disable-shared --without-freetype --without-jpeg
|
|
Packit |
667938 |
make
|
|
Packit |
667938 |
cp .libs/* .
|
|
Packit |
667938 |
|
|
Packit |
667938 |
=head1 MRTG COMPILATION
|
|
Packit |
667938 |
|
|
Packit |
667938 |
Ok, now everything is ready for the mrtg compilation.
|
|
Packit |
667938 |
|
|
Packit |
667938 |
cd /usr/local/src
|
|
Packit |
667938 |
gunzip -c mrtg-2.17.7.tar.gz | tar xvf -
|
|
Packit |
667938 |
cd mrtg-2.17.7
|
|
Packit |
667938 |
|
|
Packit |
667938 |
If all the libraries have been preinstalled on your system you can
|
|
Packit |
667938 |
configure mrtg by doing a simple:
|
|
Packit |
667938 |
|
|
Packit |
667938 |
./configure --prefix=/usr/local/mrtg-2
|
|
Packit |
667938 |
|
|
Packit |
667938 |
Otherwise you may have to give some hints on where to find the
|
|
Packit |
667938 |
various libraries required to compile mrtg:
|
|
Packit |
667938 |
|
|
Packit |
667938 |
./configure --prefix=/usr/local/mrtg-2 \
|
|
Packit |
667938 |
--with-gd=/usr/local/src/gd \
|
|
Packit |
667938 |
--with-z=/usr/local/src/zlib \
|
|
Packit |
667938 |
--with-png=/usr/local/src/libpng
|
|
Packit |
667938 |
|
|
Packit |
667938 |
If you have RRDtool available you might want to tell mrtg about it
|
|
Packit |
667938 |
so that you can opt to use rrdtool with mrtg. Check L<mrtg-rrd>.
|
|
Packit |
667938 |
|
|
Packit |
667938 |
Configure will make sure your environment is fit for building mrtg.
|
|
Packit |
667938 |
If it finds a problem, it will tell you so and it will also tell
|
|
Packit |
667938 |
you what to do about it. If everything is OK, you will end up with
|
|
Packit |
667938 |
a custom Makefile for your system. Now type:
|
|
Packit |
667938 |
|
|
Packit |
667938 |
make
|
|
Packit |
667938 |
|
|
Packit |
667938 |
This builds the rateup binary and edits all the perl pathnames in
|
|
Packit |
667938 |
the scripts. You can now install mrtg by typing
|
|
Packit |
667938 |
|
|
Packit |
667938 |
make install (requires gnu install)
|
|
Packit |
667938 |
|
|
Packit |
667938 |
All the software required by MRTG is now installed under
|
|
Packit |
667938 |
the F</usr/local/mrtg-2> subdirectory.
|
|
Packit |
667938 |
|
|
Packit |
667938 |
You can now safely delete the libraries we compiled above. Then
|
|
Packit |
667938 |
again, you might want to keep them around so that you have them
|
|
Packit |
667938 |
available when compiling the next version of mrtg.
|
|
Packit |
667938 |
|
|
Packit |
667938 |
=head1 CONFIGURATION
|
|
Packit |
667938 |
|
|
Packit |
667938 |
The next step is to configure mrtg for monitoring a network
|
|
Packit |
667938 |
device. This is done by creating an F<mrtg.cfg> file which defines
|
|
Packit |
667938 |
what you want to monitor. Luckily, you don't have to dive straight in
|
|
Packit |
667938 |
and start writing your own configuration file all by
|
|
Packit |
667938 |
yourself. Together with mrtg you also got a copy of B<cfgmaker>. This
|
|
Packit |
667938 |
is a script you can point at a router of your choice; it will
|
|
Packit |
667938 |
create a mrtg configuration file for you. You can find the script in
|
|
Packit |
667938 |
the F<bin> subdirectory.
|
|
Packit |
667938 |
|
|
Packit |
667938 |
cfgmaker --global 'WorkDir: /home/httpd/mrtg' \
|
|
Packit |
667938 |
--global 'Options[_]: bits,growright' \
|
|
Packit |
667938 |
--output /home/mrtg/cfg/mrtg.cfg \
|
|
Packit |
667938 |
community@router.abc.xyz
|
|
Packit |
667938 |
|
|
Packit |
667938 |
This example above will create an mrtg config file in
|
|
Packit |
667938 |
F</home/mrtg/cfg> assuming this is a directory visible on your
|
|
Packit |
667938 |
webserver. You can read all about cfgmaker in L<cfgmaker>. One area you might
|
|
Packit |
667938 |
want to look at is the possibility of using B<--ifref=ip> to prevent
|
|
Packit |
667938 |
interface renumbering troubles from catching you.
|
|
Packit |
667938 |
|
|
Packit |
667938 |
If you want to start rolling your own mrtg configuration files, make sure
|
|
Packit |
667938 |
you read L<mrtg-reference> to learn all about the possible configuration options.
|
|
Packit |
667938 |
|
|
Packit |
667938 |
=head1 RUNNING MRTG
|
|
Packit |
667938 |
|
|
Packit |
667938 |
Once you have created a configuration file, try the following:
|
|
Packit |
667938 |
|
|
Packit |
667938 |
/usr/local/mrtg-2/bin/mrtg /home/mrtg/cfg/mrtg.cfg
|
|
Packit |
667938 |
|
|
Packit |
667938 |
This will query your router and also create your first mrtg trafic
|
|
Packit |
667938 |
graphs and webpages. When you run mrtg for the first time there will
|
|
Packit |
667938 |
be a lot of complaints about missing log files. Don't worry, this is
|
|
Packit |
667938 |
normal for the first 2 times you start mrtg. If it keeps complaining
|
|
Packit |
667938 |
after this time you might want to look into the problem.
|
|
Packit |
667938 |
|
|
Packit |
667938 |
Starting mrtg by hand is not ideal in the long run. So when you are
|
|
Packit |
667938 |
satisfied with the results you can automate the process of running mrtg in
|
|
Packit |
667938 |
regular intervals (this means every 5 minutes by default).
|
|
Packit |
667938 |
|
|
Packit |
667938 |
You can either add mrtg to your crontab with a line like this:
|
|
Packit |
667938 |
|
|
Packit |
667938 |
0,5,10,15,20,25,30,35,40,45,50,55 * * * * \
|
|
Packit |
667938 |
<mrtg-bin>/mrtg <path to mrtg-cfg>/mrtg.cfg \
|
|
Packit |
667938 |
--logging /var/log/mrtg.log
|
|
Packit |
667938 |
|
|
Packit |
667938 |
or if you live in Linux Land the line may look like this if you are
|
|
Packit |
667938 |
using C<crontab -e>
|
|
Packit |
667938 |
|
|
Packit |
667938 |
*/5 * * * * <mrtg-bin>/mrtg <path to mrtg-cfg>/mrtg.cfg \
|
|
Packit |
667938 |
--logging /var/log/mrtg.log
|
|
Packit |
667938 |
|
|
Packit |
667938 |
or like this if you use F</etc/crontab>
|
|
Packit |
667938 |
|
|
Packit |
667938 |
*/5 * * * * mrtg-user <mrtg-bin>/mrtg <path to mrtg-cfg>/mrtg.cfg \
|
|
Packit |
667938 |
--logging /var/log/mrtg.log
|
|
Packit |
667938 |
|
|
Packit |
667938 |
You can also run mrtg as a daemon process by adding the line
|
|
Packit |
667938 |
|
|
Packit |
667938 |
RunAsDaemon: Yes
|
|
Packit |
667938 |
|
|
Packit |
667938 |
to your mrtg configuration file and then creating a startup script in
|
|
Packit |
667938 |
your system startup sequence. Unfortunately, adding startup scripts
|
|
Packit |
667938 |
differs widely amongst different unix systems. The modern ones normally
|
|
Packit |
667938 |
have a directory called F</etc/init.d> or F</etc/rc.d/init.d> where you
|
|
Packit |
667938 |
put scripts which starts the process you want to run when the system
|
|
Packit |
667938 |
boots. Further you must create a symbolic link in F</etc/rc3.d> or
|
|
Packit |
667938 |
F</etc/rc.d/rc?.d> called F<S65mrtg> (this is just a sample name
|
|
Packit |
667938 |
... it is just important that it starts with S followed by a two digit
|
|
Packit |
667938 |
number). If you are not sure about this, make sure you consult the
|
|
Packit |
667938 |
documentation of your system to make sure you get this right.
|
|
Packit |
667938 |
|
|
Packit |
667938 |
A B<minimal> script to put into F<init.d> might look like this:
|
|
Packit |
667938 |
|
|
Packit |
667938 |
#! /bin/sh
|
|
Packit |
667938 |
cd /usr/local/mrtg-2.17.7/bin && ./mrtg --user=mrtg-user \
|
|
Packit |
667938 |
/home/httpd/mrtg/mrtg.cfg --logging /var/log/mrtg.log
|
|
Packit |
667938 |
|
|
Packit |
667938 |
|
|
Packit |
667938 |
Note that this will only work with B<RunAsDaemon: Yes> in your
|
|
Packit |
667938 |
mrtg.cfg file.
|
|
Packit |
667938 |
|
|
Packit |
667938 |
=head1 AUTHOR
|
|
Packit |
667938 |
|
|
Packit |
667938 |
Tobias Oetiker E<lt>tobi@oetiker.chE<gt>
|
|
Packit |
667938 |
|