Help - Search - Members - Calendar
Full Version: How-to MRTG on cPanel
The Planet Forums > Control Panels > cPanel/WHM > Cpanel/WHM HOWTOs
Sh4ka
The Multi Router Traffic Grapher (MRTG) is a tool to monitor the traffic load on network-links. MRTG generates HTML pages containing graphical images which provide a LIVE visual representation of this traffic. Check http://www.ee.ethz.ch/stats/mrtg/ for an example.

Let's begin:

# Move to your download folder.
cd /root/downloads

# Unninstal in case we have an old/broken installation
rpm -e mrtg

# Get the rpm
wget http://www.dedicated-resources.com/files/m...cpanel.i386.rpm

# Installing the app
rpm -Uvh mrtg-2.9.17-1cpanel.i386.rpm

# Moving libpng
cd /usr/lib
mv libpng.so.2 libpng.so.2.OLD

# Creating the symlink
ln -s libpng.so.3 libpng.so.2

# Edit language at and specify only "en_US"
pico /etc/sysconfig/i18n

# Restarting MRTG
service mrtg restart

# Configurating MRTG to allow only our local IP to see the reports at http://IP/mrtg

pico /usr/local/apache/conf/httpd.conf

#Search for the line (CTRL+W):


# It should look like this:


Options Indexes FollowSymlinks MultiViews
AllowOverride None
Order allow,deny
Allow from all


#After the last line (
) paste this and change allowed IPs:


order deny,allow
allow from [ SERVER IP ]
allow from [YOUR LOCAL IP]
deny from all


# Restarting httpd
service httpd restart

# Let's put MRTG to start with the system
chkconfig --level 0123456 mrtg on

# Add mrtg to the up2date skip-list. If you don't do this, after system updates your MRTG will be broken.
up2date --configure
# Select the skip-list option
# Add mrtg to the skip-list
"mrtg*"

# If you have problems with Exim after MRTG is restarted, you don't have to worry about that because that mean that you don't have no mail, and MRTG takes that as an error, but if you don't want to see those error messages, you can do this:

# Edit file:
pico /etc/mrtg/check-email

# Change to "*-H" "* -H".

After this steps, your MRTG report should be available at: http://SERVER_IP/mrtg

That's all.
instantnet
Looks like everythign installed ok but I dont see it at the url
Also I think posting


order deny,allow
allow from [ SERVER IP ]
allow from [YOUR LOCAL IP]
deny from all


in the middle of


.....


I would thin it would be at the end or before but not the middle. I have it before and it is not showing up. Also posting in the middle causes http errors.
totohost
This work great for me. Thank you for howto.
Sh4ka
I've changed the text to be more clear with apache restrictions to MRTG. And yes, you are right, I typed "under" and it was "before" that line, I know I don't speak a perfect english icon_razz.gif

Good luck.

pd: remember to change "SERVER IP" and "YOUR LOCAL IP" for the real IP addresses icon_wink.gif
benito
Hi Sh4ka !

Im getting those messages on RHEL4

WARNING: Problem with External get '/etc/mrtg/system swap':
Expected a Number for 'in' but got ''

WARNING: Problem with Externale get '/etc/mrtg/system swap':
Expected a Number for 'out' but got ''

You have any fix for this ?
uneedawebsite
Getting the same error message with RHEL3.
benito
QUOTE(uneedawebsite)
Getting the same error message with RHEL3.


I found the solution on this board by "Penguin"

Do:

CODE
#pico /etc/mrtg/system


And replace all your SWAP code with this one:

CODE




if [ "$TYPE" = "swap" ]; then

INDATA=`/usr/bin/free -b | grep "Swap:" | sed 's/ * / /g' | cut -d ' ' -f2`

OUTDATA=`/usr/bin/free -b | grep "Swap:" | sed 's/ * / /g' | cut -d ' ' -f3`



uneedawebsite
Thanks for the info. I did that and everything is working now.

Mark
uneedawebsite
Had this working for weeks but today my Daily graph is showing up as an X and the stats for Weekly and Monthly are all 0.00.

I tried restarting the mrtg service and got the following showing up as an error multiple times:

