DirectAdmin Forums

Go Back   DirectAdmin Forums > Modifications / Add-ons > How-To Guides

Reply
 
Thread Tools Display Modes
  #1  
Old 04-18-2005, 05:22 PM
loopforever loopforever is offline
Verified User
 
Join Date: May 2003
Location: /home/admin
Posts: 298
HOWTO: Install MRTG (FULLY AUTOMATED)

Hi Guys,

** June 6th. 2008: MRTG tarball location has been updated to reflect it's new home on the official MRTG site. Also worth noting, I haven't updated this thread since 2005. Jeeze...you guys have been using this thing for a while!

With the addition of a new server I found myself in the position of installing MRTG again. Chris (ProWebUK) wrote up a nice guide for installing MRTG manually - but I found the config to be lacking in some of the features I needed to monitor.

So, I grabbed the mrtg.cfg from an old CPanel rpm and modified it slightly to work on a DA machine. The script I wrote will automatically download and install the latest version of MRTG and apply a very nice config for your viewing pleasure. Please note...I take ABSOLUTELY no credit for the mrtg.cfg included - I simply made a small modification and wrote an installer for the whole process.

The installer will check to see if you have anything installed in /var/www/html/mrtg - if you have mrtg installed in another directory, you should remove it first. If you are already running MRTG, you need to make sure you delete it and its crontab entry before continuing with the installer.

Guide:
Code:
wget http://serveio.com/da/install.mrtg.sh
chmod +x install.mrtg.sh
./install.mrtg.sh
When the process is done MRTG will be installed in:

/var/www/html/mrtg

and can be viewed at:

http://your.hostname.com/mrtg

You can see the output of my install at:

http://loop.serveio.com/mrtg

Enjoy!

Confirmed Supported OSs:

RedHat 9
Fedora Core 3
Fedora Core 2
Debian 3.0
CentOS 3.4
CentOS 4.0

If this installer works properly for you, please let me know what OS you used so I can update this list!

Uninstall Instructions

For those of you that want to uninstall MRTG (assuming you used this installer), please follow these steps:
  • Open /etc/crontab and remove the line that reads:
    */5 * * * * root /usr/local/mrtg-2/bin/mrtg /var/www/html/mrtg/core/mrtg.cfg
  • rm -rf /usr/local/mrtg-2/
  • rm -rf /var/www/html/mrtg/
__________________
Matt Savona
serveIO
Creator of the DirectAdmin Enhanced Theme

Last edited by loopforever; 06-06-2008 at 05:52 AM.
Reply With Quote
  #2  
Old 04-18-2005, 06:33 PM
jmstacey's Avatar
jmstacey jmstacey is offline
Verified User
 
Join Date: Feb 2004
Location: Colorado
Posts: 4,111
Just installed it and working perfectly on Debian 3.0

Thanks for the script loopforever
__________________
Just do what it takes to make it happen
Reply With Quote
  #3  
Old 04-18-2005, 06:40 PM
loopforever loopforever is offline
Verified User
 
Join Date: May 2003
Location: /home/admin
Posts: 298
Great! If you install it on any other OSs, let me know. I'll keep a list of confirmed operating systems for everyone's reference.
__________________
Matt Savona
serveIO
Creator of the DirectAdmin Enhanced Theme
Reply With Quote
  #4  
Old 04-21-2005, 08:52 AM
jodasi jodasi is offline
Verified User
 
Join Date: Mar 2005
Posts: 62
FAILED ON

CentOS4

It gives a message of INSTALLED OK

created the /var/www/html/mrtg dir, bust acessing to

http://www.server.com/mrtg just gives nothing

Now the question is

How to remove-it
Reply With Quote
  #5  
Old 04-21-2005, 10:06 AM
loopforever loopforever is offline
Verified User
 
Join Date: May 2003
Location: /home/admin
Posts: 298
It would be helpful if you provided the output of the install script whereever errors occurred. Do you even know if it gave you an error?

You also must access the mrtg directory through your servers host name or IP. Not a Vhost in your httpd.conf.

Try:

http://serverip/mrtg

And if that doesn't work, please tell me what errors the install script produced.
__________________
Matt Savona
serveIO
Creator of the DirectAdmin Enhanced Theme
Reply With Quote
  #6  
Old 04-21-2005, 12:06 PM
jodasi jodasi is offline
Verified User
 
Join Date: Mar 2005
Posts: 62
With http://serverip/mrtg/ just went good

why wont access by domain?
Reply With Quote
  #7  
Old 04-21-2005, 02:43 PM
loopforever loopforever is offline
Verified User
 
