HOWTO: Install MRTG (FULLY AUTOMATED)

I believe you all need to at least run MRTG once before the HTML files will be created. To do that, SSH into your box as root and execute the following command:

Code:
env LANG=C /usr/local/mrtg-2/bin/mrtg /var/www/html/mrtg/core/mrtg.cfg

Do this at least twice, because the first time you might get some errors. Also, there is a line in your /etc/crontab file that needs to be altered. When this script is installed, it adds the following line to your crontab file:

Code:
*/5 * * * * root /usr/local/mrtg-2/bin/mrtg /var/www/html/mrtg/core/mrtg.cfg

That needs to be changed to this:

Code:
*/5 * * * * root env LANG=C /usr/local/mrtg-2/bin/mrtg /var/www/html/mrtg/core/mrtg.cfg

I hope this solves the problems you are having with getting MRTG to work.

Got it working on CentOS 4.4 64bit after doing the above hehe :D

not sure if its plotting the grpahs correcetly though i'll wait 24 hours and see.

I dont need any ports setup for this do I as im using a firewall other than the standard web server stuff correct?
 
next question is how do I get mrtg monitoring mutltiple servers? do I have to have apache/php etc on each server?
 
Nice work guys... I've added the changes to mine... even learnt a few commands in the process... but not getting any data appear for the extra sections.

99.9% sure I've entered them correctly.

Could it be some firewall ports i need to open in APF at all?

I'll post a link once i have this sorted :)

Cheers
Nath.

Nath,

Remove the DOT between mail and log. Becouse bij a default install from CentOS there wont be a file "mail.log" so it has to be "maillog".

Code:
if [ "$TYPE" = "sa" ]; then
    INDATA=`cat /var/log/maillog | grep "spamd: connection" | wc -l`
    OUTDATA=$INDATA
fi

Or download them conplete:
http://sv03.aklmedia.nl/filedump/system
http://sv03.aklmedia.nl/filedump/mrtg.cfg

Don't forget to chmod `system`. It should be executable (-rwxrwxrwx 1 root root 2020 Jul 27 23:58 system)
 
Last edited:
Nath,

Remove the DOT between mail and log. Becouse bij a default install from CentOS there wont be a file "mail.log" so it has to be "maillog".

Code:
if [ "$TYPE" = "sa" ]; then
    INDATA=`cat /var/log/maillog | grep "spamd: connection" | wc -l`
    OUTDATA=$INDATA
fi

Or download them conplete:
http://sv03.aklmedia.nl/filedump/system
http://sv03.aklmedia.nl/filedump/mrtg.cfg

Don't forget to chmod `system`. It should be executable (-rwxrwxrwx 1 root root 2020 Jul 27 23:58 system)
Addition: people who use debian has to use mail.log in stead of maillog :p
 
Thx Randy... the . was indeed preventing the SA scans from displaying ;)

tho I'm not convinced about the IMAP / POP3 logins and Email Delivered graphs being correct.

Email Spam Blocked is very much quiet too - which is odd, unless it depended on the SA Scan's section working.

If its ok, I will PM you with the link to the live graphs if you want a look randy. You might spot something from the output that I've missed.

Cheers guys.
Nath.
 
Thx Randy... the . was indeed preventing the SA scans from displaying ;)

tho I'm not convinced about the IMAP / POP3 logins and Email Delivered graphs being correct.

Email Spam Blocked is very much quiet too - which is odd, unless it depended on the SA Scan's section working.

If its ok, I will PM you with the link to the live graphs if you want a look randy. You might spot something from the output that I've missed.

Cheers guys.
Nath.


Nath,

I reather prefer direct mail (or MSN); [email protected].
 
Thank you very much, it looks very convenient. That's a great work

next question is how do I get mrtg monitoring mutltiple servers? do I have to have apache/php etc on each server?

However, I have the same problem. My company networks have many servers and I use one server to monitor others. How do I use this to monitor multiple server?

Thanks
 
Last edited:
quyenlt and flumps,

The default installation can't know your network details; you'll have to configure MRTG and make sure the necessary ports are open for snmp monitoring.

There's a fairly decent Mini How-To here.

(I just have our lead RHCE tech take care of it for me ;) ).

Jeff
 
quyenlt and flumps,

The default installation can't know your network details; you'll have to configure MRTG and make sure the necessary ports are open for snmp monitoring.

There's a fairly decent Mini How-To here.

(I just have our lead RHCE tech take care of it for me ;) ).

Jeff
But adding that to the config file means your network stats for the other servers are added, but if you like stats for the cpu/mem/processes/etc for the other servers it is another story?
 
