HOWTO: Install MRTG (FULLY AUTOMATED)

Works great on my server with fedora core 3.

Had to install the Perl URI rpm first, dunno why but otherwise it worked perfectly.
 
freebsd

Hi,

Has anyone confirmed this works with freebsd?

Linux and bsd has different ways of finding CPU usage etc, the /proc (I think it is) in linux provides all cpu, ram, etc.

Has there been a method built for bsd?

thanks
baz
 
link error

Hi there,
The script won't work coz the link to grab the mrtg is access restricted.
This is what i get:
Code:
Downloading the most recent MRTG and installing it...
--07:53:43--  [url]http://people.ee.ethz.ch/%7Eoetiker/webtools/mrtg/pub/mrtg.tar.gz[/url]
           => `mrtg.tar.gz'
Resolving people.ee.ethz.ch... 129.132.2.203
Connecting to people.ee.ethz.ch[129.132.2.203]:80... connected.
HTTP request sent, awaiting response... 403 Forbidden
07:53:43 ERROR 403: Forbidden.

tar (child): mrtg.tar.gz: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error exit delayed from previous errors

When i try to load the link in browser, i get :
Forbidden

You don't have permission to access /~oetiker/webtools/mrtg/pub/mrtg.tar.gz on this server.

Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.


Could some1 email me the above tar file to [email protected] pls?

Thanks!
 
Fixed the problem, i replaced the 2 lines in the install.sh file to:
Code:
echo "Downloading the most recent MRTG and installing it..."
wget [url]http://people.ee.ethz.ch/~oetiker/webtools/mrtg/pub/mrtg-2.12.2.tar.gz[/url]
tar zfx mrtg-2.12.2.tar.gz

Also, pls make sure u have have the following installed:
In order to compile and use mrtg you need a C compiler and a copy of perl installed on your machine. In most cases this will already be available. In case it is not, here are some starting points. Below I'll give you a detailed run through the whole compilation process.

GCC
The GNU C compiler comes preinstalled on most of the free Unicies out there. For commercial derivatives you may have to download and compile it first. If you have no compiler at all there is a chicken and egg problem, but there are also precompiled versions of gcc available for most operating systems.

http://gcc.gnu.org/

Perl
Large parts of the MRTG system are written in the Perl scripting language. Make sure there is a recent copy of perl on your machine (try perl -v). At least version 5.005 is required for mrtg to work well. You can get the latest perl from

http://www.perl.com/

MRTG generates traffic graphs in the PNG format. To be able to do this it needs several 3rd party libraries. When compiling these libraries I urge you to make sure you compile them as static libraries. There is just much less trouble ahead if you are doing it like this. See the Instructions in the next section for inspiration. Note that many free unices have all the required libraries already in place so there is no need to install another copy. To check it is best to skip all the library instructions below and go straight into the mrtg compile.

If the first attempt fails and you do not get a working version of mrtg, try compiling new copies of all libraries as explained below. Do this BEFORE you send email to me about problems compiling mrtg.

gd
This is a basic graph drawing library created by Thomas Boutell. Note that all releases after Version 1.3 only create PNG images. This is because a) Thomas got into trouble because the GIF format which it used to produce uses a compression technology patented by Unisys. b) PNG is more efficient and patent free. MRTG can work with old and new version of the GD library. You can get a recent copy of GD from:

http://www.boutell.com/gd/

libpng
Is required by gd in order to produce PNG graphics files. Get it from:

http://www.libpng.org/pub/png/libpng.html

zlib
Is needed by libpng to compress the graphics files you create. Get a copy from

http://www.gzip.org/zlib
 
The script worked for me once I made the change mikron15 mentioned. Before that, it also failed for me. All looks good, thanks for the script. :)
 
No error at all. I am running on CentOS 4.1.

Is there any chance you can teach me to uninstall fully and install it again?
 
Uninstall Instructions

For those of you that want to uninstall MRTG (assuming you used this installer), please follow these steps:


1) Open /etc/crontab and remove the line that reads: */5 * * * * root /usr/local/mrtg-2/bin/mrtg /var/www/html/mrtg/core/mrtg.cfg
2) rm -rf /usr/local/mrtg-2/
3) rm -rf /var/www/html/mrtg/
 
Then how should I re-install everything? I have follow the solution properly and I have received that website link. What do you think probably happen?
 
The directory /var/www/html/mrtg does not exist. I will create it...
Creating necessary directories and preparing for installation...
Preparations complete...
Downloading the most recent MRTG and installing it...
--20:47:57-- http://people.ee.ethz.ch/~oetiker/webtools/mrtg/pub/mrtg.tar.gz
=> `mrtg.tar.gz'
Resolving people.ee.ethz.ch... 129.132.2.203
Connecting to people.ee.ethz.ch|129.132.2.203|:80... connected.
HTTP request sent, awaiting response... 403 Forbidden
20:48:00 ERROR 403: Forbidden.