Join Date: May 2003
Location: /home/admin
Posts: 298
You cannot access files in your global html directory through vhosts. Vhosts direct you to shared accounts on a given IP. The only way to access anything in the global html directory is through any ip or domain that is pointing to your server but does not have a virtualhost configured. You can add an A record (infact...you should most definitely add an A record) that points hostname.yourdomain.com -> yourip.
__________________
Matt Savona
serveIO
Creator of the DirectAdmin Enhanced Theme
Reply With Quote
  #8  
Old 04-21-2005, 11:16 PM
jmstacey's Avatar
jmstacey jmstacey is offline
Verified User
 
Join Date: Feb 2004
Location: Colorado
Posts: 4,111
You could add an alias to the httpd.conf file so that it would be like /webmail /squirrelmail etc and accessible on all domains.
__________________
Just do what it takes to make it happen
Reply With Quote
  #9  
Old 04-22-2005, 03:06 AM
Icheb Icheb is offline
Verified User
 
Join Date: Sep 2003
Location: The Netherlands
Posts: 546
I usually get the following warnings:
Executing MRTG for the first time (you may see some warnings)...
-----------------------------------------------------------------------
ERROR: Mrtg will most likely not work properly when the environment
variable LANG is set to UTF-8. Please run mrtg in an environment
where this is not the case. Try the following command to start:

env LANG=C /usr/local/mrtg-2/bin/mrtg /var/www/html/mrtg/core/mrtg.cfg
-----------------------------------------------------------------------
If you see warnings above, it is generally safe to ignore.


