Howdy, Stranger!

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


How to track bandwidth per vhost in nginx?
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.

How to track bandwidth per vhost in nginx?

Is it possible to do it?
I tried awstat but I found it complicated that you also had to lunch the script to populate from the access log manually and even merge them. And I wasn't able to access the front end interface!
Does webmin do that maybe?

I'm looking for something very simple and light that tells me how much data has been transferred per virtual host.

Also is there something similar to ngix plus that tells LIVE the connections per second and stuff like that?

Comments

  • PUSHR_VictorPUSHR_Victor Member, Host Rep
    edited September 2017

    Easiest way is to use the $bytes_sent in the log and parse it, that's for the traffic (not bandwidth).
    Number of connections can be observed with the http_stub_status_module. Alternatively, Nginx Amplify can do this and turn it into nice graphs, not sure if it went out of beta and if it is still free.

  • @PUSHRcdn said:
    Easiest way is to use the $bytes_sent in the log and parse it, that's for the traffic (not bandwidth).
    Number of connections can be observed with the http_stub_status_module. Alternatively, Nginx Amplify can do this and turn it into nice graphs, not sure if it went out of beta and if it is still free.

    Isn't the traffic sent = bw?
    Nginx Amplify seems cool but I'm looking for something free "forever"

  • qtwrkqtwrk Member
    edited September 2017

    @sandro said:

    @PUSHRcdn said:
    Easiest way is to use the $bytes_sent in the log and parse it, that's for the traffic (not bandwidth).
    Number of connections can be observed with the http_stub_status_module. Alternatively, Nginx Amplify can do this and turn it into nice graphs, not sure if it went out of beta and if it is still free.

    Isn't the traffic sent = bw?
    Nginx Amplify seems cool but I'm looking for something free "forever"

    There will be some traffic outside of nginx.
    Like mysql, if remote connection is available, so is ftp, smtp, imap and such

    Oops, never mind, misunderstood the OP

  • jetchiragjetchirag Member
    edited September 2017

    Have a look here: https://github.com/vozlt/nginx-module-vts

    However

    Traffic is the cumulative transfer or counter, not a bandwidth

  • @qtwrk said:

    @sandro said:

    @PUSHRcdn said:
    Easiest way is to use the $bytes_sent in the log and parse it, that's for the traffic (not bandwidth).
    Number of connections can be observed with the http_stub_status_module. Alternatively, Nginx Amplify can do this and turn it into nice graphs, not sure if it went out of beta and if it is still free.

    Isn't the traffic sent = bw?
    Nginx Amplify seems cool but I'm looking for something free "forever"

    There will be some traffic outside of nginx.
    Like mysql, if remote connection is available, so is ftp, smtp, imap and such

    Oops, never mind, misunderstood the OP

    I guess those traffics are minimal anyway...

  • I have web sites in production and I can't rebuild nginx :(

  • I'd use an ELK stack and scrape the logs. This should give you ultra accurate stats

  • PUSHR_VictorPUSHR_Victor Member, Host Rep
    edited September 2017

    @sandro Bandwidth is the amount of data transferred over a fixed amount of time, usually measured in bits (or megabits, gigabits, terabits) and the time interval is per second. it measures the speed of a transfer. Traffic is simply the total amount of data transferred - that's the size of the transfer. The free forever part would require a single line in bash which I can't come up with right now but Google should be able to help.

    EDIT: If you can't recompile I am not aware of any way to monitor the active connections.

  • @sandro said:

    I have web sites in production and I can't rebuild nginx :(

    I've haven't tried but you can try something as @PUSHRcdn suggested and create a bash script to display it in nice format and calculation

  • @PUSHRcdn said:
    @sandro Bandwidth is the amount of data transferred over a fixed amount of time, usually measured in bits (or megabits, gigabits, terabits) and the time interval is per second. it measures the speed of a transfer. Traffic is simply the total amount of data transferred - that's the size of the transfer. The free forever part would require a single line in bash which I can't come up with right now but Google should be able to help.

    EDIT: If you can't recompile I am not aware of any way to monitor the active connections.

    oh yeah I just used the wrong term...I meant traffic of course. For now I'm just interested in traffic, active connections is secondary.

  • @DeadCode said:
    I'd use an ELK stack and scrape the logs. This should give you ultra accurate stats

    Is it free?

  • Found one! https://goaccess.io/ go check it out!

    Thanked by 2jetchirag MikePT
  • eva2000eva2000 Veteran
    edited September 2017

    You can script it leveraging ngxtop https://github.com/lebinh/ngxtop to point to each specific vhost log file you want - very handy tool to have https://community.centminmod.com/threads/ngxtop-real-time-metrics-for-nginx.285/

    Or as folks suggested nginx-module-vts is another way to go. In latest Centmin Mod beta, I just added dynamic nginx module support for nginx-module-vts, so technically you could use a separate staging server to build the dynamic module and drop it into your live server's nginx module directory and setup a load_module line to enable it https://community.centminmod.com/posts/54840/

    sandro said: I have web sites in production and I can't rebuild nginx :(

    You can restart nginx with zero downtime http://nginx.org/en/docs/control.html

    Thanked by 1jetchirag
  • Yeah goaccess is quite good. I had a discussion about this with its author a long ago. check this out if you had this problem. You will probably have it if you followed the default instructions.

    https://github.com/allinurl/goaccess/issues/607#issuecomment-270458116

  • Not knowing how to set your path is not a good reason to throw arbitrary software in /usr/bin.

  • sandrosandro Member
    edited September 2017

    @eva2000 said:
    You can script it leveraging ngxtop https://github.com/lebinh/ngxtop to point to each specific vhost log file you want - very handy tool to have https://community.centminmod.com/threads/ngxtop-real-time-metrics-for-nginx.285/

    Or as folks suggested nginx-module-vts is another way to go. In latest Centmin Mod beta, I just added dynamic nginx module support for nginx-module-vts, so technically you could use a separate staging server to build the dynamic module and drop it into your live server's nginx module directory and setup a load_module line to enable it https://community.centminmod.com/posts/54840/

    sandro said: I have web sites in production and I can't rebuild nginx :(

    You can restart nginx with zero downtime http://nginx.org/en/docs/control.html

    don't know why but when I tried ngxtop it didn't read my log file...

    edit: oh wait it's live, yes it works :)

  • yes ngxtop is live stats. If you want to read past stats add --no-follow

Sign In or Register to comment.