# Ubiquiti Unifi Gateway WAN Statistics

**URL:** <https://discussion.scottibyte.com/t/ubiquiti-unifi-gateway-wan-statistics/398>\
**Category:** Uncategorized\
**Created:** [April 24, 2024, 11:28pm UTC](https://discussion.scottibyte.com/t/ubiquiti-unifi-gateway-wan-statistics/398 "2024-04-24T23:28:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![scott](https://discussion.scottibyte.com/letter_avatar_proxy/v4/letter/s/3e96dc/32.png) [@scott](https://discussion.scottibyte.com/u/scott)\
**Post date:** [April 24, 2024, 11:28pm UTC](https://discussion.scottibyte.com/t/ubiquiti-unifi-gateway-wan-statistics/398/1 "2024-04-24T23:28:54Z")

</div>

This is a nice little application for those of you that run a Ubiquiti Unifi Gateway/router.

Today I discuss UGatewayStats which is a web application to display Unifi Gateway WAN bandwidth statistics pulled from the Unifi Controller with direct API calls.

The Github project site for UGatewayStats is [here](https://github.com/stevesinchak/UGatewayStats).

This is an easy to install application and we are going to install it in an Incus container. If you don’t know what Incus is all about, watch my “Incus Containers Step by Step” tutorial.

Create a container for the project:

```auto
incus launch images:ubuntu/22.04 WAN-Usage --profile default --profile bridgeprofile -c boot.autostart=true

```

Connect to the container shell root account and take the latest updates:

```auto
incus shell WAN-Usage
apt update && apt upgrade -y

```

Create a user account and put it in the sudo group and move over to that account.

```auto
adduser scott
usermod -aG sudo scott
su - scott

```

Install the dependencies into the container:

```auto
sudo apt install apache2 php php-json php-curl git nano openssh-server -y

```

Move over to the folder where the website application code will be stored.

```auto
cd /var/www/html

```

Clone the project from Github:

```auto
sudo git clone https://github.com/stevesinchak/UGatewayStats.git

```

Now move into the folder for the application:

```auto
cd UGatewayStats

```

Edit the configuration file:

```auto
sudo nano config.php

```

The file should appear as follows in the nano editor.

 ![image](https://discussion.scottibyte.com/uploads/default/original/2X/5/504799f93a013d3614579668cc76a04bed1c719d.jpeg)

Change the controller URL to be the address of your controller which will be the address of your gateway or the address of your cloud key if that is where your controller is running. Typically this will look like:

```auto
https://192.168.1.1

```

You will want to sign on to your unifi controller and create a local account with READONLY privilege since that is all that is needed. Specify the username and the password of the Unifi OS account that you created in the config file pictured above.

Then SAVE the file with a CTRL O and enter and then CTRL X to exit the nano editor.

Next move to the Apache web server configuration folder.

```auto
cd /etc/apache2/sites-available

```

Edit the default configuration file:

```auto
sudo nano 000-default.conf

```

In this file, change the document root as follows:

![image](https://discussion.scottibyte.com/uploads/default/original/2X/1/176e9ae8d5f852aad9250218ee1e672d248552e7.png)

Then SAVE the file with a CTRL O and enter and then CTRL X to exit the nano editor.

Reload the Apache Web Server configuration.

```auto
sudo service apache2 reload

```

You may need to enable PHP, but the installation of PHP as described should have done that. So, optionally you may need:

```auto
sudo a2enmod php8.1

```

Find out the address of our container.

```auto
ip -br -4 a

```

You should get an output something like the one below and make a note of the IP address of eth0:

 ![image](https://discussion.scottibyte.com/uploads/default/original/2X/2/2fd3f88527264248eaec70d233414c3ccd6f9e62.png)

Go to your favorite web browser and visit the IP address you just found and you will be at the “Unifi Gateway Stats” application web page.

 ![image](https://discussion.scottibyte.com/uploads/default/original/2X/8/8aa69b8d0e79094dd7c6f9bfbfdc7cd888a8d0e3.jpeg)

Enjoy your new app!
