HOWTO: Compile, configure and run MRTG

Are you using a modified cfg... it certainly appears you havnt followed the howto guide exactly either way...

Chris
 
Ok my mistake :D

Could you paste your exact current mrtg.cfg.

Thanks,
Chris (who needs to get some sleep! :p)
 
Forgot - if you do use my cfg, make sure you put the system file in that tarball in /var/www/html/mrtg/ and chmod it runable. (And of course, you can put it anywhere you want, but you'll have modify the cfg.)

Good luck :)
 
I've been using MRTG for ages, figured out most of the configs myself, but i now have a bit of a problem which i am unable to solve.
I've taken a look at the howto, and the sh scripts, but the methods described here are methods i already tried. I need to see the traffic per IP instead of per networkcard (NIC).
Is this possible with MRTG ?
And if so, can anyone give me a cfg for that ?

To illustrate what i mean, here's a part of my ifconfig :
eth0 Link encap:Ethernet HWaddr 00:20:55:14:AF:73
inet addr:<ip1>
RX bytes:821403724 (783.3 Mb) TX bytes:1564562115 (1492.0 Mb)
eth0:0 Link encap:Ethernet HWaddr 00:20:55:14:AF:73
inet addr:<ip2>
eth0:1 Link encap:Ethernet HWaddr 00:20:55:14:AF:73
inet addr:<ip3>

I need to find out the exact traffic for <ip3>...
 
I have done everything upto this point without any problems, but i dont have a /html/mrtg folder.

in /home/my domain i have a mrtg-2.10.12
is this the correct folder? This is where i ran the install from.


// now, if you did not recieve any error messages and everything went ok its time to get your cfg sorted and everything else setup.

// Please replace the /path/to/html/folder/ with the actual path to the html folder of the site which you wish to display the mrtg graphs at.

# cd /path/to/html/folder/mrtg/



# pico -w mrtg.sh

// paste the following code in the file:
// (Thanks to ryanz on the plesk forums for this)

#!/bin/sh

INFO=`grep eth0 /proc/net/dev | tr -s ' ' ' ' | cut -d: -f2`
RECEIVE=`echo $INFO | cut -d" " -f1`
TRANSMIT=`echo $INFO | cut -d" " -f9`
UPTIME=`uptime | tr -s ' ' ' ' | cut -d" " -f4-`
echo $RECEIVE
echo $TRANSMIT
echo $UPTIME
echo "yourdomain.com"

// CTRL and X to exit, press y to confirm the file save.

# chmod 755 mrtg.sh

// Now to create the CFG

# pico -w mrtg.cfg

WorkDir: /path/to/html/folder/mrtg/

Target[index]: `/path/to/html/folder/mrtg/mrtg.sh`
MaxBytes[index]: 25000000
Title[index]: Traffic and Load Analysis
PageTop[index]: <H1>Traffic and Load Analysis</H1>
Xsize[index]: 400
YSize[index]: 200


// nearly done!!
// now you can start it to see if its worked :)
// Check where mrtg is installed... it should be /usr/local/mrtg-2/
// if it is different replace the following paths appropiately

# /usr/local/mrtg-2/bin/mrtg /path/to/html/folder/mrtg/mrtg.cfg

// now depending what domain you used as the /path/to/html/folder go to the domain with a trailing mrtg, for example, if you used the path to the html folder of myfavdomain.com you would now go to:

http://myfavdomain.com/mrtg/index.html

you should see some pretty empty graphs :p

if thats the case, you can now add mrtg to cron to have it run every 5 minutes (or any other lengh you wish to use) to keep them graphs up2date.

# pico -w /etc/crontab

// after all the other lines enter this:

*/5 * * * * /usr/local/mrtg-2/bin/mrtg /path/to/html/folder/mrtg/mrtg.cfg

// Please note the above line contains the same line used to start mrtg above, you can paste the line you used to start to speed things up slighly if you wish.

Now give it a few hours to notice the graphs in any detail. After just 1 hour you should start seeing data on your daily graph :)

Hope you enjoy this HOWTO guide :) any problems please feel free to post here.

Chris
 
Im going to re-write this guide in a day or two with totally new downloadbales etc etc...... regarding the html directory

just replace

cd /path/to/html/folder/mrtg/

with

cd /var/www/html
mkdir mrtg
cd mrtg


As I said... new guide coming soon to clean everything up!

(that will leave a total of 3 mrtg installations / guides.. all posted by me! :eek: )

Chris
 
Anybody ever get it compiled on FreeBSD 4.8 with DA?

I get:

checking gd.h usability... yes
checking gd.h presence... yes
checking for gd.h... yes

** Ooops, one of many bad things happened:

a) You don't have the GD library installed.
Get it from http://www.boutell.com, compile it and
use either --with-gd-lib=DIR and --with-gd-inc=DIR to specify
its location. You might also have to use --with-z-inc,
--with-z-lib and --with-png-inc, --with-png-lib for gd
versions 1.6 and higher. Check config.log for more
information on the problem.

b) You have the GD library installed, but not the gd.h
header file. Download the source (see above) and use
--with-gd-inc=DIR to specify where the file can be found.

