diff --git a/README.md b/README.md index f7244ee1..cf3b525d 100644 --- a/README.md +++ b/README.md @@ -24,16 +24,19 @@ We'd be curious to hear about how you use this with your own RPi-powered project - [License](#license) ## Prerequisites -You need to install some extra software in order for the Raspberry Pi to act as a WiFi router and access point. If all you're interested in is configuring your RPi as a client on an existing WiFi network, you can skip this step. +Start with a clean install of the [latest release of Raspbian](https://www.raspberrypi.org/downloads/raspbian/) (currently Stretch). Raspbian Stretch Lite is recommended. -There are many guides available to help you select a WiFi adapter, install a compatible driver, configure HostAPD and so on. The details are outside the scope of this project, although I've had consistently good results with the [**Edimax Wireless 802.11b/g/n nano USB adapter**](http://www.edimax.com/edimax/merchandise/merchandise_detail/data/edimax/global/wireless_adapters_n150/ew-7811un) – it's small, cheap and easy to work with. +1. Update Raspbian, including the kernel and firmware, followed by a reboot: +``` +sudo apt-get update +sudo apt-get dist-upgrade +sudo reboot +``` +2. Set the WiFi country in raspi-config's **Localisation Options**: `sudo raspi-config` -To configure your RPi as a WiFi router, either of these resources will start you on the right track: -* [**How-To: Setting up a Raspberry Pi as an access point in a standalone network (Tested with Raspbian Stretch)**](https://github.com/SurferTim/documentation/blob/6bc583965254fa292a470990c40b145f553f6b34/configuration/wireless/access-point.md) -* [**How-To: Use The Raspberry Pi As A Wireless Access Point/Router Part 1**](http://sirlagz.net/2012/08/09/how-to-use-the-raspberry-pi-as-a-wireless-access-pointrouter-part-1/) -* [**How-To: Turn a Raspberry Pi into a WiFi router**](http://raspberrypihq.com/how-to-turn-a-raspberry-pi-into-a-wifi-router/) (uses isc-dhcp-server instead of dnsmasq) +3. If you have an older Raspberry Pi without an onboard WiFi chipset, the [**Edimax Wireless 802.11b/g/n nano USB adapter**](https://www.edimax.com/edimax/merchandise/merchandise_detail/data/edimax/global/wireless_adapters_n150/ew-7811un) is an excellent option – it's small, cheap and has good driver support. -After you complete the intial setup, you'll be able to administer these services using the web UI. +With the prerequisites done, you can proceed with either the Quick installer or Manual installation steps below. ## Quick installer Install RaspAP from your RaspberryPi's shell prompt: diff --git a/ajax/bandwidth/get_bandwidth.php b/ajax/bandwidth/get_bandwidth.php index ea0c103e..a784b4d7 100644 --- a/ajax/bandwidth/get_bandwidth.php +++ b/ajax/bandwidth/get_bandwidth.php @@ -26,6 +26,8 @@ if (strlen($interface) > IFNAMSIZ) { exit('Invalid interface name.'); } +require_once './get_bandwidth_hourly.php'; + exec(sprintf('vnstat -i %s --json ', escapeshellarg($interface)), $jsonstdoutvnstat, $exitcodedaily); if ($exitcodedaily !== 0) { diff --git a/ajax/bandwidth/get_bandwidth_hourly.php b/ajax/bandwidth/get_bandwidth_hourly.php new file mode 100644 index 00000000..5c8276df --- /dev/null +++ b/ajax/bandwidth/get_bandwidth_hourly.php @@ -0,0 +1,63 @@ + array('date' => '00:00', 'rx' => 0, 'tx' => 0), + 1 => array('date' => '01:00', 'rx' => 0, 'tx' => 0), + 2 => array('date' => '02:00', 'rx' => 0, 'tx' => 0), + 3 => array('date' => '03:00', 'rx' => 0, 'tx' => 0), + 4 => array('date' => '04:00', 'rx' => 0, 'tx' => 0), + 5 => array('date' => '05:00', 'rx' => 0, 'tx' => 0), + 6 => array('date' => '06:00', 'rx' => 0, 'tx' => 0), + 7 => array('date' => '07:00', 'rx' => 0, 'tx' => 0), + 8 => array('date' => '08:00', 'rx' => 0, 'tx' => 0), + 9 => array('date' => '09:00', 'rx' => 0, 'tx' => 0), + 10 => array('date' => '10:00', 'rx' => 0, 'tx' => 0), + 11 => array('date' => '11:00', 'rx' => 0, 'tx' => 0), + 12 => array('date' => '12:00', 'rx' => 0, 'tx' => 0), + 13 => array('date' => '13:00', 'rx' => 0, 'tx' => 0), + 14 => array('date' => '14:00', 'rx' => 0, 'tx' => 0), + 15 => array('date' => '15:00', 'rx' => 0, 'tx' => 0), + 16 => array('date' => '16:00', 'rx' => 0, 'tx' => 0), + 17 => array('date' => '17:00', 'rx' => 0, 'tx' => 0), + 18 => array('date' => '18:00', 'rx' => 0, 'tx' => 0), + 19 => array('date' => '19:00', 'rx' => 0, 'tx' => 0), + 20 => array('date' => '20:00', 'rx' => 0, 'tx' => 0), + 21 => array('date' => '21:00', 'rx' => 0, 'tx' => 0), + 22 => array('date' => '22:00', 'rx' => 0, 'tx' => 0), + 23 => array('date' => '23:00', 'rx' => 0, 'tx' => 0) + ); + + + + + exec(sprintf('vnstat -i %s --json h', escapeshellarg($interface)), $jsonstdoutvnstat, $exitcodedaily); + if ($exitcodedaily !== 0) { + exit('vnstat error'); + } + + $jsonobj = json_decode($jsonstdoutvnstat[0], true)['interfaces'][0]; + $jsonData = $jsonobj['traffic']['hours']; + for ($i = count($jsonData) - 1; $i >= 0; --$i) { + $data_template[$jsonData[$i]['id']]['rx'] = round($jsonData[$i]['rx'] / 1024, 0); + $data_template[$jsonData[$i]['id']]['tx'] = round($jsonData[$i]['tx'] / 1024, 0); + } + + $data = array(); + $hour = $jsonobj['updated']['time']['hour']; + foreach ($data_template as $key => $value) { + if ($key > $hour) { + array_push($data, $value); + } + } + foreach ($data_template as $key => $value) { + if ($key <= $hour) { + array_push($data, $value); + } + } + echo json_encode($data); + exit(0); +} diff --git a/includes/data_usage.php b/includes/data_usage.php index db2e4cb4..6436dc3f 100755 --- a/includes/data_usage.php +++ b/includes/data_usage.php @@ -5,6 +5,7 @@ */ function DisplayDataUsage(&$extraFooterScripts) { +exec("ip -o link show | awk -F ': ' '{print $2}' | grep -v lo ", $interfacesWlo); ?>
@@ -16,27 +17,48 @@ function DisplayDataUsage(&$extraFooterScripts)
-
+
+
+
+

+ + + +
+
+
+
+
+

- +
@@ -53,7 +75,6 @@ foreach ($interfacesWlo as $interface) { echo ' ' , PHP_EOL; } - ?>