The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

MRTG for Centos 4.2 and Cpanel

Discussion in 'General Discussion' started by Wallaby, Dec 7, 2005.

  1. Wallaby

    Wallaby Well-Known Member

    Joined:
    Aug 15, 2001
    Messages:
    131
    Likes Received:
    1
    Trophy Points:
    18
    Can anyone point me to a how-to for a Centos 4.2 server with CPanel?

    The stuff I can find is aimed at RedHat 9.x, Fedora or RHE 3.x.

    Or, maybe even better, does anyone have info on a robust easy-to-install alternative to MRTG? It seems to be such a pain to get right and so prone to needing different tweaks to get it going on different OS flavours!

    Cheers!
     
  2. u-hosts

    u-hosts Member

    Joined:
    Dec 7, 2005
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    1
    Well, This is quite simple, I am running mrtg in centOS 4.2 and cPanel.
     
  3. Wallaby

    Wallaby Well-Known Member

    Joined:
    Aug 15, 2001
    Messages:
    131
    Likes Received:
    1
    Trophy Points:
    18
    Does anyone have a more helpful response?
     
  4. AlexSmithMCP

    AlexSmithMCP Well-Known Member

    Joined:
    May 26, 2004
    Messages:
    66
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    Root Administrator
    Cacti with SNMP support on your machine. If its the local machine you want stats on it also has a bunch of "Local" only graphs.

    Use this as you snmpd.conf

    Code:
    com2sec local     127.0.0.1/32    public
    
    group MyROGroup v1         local
    group MyROGroup v2c        local
    group MyROGroup usm        local
    
    view all    included  .1                               80
    
    access MyROGroup ""      any       noauth    exact  all    none   none
    
    syslocation MyLocation
    syscontact Me <me@somewhere.org>
    and then just download and install cacti as per the install guide. http://cacti.net/

    I can't comment on using RPM's - I run cacti from a Gentoo Server that only does monitering, but installing by hand is better imho.

    There are a bunch of benifts of cacti over MRTG imho:

    1) can graph more than one device (I have it doing ~20 - switches, routers and servers)
    2) there are alot of extras you can make it graph, for example MySQL load, Shoutcast Load or pretty much anything u can script to make results. (http://forums.cacti.net/forum-5.html)
    3) i think the graphs look better :P

    Hope that helps somewhat.

    Alex
     
  5. Lastqaurk

    Lastqaurk Member

    Joined:
    Jun 29, 2006
    Messages:
    23
    Likes Received:
    0
    Trophy Points:
    1
    ========================================================================================================
    S N M P
    ========================================================================================================

    Step # 1 : Make sure snmp server installed
    ------------------------------------------
    # rpm -qa | grep snmp

    Make sure snmp utils is installed
    # yum install net-snmp-utils net-snmp

    Step # 2 : Determine if snmp server is running or not
    -----------------------------------------------------
    # ps -aux | grep snmp
    ...output
    root 5512 0.0 2.3 5872 3012 pts/0 S 22:04 0:00 /usr/sbin/snmpd

    Start service using following command:
    # service snmpd start

    Make sure snmpd service starts automatically, when linux comes us (add snmpd service):
    # chkconfig --add snmpd

    Step # 3 : Make sure snmp server configured properly
    ----------------------------------------------------
    Run snmpwalk utility to request for tree of information about network entity:
    # snmpwalk -v 1 -c public localhost IP-MIB::ipAdEntIfIndex
    ...output
    IP-MIB::ipAdEntIfIndex.127.0.0.1 = INTEGER: 1

    Step # 4 : Configure SNMP
    -------------------------
    # nano /etc/snmp/snmpd.conf

    Change/Modify line(s) as follows:
    com2sec notConfigUser default public

    ..replace with:
    com2sec local localhost public
    com2sec network_1 xxx.xxx.xxx.0/24 public

    Find Lines:
    group notConfigGroup v1 notConfigUser
    group notConfigGroup v2c notConfigUser

    ..replace with:
    group MyRWGroup v1 local
    group MyRWGroup v2c local
    group MyRWGroup usm local
    group MyROGroup v1 network_1
    group MyROGroup v2c network_1
    group MyROGroup usm network_1

    Find line:
    view systemview included system

    ..replace with:
    view all included .1 80

    Find line:
    access notConfigGroup "" any noauth exact systemview none none

    ..replace with:
    access MyROGroup "" any noauth exact all none none
    access MyRWGroup "" any noauth exact all all none

    Find lines:
    syslocation Unknown (edit /etc/snmp/snmpd.conf)
    syscontact Root (configure /etc/snmp/snmp.local.conf)

    ..replace with:
    syslocation Linux (Centos_4.2), YourDomain.com.
    syscontact Your Name <yourname@yourdomain.com>

    Start your snmp server and test it:
    (a) Make sure when linux comes up snmpd always starts:
    # chkconfig snmpd on

    (b) Make sure service start whenever Linux comes up (after reboot):
    # service snmpd start

    (c) Finally test your snmp server:
    # snmpwalk -v 1 -c public localhost IP-MIB::ipAdEntIfIndex

    ========================================================================================================
    M R T G
    ========================================================================================================

    Step # 1 : Install mrtg if not installed
    ----------------------------------------
    Mrtg software may install during initial installation; you can verify if MRTG installed or not with following RPM command:
    # rpm -qa | grep mrtg

    Use yum command as follows to install MRTG:
    # yum install mrtg

    Step # 2 : Configuring MRTG
    ---------------------------
    [root@host]# cfgmaker --output=/etc/mrtg/mrtg.cfg \
    --global "workdir: /var/www/mrtg" -ifref=ip \
    --global 'options[_]: growright,bits' \
    public@localhost

    Step # 3 : Edit mrtg.cfg
    ------------------------
    Edit /etc/mrtg/mrtg.cfg, and remove the sections related to interfaces you don't need to monitor. A certain candidate would be the virtual loopback interface Lo: (with the IP address of 127.0.0.1), which doesn't pass any network traffic at all.

    Step # 4 : Add "127.0.0.1" and Maxbytes for Virtuozzo users
    --------------------------------------------------------
    Target[localhost_2]: 2:public@localhost:
    SetEnv[localhost_2]: MRTG_INT_IP="127.0.0.1" MRTG_INT_DESCR="venet0"
    MaxBytes[localhost_2]: 1250000
    Title[localhost_2]: Traffic Analysis for 2 -- youhost.com
    PageTop[localhost_2]: <H1>Traffic Analysis for 2 -- yourhost.com</H1>
    <TABLE>
    <TR><TD>System:</TD> <TD>yourhost.com in Linux (Centos_4.2), Yourhost Router</TD></TR>
    <TR><TD>Maintainer:</TD> <TD>Your Name &lt;yourname@yourhost.com&gt;</TD></TR>
    <TR><TD>Description:</TD><TD>venet0 </TD></TR>
    <TR><TD>ifType:</TD> <TD>Other (1)</TD></TR>
    <TR><TD>ifName:</TD> <TD></TD></TR>
    <TR><TD>Max Speed:</TD> <TD>1250.0 kBytes/s</TD></TR>
    </TABLE>

    Step # 5: Run MRTG using /etc/mrtg/mrtg.cfg as your argument three timeronnies.
    -------------------------------------------------------------------------
    [root@host]# env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg

    Step # 6: Use MRTG's indexmaker command to create a Web index page using your new mrtg.cfg file as a guide.
    ----------------------------------------------------------------------------------------------------------
    [root@host]# indexmaker --output=/var/www/mrtg/index.html \
    /etc/mrtg/mrtg.cfg

    Step # 7: MRTG is run every five minutes by default, and the file that governs this is /etc/cron.d/mrtg.
    -------------------------------------------------------------------------------------------------------
    For MRTG to work correctly, edit this file, replacing all occurrences of /usr/bin/mrtg with env LANG=C /usr/bin/mrtg. The explanation for changing the language character set for MRTG is given in the "Troubleshooting MRTG" section.

    Step # 8: Getting MRTG To Poll Multiple Devices
    -----------------------------------------------
    The Centos MRTG installation process creates a cron file named /etc/cron.d/mrtg. This file tells the cron daemon to run MRTG using the /etc/mrtg/mrtg.cfg file every five minutes to poll your network devices. You can configure MRTG to poll multiple devices, each with a separate configuration file. Here's how:
    1) Create a new configuration file using the steps from the previous section; choose a filename that is not mrtg.cfg.
    2) Add a new MRTG line in /etc/cron.d/mrtg for each new configuration file you create.

    0-59/5 * * * * root env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
    0-59/5 * * * * root env LANG=C /usr/bin/mrtg /etc/mrtg/device1.cfg
    0-59/5 * * * * root env LANG=C /usr/bin/mrtg /etc/mrtg/device2.cfg

    3) Run the indexmaker command, and include all of your /etc/mrtg configuration files, to regenerate your Web index page.
    [root@host]# indexmaker --output=/var/www/mrtg/index.html \
    /etc/mrtg/mrtg.cfg /etc/mrtg/device1.cfg /etc/mrtg/device2.cfg

    4) Other versions of Linux keep their MRTG cron entries inside the /etc/crontab file. Edit this file using the same syntax as the Fedora /etc/cron.d/mrtg file, and then restart the cron daemon to re-read the configuration:

    [root@host]# service crond restart

    You could also create a script with the /usr/bin/mrtg /etc/mrtg/device.cfg entries in it and make cron run it every five minutes. This way you can just edit the script each time you add a device without having to restart cron.

    Step # 9: Configuring Apache To Work With MRTG
    ----------------------------------------------
    MRTG creates an add-on configuration file named /etc/httpd/conf.d/mrtg.conf that includes all the necessary Apache commands for MRTG to work.

    <Location /mrtg>
    Order deny,allow
    Allow from all
    </Location>

    Apache automatically reads the add-on files in the /etc/httpd/conf.d/ directory. With Centos, you have to specifically configure the Apache configuration file /etc/httpd/conf/httpd.conf to find it. You can do this yourself by inserting this line at the very bottom of the main Apache configuration file before restarting Apache for the change to take effect.

    include "/etc/httpd/conf.d/mrtg.conf"

    Step # 10: View The MRTG Graphs In Your Web Browser
    ---------------------------------------------------
    http://yourhost.com/mrtg/
     
  6. mahinder

    mahinder Well-Known Member

    Joined:
    Jun 12, 2003
    Messages:
    68
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    matrix
    while trying to install mrtg i get perl(URI) missing error. I have reinstall URI 2-3 times but i still get this error. Can any one help?

    Code:
    yum install mrtg
    Setting up Install Process
    Setting up repositories
    Reading repository metadata in from local files
    Excluding Packages in global exclude list
    Finished
    Parsing package install arguments
    Resolving Dependencies
    --> Populating transaction set with selected packages. Please wait.
    ---> Package mrtg.i386 0:2.10.15-1 set to be updated
    --> Running transaction check
    --> Processing Dependency: perl(URI) for package: mrtg
    --> Finished Dependency Resolution
    Error: Missing Dependency: perl(URI) is needed by package mrtg
    
     
    #6 mahinder, Nov 14, 2006
    Last edited: Nov 14, 2006
  7. Lyttek

    Lyttek Well-Known Member

    Joined:
    Jan 2, 2004
    Messages:
    770
    Likes Received:
    3
    Trophy Points:
    18
    FWIW, the Munin service monitor seems to be providing a lot of info...
     
  8. mahinder

    mahinder Well-Known Member

    Joined:
    Jun 12, 2003
    Messages:
    68
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    matrix
    but checking mail queue on mrtg is better !!! it provides good paterns for spam control.
     
  9. AndyB78

    AndyB78 Active Member

    Joined:
    Oct 7, 2003
    Messages:
    35
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Romania
    Great post! Thanks! It actually helped me install MRTG. Now I have to figure out how to use it.

    PS: at step 2 before ifref 2 dashes are needed instead of a single one...
     
    #9 AndyB78, Jan 11, 2009
    Last edited: Jan 11, 2009
Loading...

Share This Page