c) You have the library and the header file installed, but
you also have a shared GD library in the same directory.
Remove the shared library files and/or links (e.g.
libgd.so.2.0.0, libgd.so and libgd.so.2). This is especially
likely if you're using a recent (post 1.8.4) version of GD
and didn't configure it with --disable-shared.

Consider following the instructions in doc/unix-guide.txt

No matter which gd.h I specify it to use (even ones in locations without the shared .so files) I still get it...clues?
 
I have error when i 'make install':

[root@gandalf mrtg-2.10.13]# pwd
/root/MRTG/mrtg-2.10.13
[root@gandalf mrtg-2.10.13]# make install
/bin/sh ./mkinstalldirs /usr/local/mrtg-2/bin
for x in ./bin/mrtg ./bin/cfgmaker ./bin/indexmaker; do \
/usr/bin/install -c -m 755 $x /usr/local/mrtg-2/bin; done
for x in bin/rateup; do \
/usr/bin/install -c -m 755 $x /usr/local/mrtg-2/bin; done
/usr/bin/install: cannot stat `bin/rateup': No such file or directory
make: *** [install] Error 1

cannot stat ? what's that?
 
YouCMe said:
I've running mrtg but does somebody know how to make graphs for each ip adress on your server?

Good luck, I've been trying this for ages...
You could use a iptables counter, but so far I don't have an idea how to start one up, furthermore, in (i thought it was) Debian there is a program to count this, but it's not compatible with redhat (as i can't find the source code).
What you could try is: Install IPFM and configure it so it outputs the traffic for the IP's you want, parse these configs with a program that can output 4 values (look at MRTG howto's for which values exactly) and use that.
I tried this, but on my test server it didn't work, since it's kinda counting the wrong things...
 
Hmm on the server of a friend of me a other hosting company installed his MRTG and he has it for each IP!
I have his .pl files and his configuration file for MRTG to make the graphs, the only thing i miss is his IP Table.
I don't know anything about IP Tables but if he has it running.. is there some way to *see* his IP tables so i can get the code for counting the traffic?
Then i only have to get the ip table rules on my own server =)
 
Can you perhaps post these cfg's, configs and perl script ?

If there are any iptables persent, you can view them by :
iptables --list
while logged in as root...
 
DOn't have very much time at the moment, but i'd say you would need to adept iptraffic-rules to match your own ip's
and :
$basedir= "/home/httpd/vhosts/kene.nl/httpdocs/mrtg/"; # This directory where mrtg saves its .log and .html files
$snapshots="/home/httpd/vhosts/kene.nl/httpdocs/mrtg/snapshots"; # Where 95.pl will save a daily copy of the .log files

in the .pl.


Target[81.173.116.153]: `/home/boot/iptraffic --ip=81.173.116.153`
Target[81.173.116.154]: `/home/boot/iptraffic --ip=81.173.116.154`
Target[81.173.116.155]: `/home/boot/iptraffic --ip=81.173.116.155`
In the .cfg file will also need to be adapted to match your config...


I'll try them at a testserver tonight.
 
hmm those files i had allready changed for my own system
but when i run the command that mrtg calls i get a iptable message

i'll show you:

[root@hercules mrtg]# /home/boot/iptraffic --ip=81.173.116.157
iptables: Table does not exist (do you need to insmod?)
Use of uninitialized value in concatenation (.) or string at /home/boot/iptraffic line 51.
Use of uninitialized value in concatenation (.) or string at /home/boot/iptraffic line 51.


a very long time :)
81.173.116.157


that's the output when i run it, so i think it's something with the ip tables that doesn exist.
but the guy is online who has it working i'll let him do the iptables command to see if he has any iptable rules for it :)
 
My ip table --list output:
[root@hercules mrtg]# iptables --list
Chain INPUT (policy ACCEPT)
target prot opt source destination

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination



His ip table --list output:

[root@cleopatra root]# iptables --list
Chain INPUT (policy ACCEPT)
target prot opt source destination
iptraffic all -- anywhere anywhere

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination
iptraffic all -- anywhere anywhere

Chain iptraffic (2 references)
target prot opt source destination
all -- 81.173.116.110 !81.173.116.110
all -- !81.173.116.110 81.173.116.110
all -- 81.173.116.109 !81.173.116.109
all -- !81.173.116.109 81.173.116.109
all -- 81.173.116.108 !81.173.116.108
all -- !81.173.116.108 81.173.116.108
all -- 81.173.116.107 !81.173.116.107
all -- !81.173.116.107 81.173.116.107
all -- 81.173.116.106 !81.173.116.106
all -- !81.173.116.106 81.173.116.106
all -- 81.173.116.105 !81.173.116.105
all -- !81.173.116.105 81.173.116.105
all -- 81.173.116.104 !81.173.116.104
all -- !81.173.116.104 81.173.116.104
all -- 81.173.116.103 !81.173.116.103
all -- !81.173.116.103 81.173.116.103
all -- 81.173.116.102 !81.173.116.102
all -- !81.173.116.102 81.173.116.102
all -- kene.nl !kene.nl
all -- !kene.nl kene.nl


so i really mis the tables :rolleyes:
 
Back
Top