1MRTG-UNIX-GUIDE(1)                   mrtg                   MRTG-UNIX-GUIDE(1)
2
3
4

NAME

6       mrtg-unix-guide - Instructions for running MRTG 2.15.1 on a Unix Box
7

DESCRIPTION

9       MRTG comes to you in Source Code. This means that you have to compile
10       parts of it before you can use it on a Unix machine. These instructions
11       help you to do so.
12

PREPARATION

14       In order to compile and use mrtg you need a C compiler and a copy of
15       perl installed on your machine. In most cases this will already be
16       available.  In case it is not, here are some starting points. Below
17       I'll give you a detailed run through the whole compilation process.
18
19       GCC The GNU C compiler comes preinstalled on most of the free Unicies
20           out there.  For commercial derivatives you may have to download and
21           compile it first. If you have no compiler at all there is a chicken
22           and egg problem, but there are also precompiled versions of gcc
23           available for most operating systems.
24
25            http://gcc.gnu.org/
26
27       Perl
28           Large parts of the MRTG system are written in the Perl scripting
29           language.  Make sure there is a recent copy of perl on your machine
30           (try perl -v).  At least version 5.005 is required for mrtg to work
31           well.  You can get the latest perl from
32
33            http://www.perl.com/
34
35       MRTG generates traffic graphs in the PNG format. To be able to do this
36       it needs several 3rd party libraries. When compiling these libraries I
37       urge you to make sure you compile them as static libraries. There is
38       just much less trouble ahead if you are doing it like this. See the
39       Instructions in the next section for inspiration. Note that many free
40       unices have all the required libraries already in place so there is no
41       need to install another copy. To check it is best to skip all the
42       library instructions below and go straight into the mrtg compile.
43
44       If the first attempt fails and you do not get a working version of
45       mrtg, try compiling new copies of all libraries as explained below. Do
46       this BEFORE you send email to me about problems compiling mrtg.
47
48       gd  This is a basic graph drawing library created by Thomas Boutell.
49           Note that all releases after Version 1.3 only create PNG images.
50           This is because a) Thomas got into trouble because the GIF format
51           which it used to produce uses a compression technology patented by
52           Unisys. b) PNG is more efficient and patent free. MRTG can work
53           with old and new version of the GD library. You can get a recent
54           copy of GD from:
55
56            http://www.boutell.com/gd/
57
58       libpng
59           Is required by gd in order to produce PNG graphics files. Get it
60           from:
61
62            http://www.libpng.org/pub/png/libpng.html
63
64       zlib
65           Is needed by libpng to compress the graphics files you create.  Get
66           a copy from
67
68            http://www.gzip.org/zlib
69
70       And last but not least you also need mrtg itself. In case you have not
71       yet downloaded it, you can find a copy on my website:
72
73        http://oss.oetiker.ch/mrtg/pub
74

LIBRARY COMPILATION

