Blame doc/mrtg-unix-guide.txt

Packit 667938
MRTG-UNIX-GUIDE(1)                   mrtg                   MRTG-UNIX-GUIDE(1)
Packit 667938
Packit 667938
Packit 667938
Packit 667938
N?NA?AM?ME?E
Packit 667938
       mrtg-unix-guide - The MRTG 2.17.7 Linux/Unix Installation Guide
Packit 667938
Packit 667938
D?DE?ES?SC?CR?RI?IP?PT?TI?IO?ON?N
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
P?PR?RE?EP?PA?AR?RA?AT?TI?IO?ON?N
Packit 667938
       In order to compile and use mrtg you need a C compiler and a copy of
Packit 667938
       perl installed on your machine. In most cases this will already be
Packit 667938
       available.  In case it is not, here are some starting points. Below
Packit 667938
       I'll give you a detailed run through the whole compilation process.
Packit 667938
Packit 667938
       GCC The GNU C compiler comes preinstalled on most of the free Unicies
Packit 667938
           out there.  For commercial derivatives you may have to download and
Packit 667938
           compile it first. If you have no compiler at all there is a chicken
Packit 667938
           and egg problem, but there are also precompiled versions of gcc
Packit 667938
           available for most operating systems.
Packit 667938
Packit 667938
            http://gcc.gnu.org/
Packit 667938
Packit 667938
       Perl
Packit 667938
           Large parts of the MRTG system are written in the Perl scripting
Packit 667938
           language.  Make sure there is a recent copy of perl on your machine
Packit 667938
           (try perl -v). At least version 5.005 is required for mrtg to work
Packit 667938
           well. If you use SNMPV3 and other new features you should use at
Packit 667938
           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
       MRTG generates traffic graphs in the PNG format. To be able to do this
Packit 667938
       it needs several 3rd party libraries. When compiling these libraries I
Packit 667938
       urge you to make sure you compile them as s?st?ta?at?ti?ic?c libraries. There is
Packit 667938
       just much less trouble ahead if you are doing it like this. See the
Packit 667938
       Instructions in the next section for inspiration. Note that many free
Packit 667938
       unices have all the required libraries already in place so there is no
Packit 667938
       need to install another copy. To check it is best to skip all the
Packit 667938
       library instructions below 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
Packit 667938
       mrtg, try compiling new copies of all libraries as explained below. Do
Packit 667938
       this B?BE?EF?FO?OR?RE?E you send email to me about problems compiling mrtg.
Packit 667938
Packit 667938
       gd  This is a basic graph drawing library created by Thomas Boutell.
Packit 667938
           Note that all releases after Version 1.3 only create PNG images.
Packit 667938
           This is because a) Thomas got into trouble because the GIF format
Packit 667938
           which it used to produce uses a compression technology patented by
Packit 667938
           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
Packit 667938
           copy of GD from:
Packit 667938
Packit 667938
            http://www.boutell.com/gd/
Packit 667938
Packit 667938
       libpng
Packit 667938
           Is required by gd in order to produce PNG graphics files. Get it
Packit 667938
           from:
Packit 667938
Packit 667938
            http://www.libpng.org/pub/png/libpng.html
Packit 667938
Packit 667938
       zlib
Packit 667938
           Is needed by libpng to compress the graphics files you create.  Get
Packit 667938
           a copy from
Packit 667938
Packit 667938
            http://www.gzip.org/zlib
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
L?LI?IB?BR?RA?AR?RY?Y C?CO?OM?MP?PI?IL?LA?AT?TI?IO?ON?N
Packit 667938
       In this section I will give you step by step instructions on how to
Packit 667938
       compile the various libraries required for the compilation of mrtg.
Packit 667938
       Note that these libraries may already be installed if you have a _?*_?B_?S_?D
Packit 667938
       or _?L_?i_?n_?u_?x system so you can skip recompiling them. The w?wg?ge?et?t program used
Packit 667938
       below is a simple web downloader. You can also enter the address into
Packit 667938
       your n?ne?et?ts?sc?ca?ap?pe?e if you don't have w?wg?ge?et?t 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