tar (child): mrtg.tar.gz: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error exit delayed from previous errors
./install.mrtg.sh: line 43: cd: mrtg*: No such file or directory
./install.mrtg.sh: line 44: ./configure: No such file or directory
make: *** No targets specified and no makefile found. Stop.
make: *** No rule to make target `install'. Stop.
MRTG has been installed...
Updating MRTG config and template...
--20:48:00-- http://www.serveio.com/da/mrtgcfg.tar.gz
=> `mrtgcfg.tar.gz'
Resolving www.serveio.com... 69.9.34.242
Connecting to www.serveio.com|69.9.34.242|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2,056 (2.0K) [application/x-gzip]

100%[==================================================================================================>] 2,056 --.--K/s

20:48:01 (217.86 MB/s) - `mrtgcfg.tar.gz' saved [2056/2056]

Update complete!
Adding MRTG to /etc/crontab...
Executing MRTG for the first time (you may see some warnings)...
./install.mrtg.sh: line 64: /usr/local/mrtg-2/bin/mrtg: No such file or directory
If you see warnings above, it is generally safe to ignore.
Cleaning up installation...
Installation of MRTG complete!

================================

I know why my MRTG doesn't work cos it can't download the latest MRTG from the URL stated in the install.mrtg.sh

Can anyone update the program?
 
miltongoh,

You can do this yourself by editing the "install.mrtg.sh" file after you have downloaded it. Use an editor like vi, pico or joe, locate the line
Code:
 http://people.ee.ethz.ch/~oetiker/webtools/mrtg/pub/mrtg.tar.gz
and change it so that it looks like this:
Code:
 http://people.ee.ethz.ch/~oetiker/webtools/mrtg/pub/mrtg-2.12.2.tar.gz
you will also need to change the next line that is used to untar the file so that it looks like this:
Code:
tar zfx mrtg-2.12.2.tar.gz
Save the file and then run the installer ./install.mrtg.sh this is how I got my install to work and is what mikron15 mentioned about 8 post up. :)
 
Hi,

I have done everything. I think MRTG should be installed. One thing about now is that it is shown like this.

http://202.172.234.79/mrtg/

It is the MRTG homepage rather the graph. is there something wrong with the mrtg.cfg?

Can someone advise me on that please.
 
Thats whats puzzling me, i did this install on 2 boxes and it worked fine after i made those changes to the install file. But mine never pointed to MRTG homepage.

Also, note that, the install.sh file didnt add the crontab as it hsould have. So i added it manually. You can accomplish this by typing crontab -e in ur ssh prompt. Then paste:
Code:
*/5 * * * * root env LANG=C /usr/local/mrtg-2/bin/mrtg /var/www/html/mrtg/core/mrtg.cfg
Make sure u leave an empty line after the */5 * * line.
Then hit escape key, followed by Shift+: key and then type wq ( followed by enter) to save it

you will now be back at the prompt.
At the prompt , excute this line 2 -3 times.
env LANG=C /usr/local/mrtg-2/bin/mrtg /var/www/html/mrtg/core/mrtg.cfg

And then check ur mrtg link and see if it works


You can pm me ur msn id so i can add yah and probably take a look at ur server
 
Last edited:
Do you mind posting how u fixed it so it will benefit others in future.

thanks!
 
Back
Top