libpng warning: Application was compiled with png.h from libpng-1.2.2
libpng warning: Application is running with png.c from libpng-1.0.13
gd-png: fatal libpng error: Incompatible libpng version in application and library
WARNING: rateup died from Signal 11


I haven't done anything to libpng in the way of an update, so wondering why I am getting this error all of a sudden and how to fix it.

Mark
Manuel
Hi

First of all I would like to express my great thanks to Sh4ka and benito!

I have installed the mrtg successfully. I could easily restart the MRTG deamon but I could not check it via internet, I am not sure what is the error.

When tried to check http://server.servername.com/mrtg/ I received the MRTG manual page.

How could I check the MRTG?
misterq
rm /usr/local/apache/htdocs/mrtg/index.html

that will get rid of the manual page. The next time MRTG recreates the pages (every 5 mins), it will recreate it with the proper index page that shows load average.
Jeff
QUOTE(Sh4ka @ Oct 15 2005, 03:59 PM) [snapback]366082[/snapback]
The Multi Router Traffic Grapher (MRTG) is a tool to monitor the traffic load on network-links. MRTG generates HTML pages containing graphical images which provide a LIVE visual representation of this traffic. Check http://www.ee.ethz.ch/stats/mrtg/ for an example.
CODE
Let's begin:
# Move to your download folder.
cd /root/downloads
# Unninstal in case we have an old/broken installation
rpm -e mrtg
# Get the rpm
wget [url=http://www.dedicated-resources.com/files/mrtg-2.9.17-1cpanel.i386.rpm]http://www.dedicated-resources.com/files/m...cpanel.i386.rpm[/url]
# Installing the app
rpm -Uvh mrtg-2.9.17-1cpanel.i386.rpm
# Moving libpng
cd /usr/lib
mv libpng.so.2 libpng.so.2.OLD
# Creating the symlink
ln -s libpng.so.3 libpng.so.2
# Edit language at and specify only "en_US"
pico /etc/sysconfig/i18n
# Restarting MRTG
service mrtg restart
# Configurating MRTG to allow only our local IP to see the reports at [url=http://IP/mrtg]http://IP/mrtg[/url]
pico /usr/local/apache/conf/httpd.conf
#Search for the line (CTRL+W):
<Directory "/usr/local/apache/htdocs/manual">
# It should look like this:
    <Directory "/usr/local/apache/htdocs/manual">
        Options Indexes FollowSymlinks MultiViews
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>
#After the last line (</Directory>) paste this and change allowed IPs:
    <Directory "/usr/local/apache/htdocs/mrtg/">
    order deny,allow
    allow from [ SERVER IP ]
    allow from [YOUR LOCAL IP]
    deny from all
    </Directory>
# Restarting httpd
service httpd restart
# Let's put MRTG to start with the system
chkconfig --level 0123456 mrtg on
# Add mrtg to the up2date skip-list. If you don't do this, after system updates your MRTG will be broken.
up2date --configure
# Select the skip-list option
# Add mrtg to the skip-list
"mrtg*"
# If you have problems with Exim after MRTG is restarted, you don't have to worry about that because that mean that you don't have no mail, and MRTG takes that as an error, but if you don't want to see those error messages, you can do this:
# Edit file:
pico /etc/mrtg/check-email
# Change  to "*-H" "* -H".
After this steps, your MRTG report should be available at: [url=http://SERVER_IP/mrtg]http://SERVER_IP/mrtg[/url]
That's all.

Excellent tutorial and RPM - thanks!

(quoting original text in code brackets because otherwise new forum software makes invisible everything with brackets)
Jeff
Hmmm... memory usage report seems way off though for some reason ???

MRTG reports:
CODE
Max Used:      640.9 MB (96.3%)           Average Used:      574.2 MB (86.3%)           Current Used:      640.9 MB (96.3%)
Max Buffers + Cache:     0.0 B (0.0%)         Average Buffers + Cache:     0.0 B (0.0%)         Current Buffers + Cache:     0.0 B (0.0%)


Free reports:
CODE
total       used       free     shared    buffers     cached
Mem:       2055364    2029824      25540          0     137860     876200
-/+ buffers/cache:    1015764    1039600
Swap:      4192924      86332    4106592

Any ideas?
Jeff
Never mind, piece of cake.

Just edit /etc/mrtg/mrtg.cfg after installing and change
MaxBytes[localhost.mem]:
to the amount of RAM in the system. After RPM install this value was 640 MB for some reason.
James Jhurani
this post helped me 2 yrs later smile.gif
SergioC
Please help,
I have followed all the instructions to the T, but I am receiving an email that says:

Daemonizing MRTG ...

I know it is comming from my CRON that reads:
*/5 * * * * /usr/bin/mrtg /etc/mrtg/mrtg.cfg --logging /var/log/mrtg.log

How do I fix this?

Thanks for your help.

Regards,
Sergio
SergioC
It seems that yesterday cpanel updated my MRTG once again.

So, all the changes that I did are wrong and I am receiving every 5 minutes the following email:

ERROR: I Quit! Another copy of mrtg seems to be running. Check /etc/mrtg/mrtg.pid
Daemonizing MRTG ...

How I do a complete uninstall of MRTG?

Regards,
Sergio
James Jhurani
you can remove it removing the cron job, and typing "rpm -e mrtg".

Do you have a ticket open regarding it? If so, I can take a look at it for you.
Jeff
I just followed this again to install on two RHEL5 cpanel servers and it worked fine, all these years later. I did add mrtg* to my /etc/yum.conf exclude list
Jeff
One question -- does anyone know how to direct mrtg to /100 the load graph? Instead of 1 for example mrtg displays a load of 1 as 100 which I find confusing.

James Jhurani
QUOTE(Jeff @ Dec 12 2007, 08:06 PM) *
One question -- does anyone know how to direct mrtg to /100 the load graph? Instead of 1 for example mrtg displays a load of 1 as 100 which I find confusing.


If I understand what you are asking correctly, then the directive to change this is kMG in the mrtg config file.
If I misunderstood, then I would suggest looking at http://oss.oetiker.ch/mrtg/doc/mrtg-reference.en.html. It explains pretty much every directive in the config file.
Jeff
Will give it a try. For some reason I can't wrap my head around the simple explanation given there.

(the factor variable allows me to display the caption as load 0.1 instead of load 10 but doesn't affect the graph)

I know the title and caption by default say load x 100 but I still can't get used to loads reported that way and want to graph load like you see at the command prompt ... i.e. 0 to 1 instead of 1 to 100
SergioC
QUOTE(jjhurani @ Dec 13 2007, 01:19 AM) *
you can remove it removing the cron job, and typing "rpm -e mrtg".

Do you have a ticket open regarding it? If so, I can take a look at it for you.

Thankyou Jjhurani,
I have just opened my ticket for it.

Wish I could have MRTG running, but I have tried a lot of times including this HOW TO, but with no luck. I was sure that I wrote MRTG on the exception list for cpanel not to update / upgrade this but it seems it didn't work.

My ticket number is: 4448552PLNT

Hope you can help me.

Regards,
Sergio
James Jhurani
QUOTE(SergioC @ Dec 13 2007, 03:16 PM) *
Thankyou Jjhurani,
I have just opened my ticket for it.

Wish I could have MRTG running, but I have tried a lot of times including this HOW TO, but with no luck. I was sure that I wrote MRTG on the exception list for cpanel not to update / upgrade this but it seems it didn't work.

My ticket number is: 4448552PLNT

Hope you can help me.

Regards,
Sergio


just got to work, and grabbed your ticket.
SergioC
QUOTE(jjhurani @ Dec 14 2007, 10:51 AM) *
just got to work, and grabbed your ticket.

I really want to thanks James for helping me with this.

BIG THANK YOU.

Sergio
James Jhurani
any time icon_smile.gif
markcausa
James is a pimp (in a flattering way.) Keep it up "Faze!"
Old_Red
I can get MRTG installed and working fine about after a couple of days it stops with the following error :-

libpng warning: Application was compiled with png.h from libpng-1.2.7
libpng warning: Application is running with png.c from libpng-1.0.16
gd-png: fatal libpng error: Incompatible libpng version in application and library
WARNING: rateup died from Signal 11

Anyone any idea how to fix this ?

Thanks
markcausa
Ah, this might mean you need to recompile your PHP.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.