Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Nginx virtual host bandwidth control?
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Nginx virtual host bandwidth control?

dnwkdnwk Member

Is there a way to calculate and control how many bandwidth a vhost consume?

Comments

  • c0yc0y Member

    yes, a dirty but recommended solution is using the built-in logger and making it log the content sizes, to then parse it and count it up

  • @Frost said:
    yes, a dirty but recommended solution is using the built-in logger and making it log the content sizes, to then parse it and count it up

    yes. Too complicated. Any existing solution? even paid solution using PHP

  • c0yc0y Member

    @dnwk said:
    yes. Too complicated. Any existing solution? even paid solution using PHP

    You can probably pay someone to configure the logging for you and write some kind of daemon

  • dnwkdnwk Member
    edited October 2013

    @Frost said:
    You can probably pay someone to configure the logging for you and write some kind of daemon

    Do you know any existing PHP scripts that will parse a log file?
    I guess maybe I will start with readline

  • c0yc0y Member
    edited October 2013

    @dnwk said:
    I guess maybe I will start with readline

    You can define your own log format: http://wiki.nginx.org/HttpLogModule

    Use something like:
    log_format '$bytes_sent';
    access_log /tmp/nginx-bandmon/example.com;

    Then just explode them by new line in PHP and use a for loop to count them up in one variable and you'll have the amount of OUTGOING bytes (without header size I believe)

    Also, you might want to prune the file right after reading it to prevent 10GB log files :-)

  • By the way, do you know if there is a way to store Log in Mysql?

Sign In or Register to comment.