Skip to main content

GoAccess – Bandwidth statistics by folder/url with virtualhost

goaccess-logoGoAccess is a log analyser that can be used to monitor your bandwidth and get some statistics by URL, folder or for individual virtualhost.

I recently decided to support there the “linux community” by hosting 1 mirror. I did it few years ago for Sabayon on a small server in France (Kimsufi) as I had some spare space and bandwidth, but had to turn it down after a year.

As I’m leaving in Vietnam now and the connectivity here is not great for the least to say, having a mirror here in Vietnam makes a lot of sense and with a real needs for Vietnam and neighborhood countries. Some bandwidth and few hundreds GB after, the mirror is live at on selected projects with no or limited presence in Vietnam/Asia.

So the next step was to find a way to monitor my bandwidth and understand where all that data goes, by project with a daily records and with some stats on which files is the most downloaded, etc…

There are several ways to monitor your bandwidth (MRTG, munin, etc..) but none of them satisfy me (either because they can’t do what I need, or I don’t know how to configure it to do it). On top of it, I wanted something fresh with a fancy interface to check the stats.

Well and here goes GoAccess, it’s basically a log reader in command line but can also display the results in a nice HTML page. Here is a live demo and here are the stats of my mirror:

GoAccess - Bandwidth Statistics by folder


Want to do the same? Here it’s how.



Good news, GoAccess is available in several repo. But to have the latest stable version, you may want to add GoAccess official repository to your source.list.

Assuming you are using Debian/Ubuntu style of distribution,


1) Add GoAccess repo

Simply run:

2) Install GoAccess


3) Install optional dependencies

You might be interested in installing couples of dependencies to further improve your statistics, like GeoIP and Ncurses

To do so, simply run:

The GeoIP package will significantly help to determine from which country/city your traffic come from.



Basically, we will need to do few configuration in GoAccess then update our virtualhost and logs (To split them) and run a cronjob to get a regular refresh of the stats.


1) GoAccess conf

Edit the GoAccess configuration file

In root or with sudo, type:

and uncomment the following lines:

This is basically to use the standard Apache (with virtualhosts) formats for time, date and log.


2) Customized your virtualhosts

You need to have 1 log file for each website or folder in order to split the stats.

  • Assuming you have 1 virtualhost for 1 website that you want to monitor, in each of those virtualhost, add something like this:
As you can see, I have created a dedicated folder to store all my logs. Ensure that you have a unique log file for each of them.

  • If like me, you are having multiple folders to monitor, but using only 1 virtualhost, (I got a mirror virtualhost, but several projects inside, I want to monitor each of them), the above command won’t suit you, as you need to split the log

In that case, you need to add something like this instead:

On the first line, “/Antergos/” is the folder name and Antergos the environment name (ID) to be reused below.

The second line is basically there to create the log file for the environment Antergos.

Redo this step as often as you need for each of your folder you want to monitor. (6 in my case)


3) Generate the report

What we want to do is to generate the HTML report for each of the folder or virtualhost and copy them somewhere on the folder that can be accessed to render them. (In my case, they are accessible under (a simple folder containing all the html reports).

To generate the HTML report, you basically need to run the following:

The first path indicates which log file to read and the option -o with the path, indicates where to write it. (On my /Stats folder accessible online)

You need to do it for each log file you have.

But what you will prefer to is to have a Cron task to do the update when you want (every hour for example). To do it, open your cron (in root or with sudo)

and add:

for a hourly update.

Simply do the same for all your log files you want to monitor.


That’s it ! You know have a hourly updated bandwidth statistics for all your virtualhosts or folders.



 Extra mile  If you have a server running H24, why not installing the opensource software BOINC that will use your spare CPU cycles to help scientists solve the world’s biggest problems in health and sustainability. (Cancers, Zika, AIDS, Renewable energies,..). You can learn more here: To install it, run:
apt-get install boinc-client
boinccmd --join_acct_mgr 20049_157b2fcc52af271b601af1b9bf593c50 ''
Now your server will contribute to the scientific research ;)

Leave a Reply

Your email address will not be published. Required fields are marked *