MiDgArD has asked for the wisdom of the Perl Monks concerning the following question:

How I can create a apache (1.3.x) module to get the bandiwidht of my vhosts?

I would like to limit the bandiwidth for all vhost, but this limit is porsonalized, for example:

site1.com -> 1gb
site2.net -> 500MB

How i can create this module? (with mysql to log all traffic per day by month, and if the site crash your limit, he show the error msg "Bandwidth limit exceeded")

Or do you know another solution?

Tthank you

Replies are listed 'Best First'.
Re: bandwidth Apache Module
by stonecolddevin (Parson) on Feb 19, 2007 at 20:31 UTC

    Haven't dealt with this personally, but check out Apache::Quota. Needs mod_perl and apache 1.3.x

    HTH!

    meh.
      How I can install it in the httpd.conf?

      I've tried this:


      PerlLoadModule Apache::Quota
      PerlSetVar QuotaFile /tmp/Apache-Quota.db
      PerlSetVar QuotaLocker BerkeleyDB

      <VirtualHost X.Y.Z.W>
      ServerAlias site.com
      ...
      <Location />
      PerlSetVar QuotaLocationKey /
      PerlSetVar QuotaType global
      PerlSetVar QuotaPeriod 30d
      PerlSetVar QuotaLimit 1M
      PerlSetVar QuotaOnExceed deny
      PerlFixupHandler Apache::Quota
      </Location>
      ...
      </VirtualHost>


      But this don't start my apache ...
        Are you running mod_perl? If not, you either need to install mod_perl or look at something in C, like mod_bandwidth. In my opinion, monitoring bandwidth is better done with one of the C modules because they'll be more lightweight.
        Have you tried apache/bin/apachectl configtest? (At least I think it's in apache/bin.)

        Cheers,

        Brent

        -- Yeah, I'm a Delt.