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

NAME

6       mrtg-unix-guide - The MRTG 2.17.7 Linux/Unix Installation Guide
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. If you use SNMPV3 and other new features you should use at
32           least 5.8.
33
34           You can get the latest perl from
35
36            http://www.perl.com/
37
38       MRTG generates traffic graphs in the PNG format. To be able to do this
39       it needs several 3rd party libraries. When compiling these libraries I
40       urge you to make sure you compile them as static libraries. There is
41       just much less trouble ahead if you are doing it like this. See the
42       Instructions in the next section for inspiration. Note that many free
43       unices have all the required libraries already in place so there is no
44       need to install another copy. To check it is best to skip all the
45       library instructions below and go straight into the mrtg compile.
46
47       If the first attempt fails and you do not get a working version of
48       mrtg, try compiling new copies of all libraries as explained below. Do
49       this BEFORE you send email to me about problems compiling mrtg.
50
51       gd  This is a basic graph drawing library created by Thomas Boutell.
52           Note that all releases after Version 1.3 only create PNG images.
53           This is because a) Thomas got into trouble because the GIF format
54           which it used to produce uses a compression technology patented by
55           Unisys. b) PNG is more efficient and patent free. MRTG can work
56           with old and new version of the GD library. You can get a recent
57           copy of GD from:
58
59            http://www.boutell.com/gd/
60
61       libpng
62           Is required by gd in order to produce PNG graphics files. Get it
63           from:
64
65            http://www.libpng.org/pub/png/libpng.html
66
67       zlib
68           Is needed by libpng to compress the graphics files you create.  Get
69           a copy from
70
71            http://www.gzip.org/zlib
72
73       And last but not least you also need mrtg itself. In case you have not
74       yet downloaded it, you can find a copy on my website:
75
76        http://oss.oetiker.ch/mrtg/pub
77

LIBRARY COMPILATION

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

MRTG COMPILATION

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

CONFIGURATION

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

RUNNING MRTG

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

AUTHOR

268       Tobias Oetiker <tobi@oetiker.ch>
269
270
271
2722.17.7                            2018-07-13                MRTG-UNIX-GUIDE(1)
Impressum