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.

Any one have mod_cband source? The author web was down for many months.

Discussion in 'General Discussion' started by natong, Jun 10, 2008.

  1. natong

    natong Well-Known Member

    Joined:
    May 17, 2008
    Messages:
    85
    Likes Received:
    0
    Trophy Points:
    6
    #1 natong, Jun 10, 2008
    Last edited: Jun 11, 2008
  2. natong

    natong Well-Known Member

    Joined:
    May 17, 2008
    Messages:
    85
    Likes Received:
    0
    Trophy Points:
    6
  3. natong

    natong Well-Known Member

    Joined:
    May 17, 2008
    Messages:
    85
    Likes Received:
    0
    Trophy Points:
    6
    To configure module

    First you need to read these:
    http://www.cpanel.net/support/docs/ea/ea3/customdirectives.html

    You have to use Includes configuration file. There are two sections.

    1. Main section
    2. VirtualHost section

    Don't edit /usr/local/apache/conf/httpd.conf directly because it often generate by many scripts. I will tell you some short notes:

    1. Main section can add directives in WHM

    Main >> Service Configuration >> Apache Setup >> Include Editor

    It will modify /usr/local/apache/conf/includes/*.*

    2. VirtualHost section can add directives by

    /usr/local/apache/conf/userdata/<something>.conf
    /usr/local/apache/conf/userdata/(ssl|std)/<something>.conf
    /usr/local/apache/conf/userdata/(ssl|std)/(1|2)/<something>.conf
    /usr/local/apache/conf/userdata/(ssl|std)/(1|2)/<user>/<something>.conf
    /usr/local/apache/conf/userdata/(ssl|std)/(1|2)/<user>/<domain>/<something>.conf

    To verify that include files are valid with the running Apache:

    /scripts/verify_vhost_includes

    To update the include files for a single user:

    /scripts/ensure_vhost_includes --user=<user>

    To update include files for all users:

    /scripts/ensure_vhost_includes --all-users

    (by the way, --all-users has a bug. You need to run with --user one by one. So bad.)
     
    #3 natong, Jun 11, 2008
    Last edited: Sep 22, 2009
  4. natong

    natong Well-Known Member

    Joined:
    May 17, 2008
    Messages:
    85
    Likes Received:
    0
    Trophy Points:
    6
    Scoreboard is a file to save bandwidth stat. To restore bandwidth stat after restart httpd, you have to config CBandScoreboard directive for each VirtualHost.

    To prevent bad performance, you don't need to flush the bandwidth stat to file too often (default is every single request).

    Add these directives to Apache main section by Includes file:

     
    #4 natong, Jun 11, 2008
    Last edited: Jun 12, 2008
  5. natong

    natong Well-Known Member

    Joined:
    May 17, 2008
    Messages:
    85
    Likes Received:
    0
    Trophy Points:
    6
    To monitor bandwidth stat, add these directives in your VirtualHost Includes file:

    In this example, the bandwidth stat will reset every 4 weeks.
     
    #5 natong, Jun 11, 2008
    Last edited: Jun 12, 2008
  6. natong

    natong Well-Known Member

    Joined:
    May 17, 2008
    Messages:
    85
    Likes Received:
    0
    Trophy Points:
    6
    To save bandwidth stat to file, add these directives in your VirtualHost Includes file:

    If you use the same file for two or more VirtualHost, it will divide into equal value for each VirtualHost after restart httpd.

    Don't forget to chown these folder to apache!

     
    #6 natong, Jun 11, 2008
    Last edited: Jan 20, 2010
  7. natong

    natong Well-Known Member

    Joined:
    May 17, 2008
    Messages:
    85
    Likes Received:
    0
    Trophy Points:
    6
    To show server stat (all VirtualHost stats), add these directives in your VirtualHost Includes file:


    To show only one VirtualHost stat, add these directives in your VirtualHost Includes file:

     
    #7 natong, Jun 11, 2008
    Last edited: Jun 12, 2008
  8. natong

    natong Well-Known Member

    Joined:
    May 17, 2008
    Messages:
    85
    Likes Received:
    0
    Trophy Points:
    6
    My examples:

    /usr/local/apache/conf/includes/pre_main_global.conf

    Code:
    <IfModule mod_cband.c>
       CBandScoreFlushPeriod 300
    </IfModule>

    /usr/local/apache/conf/userdata/cband.conf

    Code:
    <IfModule mod_cband.c>
       CBandPeriod 4W
    </IfModule>

    /usr/local/apache/conf/userdata/std/2/tid/cband.tid.conf

    Code:
    <IfModule mod_cband.c>
    <Location /cband-status>
    SetHandler cband-status
    </Location>
    
    CBandSpeed 2560kbps 300 300
    CBandRemoteSpeed 512kbps 20 20
    
    CBandClassRemoteSpeed ban 100kbps 20 20
    
    CBandScoreboard /var/run/cband/tid
    </IfModule> 

    Access server stats page by http://www.domain.com/cband-status
     
    #8 natong, Jun 12, 2008
    Last edited: Jan 20, 2010
  9. toozie

    toozie Registered

    Joined:
    Jun 14, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Thanks

    Thanks for this post i help me :)

    To other users if you dont have the folder

    /usr/local/apache/conf/userdata/
    /usr/local/apache/conf/userdata/std
    /usr/local/apache/conf/userdata/std/2

    then just greate it
     
  10. natong

    natong Well-Known Member

    Joined:
    May 17, 2008
    Messages:
    85
    Likes Received:
    0
    Trophy Points:
    6
    Add some examples:

    /usr/local/apache/conf/includes/pre_main_2.conf
    Code:
    LoadModule cband_module modules/mod_cband.so
    
    <IfModule mod_cband.c>
       CBandScoreFlushPeriod 300
       <CBandClass ban>
          CBandClassDst 65.208.151
          CBandClassDst 65.208.152/24
       </CBandClass>
    </IfModule>
    

    /usr/local/apache/conf/userdata/std/2/cband.conf
    Code:
    <IfModule mod_cband.c>
       CBandPeriod 4W
    </IfModule
    

    /usr/local/apache/conf/userdata/std/2/tid/Sub.DoMain.Com/cband.tid.conf
    Code:
    <IfModule mod_cband.c>
       <Location /cband-status> 
          SetHandler cband-status
       </Location> 
       CBandSpeed 3mbps 300 300
       CBandRemoteSpeed 1mbps 20 20
       CBandClassRemoteSpeed ban 1mbps 20 20
    </IfModule>
    
    Access server stats page by http://sub.domain.com/cband-status
     
    #10 natong, Jul 18, 2009
    Last edited: Jul 18, 2009
  11. jols

    jols Well-Known Member

    Joined:
    Mar 13, 2004
    Messages:
    1,111
    Likes Received:
    2
    Trophy Points:
    38
    Just need a bit of help with this, please.

    I have this version installed:
    mod-cband-0.9.7.5

    In:
    /usr/local/apache/conf/includes/pre_main_2.conf

    ...I have this:

    <IfModule mod_cband.c>
    CBandScoreFlushPeriod 300
    <CBandClass googlebot_class>
    CBandClassDst 66.249.65/24
    CBandClassDst 66.249.67/24
    CBandClassDst 66.249.68/24
    </CBandClass>
    </IfModule>


    In:
    /usr/local/apache/conf/userdata/std/2/user-id/domain-name/cband.user-id.conf

    ...I have this:

    <IfModule mod_cband.c>
    CBandPeriod 8M
    CBandRandomPulse On
    CBandSpeed 3Mbps 300 300
    CBandRemoteSpeed 10Mbps 30 30
    CBandExceededSpeed 1028kbs 5 15
    CBandClassRemoteSpeed googlebot_class 20kb/s 2 3
    </IfModule>


    YET, everytime I do this:
    /scripts/ensure_vhost_includes --user=user-id

    ... then this:

    /etc/rc.d/init.d/httpd stop
    killall httpd
    /etc/rc.d/init.d/httpd startssl


    ... I get this error:

    Invalid command 'CBandClassRemoteSpeed', undefined class name


    I've been at this for nearly 8 hours, and I can't not see where I am going wrong. Anyone? Thanks in advance!!!
     
    #11 jols, Sep 21, 2009
    Last edited: Sep 21, 2009
  12. jols

    jols Well-Known Member

    Joined:
    Mar 13, 2004
    Messages:
    1,111
    Likes Received:
    2
    Trophy Points:
    38
    Nevermind, I get it.

    You only need to make sure that the module is loaded FIRST. In otherwords that this:
    LoadModule cband_module modules/mod_cband.so

    Comes before this:
    Include "/usr/local/apache/conf/includes/pre_main_2.conf"

    ... in the httpd.conf file. Sheesh (slapps head).
     
  13. jols

    jols Well-Known Member

    Joined:
    Mar 13, 2004
    Messages:
    1,111
    Likes Received:
    2
    Trophy Points:
    38
    NEW QUESTION:

    How could I do this:
    CBandClassRemoteSpeed googlebot_class 20kb/s 2 3

    ... for every vsite/account on the server? (Of course without having to manually implement this for each and every account.)
     
  14. natong

    natong Well-Known Member

    Joined:
    May 17, 2008
    Messages:
    85
    Likes Received:
    0
    Trophy Points:
    6
    Put you code at

    /usr/local/apache/conf/userdata/std/2/googlebot.conf

    To update include files for all users:

    /scripts/ensure_vhost_includes --all-users
     
  15. jols

    jols Well-Known Member

    Joined:
    Mar 13, 2004
    Messages:
    1,111
    Likes Received:
    2
    Trophy Points:
    38
    Thanks!

    What about inserting the code in the following location?

    /usr/local/apache/conf/includes/post_virtualhost_global.conf

    Will that have any effect?
     
  16. natong

    natong Well-Known Member

    Joined:
    May 17, 2008
    Messages:
    85
    Likes Received:
    0
    Trophy Points:
    6
    Post VirtualHost Include will add content to the file httpd.conf right after the last VirtualHost entry. Not add to every VirtualHost section.

    Something like last line of the file httpd.conf
     
Loading...

Share This Page