Page 1 of 13 12311 ... LastLast
Results 1 to 20 of 247

Thread: HOWTO: Install MRTG (FULLY AUTOMATED)

  1. #1
    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/
    Last edited by loopforever; 06-06-2008 at 05:52 AM.
    Matt Savona
    serveIO
    Creator of the DirectAdmin Enhanced Theme

  2. #2
    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

  3. #3
    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

  4. #4
    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

  5. #5
    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

  6. #6
    Join Date
    Mar 2005
    Posts
    62
    With http://serverip/mrtg/ just went good

    why wont access by domain?

  7. #7
    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

  8. #8
    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

  9. #9
    Join Date
    Sep 2003
    Location
    The Netherlands
    Posts
    556
    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:
    [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
    Last edited by Icheb; 04-22-2005 at 03:08 AM.

  10. #10
    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

  11. #11
    Join Date
    Sep 2003
    Location
    The Netherlands
    Posts
    556
    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:
    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:
    [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...

  12. #12
    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!
    Last edited by loopforever; 04-22-2005 at 11:18 AM.
    Matt Savona
    serveIO
    Creator of the DirectAdmin Enhanced Theme

  13. #13
    Join Date
    Feb 2005
    Posts
    294
    works great , thank you

    Great running on CentOS 3.4 and CentOS 4.0
    Last edited by servertweak; 04-23-2005 at 06:21 PM.
    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

  14. #14
    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

  15. #15
    Join Date
    Oct 2003
    Posts
    392
    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!

  16. #16
    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.

  17. #17
    Join Date
    Sep 2003
    Location
    The Netherlands
    Posts
    556
    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 .

  18. #18
    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

  19. #19
    Join Date
    Apr 2005
    Posts
    14
    Hi,
    I dont get it how do i view those stats now?

    Weccop

  20. #20
    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

Page 1 of 13 12311 ... LastLast

Similar Threads

  1. HOWTO : MRTG for Mailscanner
    By interfasys in forum How-To Guides
    Replies: 9
    Last Post: 09-05-2008, 08:43 PM
  2. APF fully automated
    By Maniak in forum How-To Guides
    Replies: 26
    Last Post: 06-29-2007, 02:04 AM
  3. HOWTO: Install MRTG (FULLY AUTOMATED) 2.12.2
    By @how@ in forum How-To Guides
    Replies: 73
    Last Post: 05-12-2007, 12:10 AM
  4. HOWTO: Compile, configure and run MRTG
    By ProWebUK in forum How-To Guides
    Replies: 115
    Last Post: 08-21-2005, 07:18 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •