question about traffic statistics on each vhost,is it po

Maxim Dounin mdounin at mdounin.ru
Thu Oct 2 00:43:49 MSD 2008


Hello!

On Wed, Oct 01, 2008 at 12:06:11PM -0700, mike wrote:

>On Wed, Oct 1, 2008 at 9:43 AM, Maxim Dounin <mdounin at mdounin.ru> wrote:
>> Hello!
>> Why not just log needed numbers ($bytes_sent) to access_log and post-process
>> it with anything you want?
>
>I might be forced to do this right now. That means millions of lines
>per day on 3 servers to combine, merge and calculate...
>
>I'm sure it would be simple for someone to write a module that dumps
>out Host: header stats to a file every so often (one per day) ...
>*fingers crossed*

It's not simple "dump out Host: header", it's shared memory, 
locking mutex for each request, loosing stats on binary upgrade, 
etc, etc.

I see no reason why this can't be done from access_logs by simple 
perl script - either running side-by-side with nginx but perfectly 
restarable whenever you want, or periodically run at low-load 
periods.

We used to run similar script for calculation of average 
$upstream_response_time for monitoring purposes and as far as I 
recall it took less than 1% cpu on not-really-fast machine with 
more than 10 mln log lines per day.

Maxim Dounin





More information about the nginx mailing list