Yes, then you have to install helper apps (I think that's what MRTG calls them) to each specific server.

We don't do it that way; we have each of our servers email us it's own statistics information.

Jeff
 
Yes, then you have to install helper apps (I think that's what MRTG calls them) to each specific server.

We don't do it that way; we have each of our servers email us it's own statistics information.

Jeff
Within a few days i will be looking for a method to let 1 mrtg installation get the statistics from other servers as well, this part together with more stats will be released within some weeks by Imtek, Randy and me.
 
i got same problem with this... mrtg not work in my server... u can see here
http://58.65.233.41/mrtg/ :(

only got "core" folder only..

btw here are my installation log..

[root@server /]#
[root@server /]# wget http://serveio.com/da/install.mrtg.sh
--02:09:49-- http://serveio.com/da/install.mrtg.sh
=> `install.mrtg.sh'
Resolving serveio.com... 69.9.34.242
Connecting to serveio.com|69.9.34.242|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1,987 (1.9K) [application/x-sh]

100%[====================================>] 1,987 --.--K/s

02:09:50 (65.34 MB/s) - `install.mrtg.sh' saved [1987/1987]

[root@server /]# chmod +x install.mrtg.sh
[root@server /]# ./install.mrtg.sh
MRTG Installer 1.0 ---------------------
By: Matt Savona (www.serveio.com)
----------------------------------------


Checking for previous MRTG installation...
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...
--02:10:04-- 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... 301 Moved Permanently
Location: http://people.ee.ethz.ch/ex-staff/oetiker [following]
--02:10:05-- http://people.ee.ethz.ch/ex-staff/oetiker
=> `oetiker'
Reusing existing connection to people.ee.ethz.ch:80.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://people.ee.ethz.ch/ex-staff/oetiker/ [following]
--02:10:06-- http://people.ee.ethz.ch/ex-staff/oetiker/
=> `index.html'
Reusing existing connection to people.ee.ethz.ch:80.
HTTP request sent, awaiting response... 200 OK
Length: 509 [text/html]

100%[====================================>] 509 --.--K/s

02:10:06 (22.06 MB/s) - `index.html' saved [509/509]

tar: mrtg.tar.gz: Cannot open: No such file or directory
tar: 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...
--02:10:06-- 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

02:10:07 (115.34 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 director
y
If you see warnings above, it is generally safe to ignore.
Cleaning up installation...
Installation of MRTG complete!


hope someone can suggest me how to solve it because i really need bandwidth monitoring tools in my serv.. :(
 
i got same problem... when i finish the installation i can't see the mrtg properly.. only i saw is "core" folder..

u can see it here http://58.65.233.41/mrtg


by the way below are my installation logg.. hope someone can tell me what should i do to resolve this problem...

[root@server /]# wget http://serveio.com/da/install.mrtg.sh
--02:09:49-- http://serveio.com/da/install.mrtg.sh
=> `install.mrtg.sh'
Resolving serveio.com... 69.9.34.242
Connecting to serveio.com|69.9.34.242|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1,987 (1.9K) [application/x-sh]

100%[====================================>] 1,987 --.--K/s

02:09:50 (65.34 MB/s) - `install.mrtg.sh' saved [1987/1987]

[root@server /]# chmod +x install.mrtg.sh
[root@server /]# ./install.mrtg.sh
MRTG Installer 1.0 ---------------------
By: Matt Savona (www.serveio.com)
----------------------------------------


Checking for previous MRTG installation...
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...
--02:10:04-- 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... 301 Moved Permanently
Location: http://people.ee.ethz.ch/ex-staff/oetiker [following]
--02:10:05-- http://people.ee.ethz.ch/ex-staff/oetiker
=> `oetiker'
Reusing existing connection to people.ee.ethz.ch:80.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://people.ee.ethz.ch/ex-staff/oetiker/ [following]
--02:10:06-- http://people.ee.ethz.ch/ex-staff/oetiker/
=> `index.html'
Reusing existing connection to people.ee.ethz.ch:80.
HTTP request sent, awaiting response... 200 OK
Length: 509 [text/html]

100%[====================================>] 509 --.--K/s

02:10:06 (22.06 MB/s) - `index.html' saved [509/509]

tar: mrtg.tar.gz: Cannot open: No such file or directory
tar: 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...
--02:10:06-- 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

02:10:07 (115.34 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 director
y
If you see warnings above, it is generally safe to ignore.
Cleaning up installation...
Installation of MRTG complete!
 
same problem

i have the same problem with this installation mrtg

i have folder in /var/www/html/mrtg and i have only folder "core" with mrtg.cfg and *system

when I enter address my site in web browser like http://myadress/mrtg i see this


You don't have permission to access /mrtg/ on this server. ?

I try chmod 777 and still error.
 
Please see my post earlier in this thread about the requirement of running MRTG at least once to create the HTML files. You also need to modify the entry in your /etc/crontab file.
 
Last edited:
Has anyone been able to implement the 95 percentile option?

The Metered 95% MRTG stat is a moving average taken over the last 30 days, with the top 5% of the peak usage discarded.

http://www.ronny-goerner.de/patch/

Sean Adams doesn't support that patch anymore so you need to grab it from places where people have copies of the script.

If anyone has been able to implement it,. please let me know how to apply it.

The instructions that I found didn't make sense to me.

thanks,

-Alon.
 
I use collectd to obtain stats about my server... uses rrdtool and seems to produce many more stats to give you a better look/view of the servers status.

Do to it's plugin facility, it's easy to write additional plugins. :)
 
anyone... pls help us to solve this problem..

The original script of the install.mrtg.sh needs to be updated.

It is trying to d/l the mrtg.tar.gz file from an old location that has been moved away, so it is no longer working.

pico/nano/vim the install.mrtg.sh such that you change one line in it:

You need to modify the line inside it of the wget from:

to


Once that path is fixed, the rest is working fine.

-Alon.
 
Back
Top