Perhaps it's an idea to add the env LANG=C thingy to the crontab to avoid getting this error too much .
(Although I don't know if this is also required on all systems )

I looked at the network stats script, it's interesting that it uses not snmpd but the /proc data.

Edit:
Furthermore I get the following error on the server I installed this on to test it:
Quote:
[root@montu root]# env LANG=C /usr/local/mrtg-2/bin/mrtg /var/www/html/mrtg/core/mrtg.cfg
/var/www/html/mrtg/core/system: line 1: 546200-507712: command not found
WARNING: Problem with Externale get '/var/www/html/mrtg/core/system swap':
Expected a Number for 'out' but got ''

ERROR: Target[swap][_OUT_] ' $target->[3]{$mode} ' did not eval into defined data
__________________
http://www.sebsoft.nl

Last edited by Icheb; 04-22-2005 at 03:08 AM.
Reply With Quote
  #10  
Old 04-22-2005, 08:32 AM
loopforever loopforever is offline
Verified User
 
Join Date: May 2003
Location: /home/admin
Posts: 298
I will take a look at the LANG bit - I know that may be a bit of an issue for some people. Thanks for bringing it to my attention.

Also, regarding your "swap" error. This is the section of the system file which I rewrote because /proc/meminfo can vary from distro to distro. What OS are you trying to install on, and can you provide me the output of:

cat /proc/meminfo

Thanks!
__________________
Matt Savona
serveIO
Creator of the DirectAdmin Enhanced Theme
Reply With Quote
  #11  
Old 04-22-2005, 08:38 AM
Icheb Icheb is offline
Verified User
 
Join Date: Sep 2003
Location: The Netherlands
Posts: 546
I fixed the error by editing the system bash file; on some line in the swap part it calculates the amount of used swap. The way it calculates this is wrong for my bash version (most versions, I hope).

Edited that part so that it reads:
Quote:
if [ "$TYPE" = "swap" ]; then
SWAPFREE=`cat /proc/meminfo | grep "SwapFree" | sed 's/ //g' | cut -d ':' -f2 | cut -d 'k' -f1`
SWAPTOTAL=`cat /proc/meminfo | grep "SwapTotal" | sed 's/ //g' | cut -d ':' -f2 | cut -d 'k' -f1`
SWAPUSED=`expr $SWAPTOTAL - $SWAPFREE`
INDATA=$SWAPFREE
OUTDATA=$SWAPUSED
fi
Now it works fine
(calculating in bash should use the expr program instead of directly trying it in bash, in my opinion).

And for your pleasure:
Quote:
[root@montu core]# cat /proc/meminfo
total: used: free: shared: buffers: cached:
Mem: 494739456 479768576 14970880 0 76853248 131510272
Swap: 559308800 22380544 536928256
MemTotal: 483144 kB
MemFree: 14620 kB
MemShared: 0 kB
Buffers: 75052 kB
Cached: 108140 kB
SwapCached: 20288 kB
Active: 198612 kB
Inactive: 218064 kB
HighTotal: 0 kB
HighFree: 0 kB
LowTotal: 483144 kB
LowFree: 14620 kB
SwapTotal: 546200 kB
SwapFree: 524344 kB
edit: corrected an error, added some fat text to make it a bit more clear what I did...
__________________
http://www.sebsoft.nl
Reply With Quote
  #12  
Old 04-22-2005, 09:07 AM
loopforever loopforever is offline
Verified User
 
Join Date: May 2003
Location: /home/admin
Posts: 298
DOH!

Very cool - I apologize for that...I was on my way out the door from work when I slopped those two commands together. I will update the system file in my tarball for future uses.

Thanks!

Edit: Tarball has been updated with a revised system file!
__________________
Matt Savona
serveIO
Creator of the DirectAdmin Enhanced Theme

Last edited by loopforever; 04-22-2005 at 11:18 AM.
Reply With Quote
  #13  
Old 04-23-2005, 06:17 PM
servertweak's Avatar
servertweak servertweak is offline
Verified User
 
Join Date: Feb 2005
Posts: 293
works great , thank you

Great running on CentOS 3.4 and CentOS 4.0
__________________
ServerTweak Networks, LLC ServerTweak.com
ServerTweak.com: Premium Services, Powered by Customers.
Fremont & Los Angeles Locations | RAID 10 Dedicated Servers | Colocation | IP Transit | 1/4 - Full Cab & Cages sales

Last edited by servertweak; 04-23-2005 at 06:21 PM.
Reply With Quote
  #14  
Old 04-24-2005, 05:23 AM
PeterB PeterB is offline
Verified User
 
Join Date: Mar 2005
Posts: 30
http://loop.serveio.com/mrtg/cpu.html

I think you've got a bug there. It would be truely remarcable if your CPU can run at 280%.

Peter
Reply With Quote
  #15  
Old 04-27-2005, 11:56 AM
neorder neorder is offline
Verified User
 
Join Date: Oct 2003
Posts: 388
this is just great! i did try to speed time how to add more things to monitor in mrtg, but was not successful.

thanks.loopforever, you are one of the professionals here also!
Reply With Quote
  #16  
Old 04-27-2005, 01:41 PM
CEpeep CEpeep is offline
Registered User
 
Join Date: Apr 2005
Posts: 4
Working well on CentOS 3.4.

Is there any way I can get it to display my bandwidth in bits instead of bytes though? I tried adding "bits" to the options string in the cfg, but it didn't change anything. It's sort of a pain to have to multiply everything by 8 when I want to figure out how much of my pipe I'm using.

EDIT: I figured it out. Had to add it to the traffic options, not global options.

Last edited by CEpeep; 04-27-2005 at 01:49 PM.
Reply With Quote
  #17  
Old 04-28-2005, 01:38 AM
Icheb Icheb is offline
Verified User
 
Join Date: Sep 2003
Location: The Netherlands
Posts: 546
Btw: I don't know if anyone is interested in it, I've been working with MRTG for ages.
I've used this setup on one of my servers and am slowly adding more and more stats to it, if you are interested I'm willing to pm the specs so that they can be included in future releases.
At the moment the main addition is a Apache hit counter. (Total hits on server per hour)

When I have some more time, I'll add some other stuff as well .
__________________
http://www.sebsoft.nl
Reply With Quote
  #18  
Old 04-28-2005, 01:48 AM
loopforever loopforever is offline
Verified User
 
Join Date: May 2003
Location: /home/admin
Posts: 298
Icheb - That would be a great addition. I also so mention in another thread of a script that outputs mysql process information. I think these are two features we can easily include in the install script. With the addition of these I will also fix the bug that is report CPU usage incorrectly.

I'll try and get in touch with you shortly to put your Apache hit counter in the "system" script.
__________________
Matt Savona
serveIO
Creator of the DirectAdmin Enhanced Theme
Reply With Quote
  #19  
Old 04-29-2005, 09:32 AM
Weccop Weccop is offline
Verified User
 
Join Date: Apr 2005
Posts: 14
Hi,
I dont get it how do i view those stats now?

Weccop
Reply With Quote
  #20  
Old 04-29-2005, 02:45 PM
jmstacey's Avatar
jmstacey jmstacey is offline
Verified User
 
Join Date: Feb 2004
Location: Colorado
Posts: 4,111
Which stats Weccop?
mrtg - hostname.domain.com/mrtg
apache hit counter - probably requires a new configuration for mrtg it possible.
__________________
Just do what it takes to make it happen
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Howto: Install Horde 3.0.4/IMP on FreeBSD Wouter How-To Guides 77 05-30-2007 01:24 PM
HOWTO: Install MRTG (FULLY AUTOMATED) 2.12.2 @how@ How-To Guides 73 05-12-2007 12:10 AM
[RELEASE] Ruby on Rails Direct Admin Plugin vandal 3rd Party Software 84 04-13-2007 03:44 AM
SNMP is not supported by your PHP installation. deltaned General Technical Discussion & Troubleshooting 6 04-03-2005 10:50 AM
HOWTO: Very easy RPM based MRTG installation ProWebUK How-To Guides 60 03-12-2005 08:55 AM


All times are GMT -7. The time now is 07:40 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
DirectAdmin © 2007 JBMC Software