76       In this section I will give you step by step instructions on how to
77       compile the various libraries required for the compilation of mrtg.
78       Note that these libaries may already be installed if you have a *BSD or
79       Linux system so you can skip recompiling them. The wget program used
80       below is a simple web downloader. You can also enter the address into
81       your netscape if you don't have wget available.
82
83       First let's create a directory for the compilation. Note that this may
84       already exist on your system. No problem, just use it.
85
86        mkdir -p /usr/local/src
87        cd /usr/local/src
88
89       If you do not have zlib installed:
90
91        wget http://www.gzip.org/zlib/zlib-1.1.4.tar.gz
92        gunzip -c zlib-*.tar.gz ⎪ tar xf -
93        rm zlib-*.tar.gz
94        mv zlib-* zlib
95        cd zlib
96        ./configure
97        make
98        cd ..
99
100       If you don't have libpng installed
101
102        wget http://public.planetmirror.com/pub/sourceforge/l/li/libpng/libpng-1.0.15.tar.gz
103        gunzip -c libpng-*.tar.gz ⎪tar xf -
104        rm libpng-*.tar.gz
105        mv libpng-* libpng
106        cd libpng
107        make -f scripts/makefile.std CC=gcc ZLIBLIB=../zlib ZLIBINC=../zlib
108        rm *.so.* *.so
109        cd ..
110
111       And now you can compile gd
112
113       For versions up to 1.8.4, try:
114
115        wget http://www.boutell.com/gd/http/gd-1.8.4.tar.gz
116        gunzip -c gd-*.tar.gz ⎪tar xf -
117        rm gd-*.tar.gz
118        mv gd-* gd
119        cd gd
120
121       The \ characters at the end of the following lines mean that all the
122       following material should actually be written on a single line.
123
124        perl -i~ -p -e s/gd_jpeg.o//g Makefile
125        make INCLUDEDIRS="-I. -I../zlib -I../libpng" \
126             LIBDIRS="-L../zlib -L. -L../libpng" \
127             LIBS="-lgd -lpng -lz -lm" \
128             CFLAGS="-O -DHAVE_LIBPNG"
129        cd ..
130
131       For version starting around 2.0.11, try:
132
133        wget http://www.boutell.com/gd/http/gd-2.0.11.tar.gz
134        gunzip -c gd-2.0.11.tar.gz ⎪tar xf -
135        mv gd-2.0.11 gd
136        cd gd
137        env CPPFLAGS="-I../zlib -I../libpng" LDFLAGS="-L../zlib -L../libpng" ./configure --disable-shared \
138            --without-freetype --without-jpeg
139        make
140        cp .libs/* .
141

MRTG COMPILATION

143       Ok, now everything is ready for the mrtg compilation.
144
145        cd /usr/local/src
146        gunzip -c mrtg-2.15.1.tar.gz ⎪ tar xvf -
147        cd mrtg-2.15.1
148
149       If all the libraries have been preinstalled on your system you can con‐
150       figure mrtg by doing a simple:
151
152        ./configure --prefix=/usr/local/mrtg-2
153
154       Otherwise you may have to give some hints on where to find the various
155       libraries required to compile mrtg:
156
157        ./configure --prefix=/usr/local/mrtg-2       \
158                    --with-gd=/usr/local/src/gd      \
159                    --with-z=/usr/local/src/zlib     \
160                    --with-png=/usr/local/src/libpng
161
162       If you have RRDtool available you might want to tell mrtg about it so
163       that you can opt to use rrdtool with mrtg. Check mrtg-rrd.
164
165       Configure will make sure your environment is fit for building mrtg.  If
166       it finds a problem, it will tell you so and it will also tell you what
167       to do about it. If everything is OK, you will end up with a custom
168       Makefile for your system. Now type:
169
170        make
171
172       This builds the rateup binary and edits all the perl pathnames in the
173       scripts. You can now install mrtg by typing
174
175        make install   (requires gnu install)
176
177       All the software required by MRTG is now installed under the
178       /usr/local/mrtg-2 subdirectory.
179
180       You can now safely delete the libraries we compiled above. Then again,
181       you might want to keep them around so that you have them available when
182       compiling the next version of mrtg.
183

CONFIGURATION

185       The next step is to configure mrtg for monitoring a network device.
186       This is done by creating an mrtg.cfg file which defines what you want
187       to monitor. Luckily, you don't have to dive straight in and start writ‐
188       ing your own configuration file all by yourself. Together with mrtg you
189       also got a copy of cfgmaker. This is a script you can point at a router
190       of your choice; it will create a mrtg configuration file for you. You
191       can find the script in the bin subdirectory.
192
193        cfgmaker --global 'WorkDir: /home/httpd/mrtg'  \
194                 --global 'Options[_]: bits,growright' \
195                 --output /home/mrtg/cfg/mrtg.cfg    \
196                  community@router.abc.xyz
197
198       This example above will create an mrtg config file in /home/mrtg/cfg
199       assuming this is a directory visible on your webserver. You can read
200       all about cfgmaker in cfgmaker. One area you might want to look at is
201       the possibility of using --ifref=ip to prevent interface renumbering
202       troubles from catching you.
203
204       If you want to start rolling your own mrtg configuration files, make
205       sure you read mrtg-reference to learn all about the possible configura‐
206       tion options.
207

RUNNING MRTG

209       Once you have created a configuration file, try the following:
210
211        /usr/local/mrtg-2/bin/mrtg /home/mrtg/cfg/mrtg.cfg
212
213       This will query your router and also create your first mrtg trafic
214       graphs and webpages. When you run mrtg for the first time there will be
215       a lot of complaints about missing log files. Don't worry, this is nor‐
216       mal for the first 2 times you start mrtg. If it keeps complaining after
217       this time you might want to look into the problem.
218
219       Starting mrtg by hand is not ideal in the long run. So when you are
220       satisfied with the results you can automate the process of running mrtg
221       in regular intervals (this means every 5 minutes by default).
222
223       You can either add mrtg to your crontab with a line like this:
224
225        0,5,10,15,20,25,30,35,40,45,50,55 * * * * \
226              <mrtg-bin>/mrtg <path to mrtg-cfg>/mrtg.cfg \
227                       --logging /var/log/mrtg.log
228
229       or if you live in Linux Land the line may look like this if you are
230       using "crontab -e"
231
232        */5 * * * *  <mrtg-bin>/mrtg <path to mrtg-cfg>/mrtg.cfg \
233                              --logging /var/log/mrtg.log
234
235       or like this if you use /etc/crontab
236
237        */5 * * * *  mrtg-user  <mrtg-bin>/mrtg <path to mrtg-cfg>/mrtg.cfg \
238                                        --logging /var/log/mrtg.log
239
240       You can also run mrtg as a daemon process by adding the line
241
242        RunAsDaemon: Yes
243
244       to your mrtg configuration file and then creating a startup script in
245       your system startup sequence. Unfortunately, adding startup scripts
246       differs widely amongst different unix systems. The modern ones normally
247       have a directory called /etc/init.d or /etc/rc.d/init.d where you put
248       scripts which starts the process you want to run when the system boots.
249       Further you must create a symbolic link in /etc/rc3.d or
250       /etc/rc.d/rc?.d called S65mrtg (this is just a sample name ... it is
251       just important that it starts with S followed by a two digit number).
252       If you are not sure about this, make sure you consult the documentation
253       of your system to make sure you get this right.
254
255       A minimal script to put into init.d might look like this:
256
257        #! /bin/sh
258        cd /usr/local/mrtg-2.15.1/bin && ./mrtg --user=mrtg-user \
259              /home/httpd/mrtg/mrtg.cfg  --logging /var/log/mrtg.log
260
261       Note that this will only work with RunAsDaemon: Yes in your mrtg.cfg
262       file.
263

AUTHOR

265       Tobias Oetiker <tobi@oetiker.ch>
266
267
268
2692.15.1                            2007-02-01                MRTG-UNIX-GUIDE(1)
Impressum