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.
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
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
Have a look here: https://github.com/vozlt/nginx-module-vts
However
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
@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.
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
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.
Is it free?
Found one! https://goaccess.io/ go check it out!
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/
You can restart nginx with zero downtime http://nginx.org/en/docs/control.html
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.
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