M?MR?RT?TG?G C?CO?OM?MP?PI?IL?LA?AT?TI?IO?ON?N
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 various
Packit 667938
       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 so
Packit 667938
       that you can opt to use rrdtool with mrtg. Check mrtg-rrd.
Packit 667938
Packit 667938
       Configure will make sure your environment is fit for building mrtg.  If
Packit 667938
       it finds a problem, it will tell you so and it will also tell you what
Packit 667938
       to do about it. If everything is OK, you will end up with a custom
Packit 667938
       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 the
Packit 667938
       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 the
Packit 667938
       _?/_?u_?s_?r_?/_?l_?o_?c_?a_?l_?/_?m_?r_?t_?g_?-_?2 subdirectory.
Packit 667938
Packit 667938
       You can now safely delete the libraries we compiled above. Then again,
Packit 667938
       you might want to keep them around so that you have them available when
Packit 667938
       compiling the next version of mrtg.
Packit 667938
Packit 667938
C?CO?ON?NF?FI?IG?GU?UR?RA?AT?TI?IO?ON?N
Packit 667938
       The next step is to configure mrtg for monitoring a network device.
Packit 667938
       This is done by creating an _?m_?r_?t_?g_?._?c_?f_?g file which defines what you want
Packit 667938
       to monitor. Luckily, you don't have to dive straight in and start
Packit 667938
       writing your own configuration file all by yourself. Together with mrtg
Packit 667938
       you also got a copy of c?cf?fg?gm?ma?ak?ke?er?r. This is a script you can point at a
Packit 667938
       router of your choice; it will create a mrtg configuration file for
Packit 667938
       you. You can find the script in the _?b_?i_?n 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 _?/_?h_?o_?m_?e_?/_?m_?r_?t_?g_?/_?c_?f_?g
Packit 667938
       assuming this is a directory visible on your webserver. You can read
Packit 667938
       all about cfgmaker in cfgmaker. One area you might want to look at is
Packit 667938
       the possibility of using -?--?-i?if?fr?re?ef?f=?=i?ip?p to prevent interface renumbering
Packit 667938
       troubles from catching you.
Packit 667938
Packit 667938
       If you want to start rolling your own mrtg configuration files, make
Packit 667938
       sure you read mrtg-reference to learn all about the possible
Packit 667938
       configuration options.
Packit 667938
Packit 667938
R?RU?UN?NN?NI?IN?NG?G M?MR?RT?TG?G
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 be
Packit 667938
       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
Packit 667938
       in 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 "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 _?/_?e_?t_?c_?/_?c_?r_?o_?n_?t_?a_?b
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 _?/_?e_?t_?c_?/_?i_?n_?i_?t_?._?d or _?/_?e_?t_?c_?/_?r_?c_?._?d_?/_?i_?n_?i_?t_?._?d where you put
Packit 667938
       scripts which starts the process you want to run when the system boots.
Packit 667938
       Further you must create a symbolic link in _?/_?e_?t_?c_?/_?r_?c_?3_?._?d or
Packit 667938
       _?/_?e_?t_?c_?/_?r_?c_?._?d_?/_?r_?c_??_?._?d called _?S_?6_?5_?m_?r_?t_?g (this is just a sample name ... it is
Packit 667938
       just important that it starts with S followed by a two digit number).
Packit 667938
       If you are not sure about this, make sure you consult the documentation
Packit 667938
       of your system to make sure you get this right.
Packit 667938
Packit 667938
       A m?mi?in?ni?im?ma?al?l script to put into _?i_?n_?i_?t_?._?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
       Note that this will only work with R?Ru?un?nA?As?sD?Da?ae?em?mo?on?n:?: Y?Ye?es?s in your mrtg.cfg
Packit 667938
       file.
Packit 667938
Packit 667938
A?AU?UT?TH?HO?OR?R
Packit 667938
       Tobias Oetiker <tobi@oetiker.ch>
Packit 667938
Packit 667938
Packit 667938
Packit 667938
2.17.7                            2018-07-13                MRTG-UNIX-GUIDE(1)