<commit_before># Bandwidth tracker for OpenWRT

This Luci module uses [wrtbwmon](https://github.com/pyrovski/wrtbwmon) to track bandwidth usage.

##### Features
* **Auto refresh** every 5 seconds (can be changed)
* Track **speed per client** (if auto refresh is enabled)
* **No cron job** required (wrtbwmon is updated on demand)

After installation you will see a new `Usage` menu item inside the `Network` menu list in the Luci GUI.

![Network Usage](https://github.com/Kiougar/luci-wrtbwmon/blob/master/screenshot.png?raw=true)

##### What it does

It displays a table that includes all columns **wrtbwmon** provides, 
with two additional ones (emphasis given):

1. Client
2. **Download speed**
3. **Upload speed**
4. Total downloaded
5. Total uploaded
6. Total usage
7. First seen date
8. Last seen date

##### How it works

The download/upload speed is calculated in memory on the **front end** using JS
thus **minimizing resource consumption** on the router. To properly calculate these values
an auto refresh interval must be set that runs the following commands on the router:

* `wrtbwmon update /tmp/usage.db`
* `wrtbwmon publish /tmp/usage.db /tmp/usage.htm`

For the above commands to work the only *requirement* is that the `wrtbwmon` package is installed and enabled.

## Install

##### Step 1 - install the `wrtbwmon` package (if you have it installed skip to Step 2):

* Download the latest `.ipk` file from [wrtbwmon releases](https://github.com/pyrovski/wrtbwmon/releases)
* Copy the file to your router `/tmp` directory 
    * I use the following command: `scp wrtbwmon_*_all.ipk root@192.168.1.1:/tmp/`
* Install the package `opkg install /tmp/wrtbwmon_*_all.ipk`
        
##### Step 2 - setup* the `wrtbwmon` package:

* If you have `wrtbwmon` version `0.35` the init script uses `wrtbwmon.sh` where it was renamed to `wrtbwmon`
    * to fix: `sed -i 's/wrtbwmon\.sh/wrtbwmon/g' /etc/init.d/wrtbwmon`
* Schedule it to run on startup `/etc/init.d/wrtbwmon enable`
* Manually start it now `/etc/init.d/wrtbwmon start`

**If you have already setup a `cron job` to update the `wrtbwmon` database, it would be best if you removed it*

##### Step 3 - install this module:

* Download the latest `.ipk` file from [releases](https://github.com/Kiougar/luci-wrtbwmon/releases)
* Copy the file to your router `/tmp` directory
    * I use the following command: `scp luci_wrtbwmon_*_all.ipk root@192.168.1.1:/tmp/`
* Install the package `opkg install /tmp/luci_wrtbwmon_*_all.ipk`

## TODO

* Add the `.ipk` package to the `OpenWRT` feed

## Contribute<commit_msg>Adds instruction about clearing luci-cache<commit_after># Bandwidth tracker for OpenWRT

This Luci module uses [wrtbwmon](https://github.com/pyrovski/wrtbwmon) to track bandwidth usage.

##### Features
* **Auto refresh** every 5 seconds (can be changed)
* Track **speed per client** (if auto refresh is enabled)
* **No cron job** required (wrtbwmon is updated on demand)

After installation you will see a new `Usage` menu item inside the `Network` menu list in the Luci GUI.

![Network Usage](https://github.com/Kiougar/luci-wrtbwmon/blob/master/screenshot.png?raw=true)

##### What it does

It displays a table that includes all columns **wrtbwmon** provides, 
with two additional ones (emphasis given):

1. Client
2. **Download speed**
3. **Upload speed**
4. Total downloaded
5. Total uploaded
6. Total usage
7. First seen date
8. Last seen date

##### How it works

The download/upload speed is calculated in memory on the **front end** using JS
thus **minimizing resource consumption** on the router. To properly calculate these values
an auto refresh interval must be set that runs the following commands on the router:

* `wrtbwmon update /tmp/usage.db`
* `wrtbwmon publish /tmp/usage.db /tmp/usage.htm`

For the above commands to work the only *requirement* is that the `wrtbwmon` package is installed and enabled.

## Install

##### Step 1 - install the `wrtbwmon` package (if you have it installed skip to Step 2):

* Download the latest `.ipk` file from [wrtbwmon releases](https://github.com/pyrovski/wrtbwmon/releases)
* Copy the file to your router `/tmp` directory 
    * I use the following command: `scp wrtbwmon_*_all.ipk root@192.168.1.1:/tmp/`
* Install the package `opkg install /tmp/wrtbwmon_*_all.ipk`
        
##### Step 2 - setup* the `wrtbwmon` package:

* If you have `wrtbwmon` version `0.35` the init script uses `wrtbwmon.sh` where it was renamed to `wrtbwmon`
    * to fix: `sed -i 's/wrtbwmon\.sh/wrtbwmon/g' /etc/init.d/wrtbwmon`
* Schedule it to run on startup `/etc/init.d/wrtbwmon enable`
* Manually start it now `/etc/init.d/wrtbwmon start`

**If you have already setup a `cron job` to update the `wrtbwmon` database, it would be best if you removed it*

##### Step 3 - install this module:

* Download the latest `.ipk` file from [releases](https://github.com/Kiougar/luci-wrtbwmon/releases)
* Copy the file to your router `/tmp` directory
    * I use the following command: `scp luci_wrtbwmon_*_all.ipk root@192.168.1.1:/tmp/`
* Install the package `opkg install /tmp/luci_wrtbwmon_*_all.ipk`
* Clear the cache for `luci` to get the web interface to refresh `rm /tmp/luci-indexcache`

## TODO

* Add the `.ipk` package to the `OpenWRT` feed

## Contribute
{'fraction_non_alphanumeric': 0.11446469248291571, 'fraction_numerical': 0.012148823082763858, 'mean_word_length': 4.175834970530452, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5901541', 'n_tokens_mistral': 1791, 'n_tokens_neox': 1704, 'n_words': 673}