Skip to content

Commit

Permalink
Merge pull request #1 from Uzurka/master
Browse files Browse the repository at this point in the history
Changed : Updated to /opt instead of /jffs, using newer panels in the…
  • Loading branch information
ch604 authored Jun 20, 2024
2 parents b60b6f6 + 819bff2 commit 2c34010
Show file tree
Hide file tree
Showing 16 changed files with 1,598 additions and 1,239 deletions.
38 changes: 30 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# tomato-grafana

Scripts to display metrics from routers running FreshTomato. Developed on Netgear R7000.
Scripts to display metrics from routers running FreshTomato. Developed on Netgear R7000, updated with a Netgear R8000.

![Dashboard Preview](https://i.imgur.com/fR4c8LC.png)

Based on dd-wrt-grafana by Trevor Dodds (https://grafana.com/grafana/dashboards/950), updated for influxdb and freshtomato.

# Requirements

- Router running FreshTomato (tested on 2021.2)
- Router running FreshTomato (tested on 2021.2 & 2024.1)
- Server running Grafana
- Server running InfluxDB
- Server running InfluxDB (=< 1.8)

# Installation

Expand All @@ -20,24 +20,46 @@ Set up a blank InfluxDB database for storage (after installing influxdb-client,

Connect Grafana to InfluxDB as a data source using the same username and password you set up for influx auth.

On to the router. Enable JFFS support on Tomato under Administration -> JFFS.
On to the router. Connect and mount a disk to /opt (USB Drive, SD Card, external HDD/SSD. If you already installed Entware, skip this step).

Upload all shell scripts to /jffs/tomato-grafana/. Modify the IP, port, password, and username of your influxdb server in variables.sh. Also add any additional mount points you may want to monitor in this file as well, space-delimited. Scripts do not have to be executable.
If you want to use JFFS instead, Enable JFFS support on Tomato under Administration -> JFFS

For speedtest results, download the Ookla ARM CLI tool from https://install.speedtest.net/app/cli/ookla-speedtest-1.0.0-arm-linux.tgz and place its contents into a folder called /jffs/speedtest/. The core speedtest binary should be executable.
## /opt
Upload all shell scripts to /opt/tomato-grafana/.

## /jffs
Upload all shell scripts to /jffs/tomato-grafana/.
Before, or after uploading the scripts, run the following command in the scripts folder to replace /opt with /jffs
`find . -type f -exec sed -i 's#/jffs/#/opt/#g' {} +`


Modify the IP, port, password, and username of your influxdb server in variables.sh. Also add any additional mount points you may want to monitor in this file as well, space-delimited. Scripts do not have to be executable.

For speedtest results, download the Ookla ARM CLI tool from https://install.speedtest.net/app/cli/ookla-speedtest-1.2.0-linux-armel.tgz and place its contents into a folder called /opt/speedtest/. The core speedtest binary should be executable.

Add the following three commands under Administration -> Scheduler as custom cron jobs:
```
sh /opt/tomato-grafana/collector.sh >/dev/null 2>&1
sh /opt/tomato-grafana/collector20.sh >/dev/null 2>&1
sh /opt/tomato-grafana/collector40.sh >/dev/null 2>&1
```
or, for jffs :
```
sh /jffs/tomato-grafana/collector.sh >/dev/null 2>&1
sh /jffs/tomato-grafana/collector20.sh >/dev/null 2>&1
sh /jffs/tomato-grafana/collector40.sh >/dev/null 2>&1
```
These should all run every 1 minute on every day of the week. The collectors will now run every 20 seconds. Additionally, add this cron for the speedtest:
```
sh /jffs/tomato-grafana/speedTest.sh >/dev/null 2>&1
sh /opt/tomato-grafana/speedTest.sh >/dev/null 2>&1
```
or, for jffs :
```
sh /opt/tomato-grafana/speedTest.sh >/dev/null 2>&1
```

Run this every 30 minutes, or as often as you would like results recorded.

Import the Grafana dashboard via json file or from this dashboard code: https://grafana.com/grafana/dashboards/14237
Import the Grafana dashboard via json file or from this dashboard code: https://grafana.com/grafana/dashboards/21104

Enjoy!
2 changes: 1 addition & 1 deletion checkBandwidthInterface.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

source /jffs/tomato-grafana/variables.sh
source /opt/tomato-grafana/variables.sh

for i in `\ls -A /sys/class/net/`; do
rx=0
Expand Down
2 changes: 1 addition & 1 deletion checkCPU.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

source /jffs/tomato-grafana/variables.sh
source /opt/tomato-grafana/variables.sh

cpu=`cat /proc/stat | head -n1 | sed 's/cpu //'`
user=`echo $cpu | awk '{print $1}'`
Expand Down
2 changes: 1 addition & 1 deletion checkCPUTemp.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

source /jffs/tomato-grafana/variables.sh
source /opt/tomato-grafana/variables.sh

cpuTemp=`cat /proc/dmu/temperature | grep -o '[0-9]\+'`

Expand Down
2 changes: 1 addition & 1 deletion checkClients.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

source /jffs/tomato-grafana/variables.sh
source /opt/tomato-grafana/variables.sh

clients=`arp -an | grep -v vlan2 | wc -l`

Expand Down
2 changes: 1 addition & 1 deletion checkConnections.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

source /jffs/tomato-grafana/variables.sh
source /opt/tomato-grafana/variables.sh

connections=`cat /proc/net/nf_conntrack`
tcp=`echo "$connections" | grep ipv4 | grep tcp | wc -l`
Expand Down
2 changes: 1 addition & 1 deletion checkDisk.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

source /jffs/tomato-grafana/variables.sh
source /opt/tomato-grafana/variables.sh

for i in $disks; do
used=0
Expand Down
2 changes: 1 addition & 1 deletion checkLoad.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

source /jffs/tomato-grafana/variables.sh
source /opt/tomato-grafana/variables.sh

load=`cat /proc/loadavg`
load1=`echo "$load" | awk '{print $1}'`
Expand Down
2 changes: 1 addition & 1 deletion checkMem.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

source /jffs/tomato-grafana/variables.sh
source /opt/tomato-grafana/variables.sh

mem=`cat /proc/meminfo`
total=`echo "$mem" | grep ^MemTotal | awk '{print $2}'`
Expand Down
18 changes: 9 additions & 9 deletions collector.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/sh
sh /jffs/tomato-grafana/checkDisk.sh &
sh /jffs/tomato-grafana/checkBandwidthInterface.sh &
sh /jffs/tomato-grafana/checkConnections.sh &
sh /jffs/tomato-grafana/pingGoogle.sh &
sh /jffs/tomato-grafana/checkLoad.sh &
sh /jffs/tomato-grafana/checkCPUTemp.sh &
sh /jffs/tomato-grafana/checkMem.sh &
sh /jffs/tomato-grafana/checkCPU.sh &
sh /jffs/tomato-grafana/checkClients.sh &
sh /opt/tomato-grafana/checkDisk.sh &
sh /opt/tomato-grafana/checkBandwidthInterface.sh &
sh /opt/tomato-grafana/checkConnections.sh &
sh /opt/tomato-grafana/pingGoogle.sh &
sh /opt/tomato-grafana/checkLoad.sh &
sh /opt/tomato-grafana/checkCPUTemp.sh &
sh /opt/tomato-grafana/checkMem.sh &
sh /opt/tomato-grafana/checkCPU.sh &
sh /opt/tomato-grafana/checkClients.sh &
2 changes: 1 addition & 1 deletion collector20.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh
sleep 20
/jffs/tomato-grafana/collector.sh
/opt/tomato-grafana/collector.sh
2 changes: 1 addition & 1 deletion collector40.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh
sleep 40
/jffs/tomato-grafana/collector.sh
/opt/tomato-grafana/collector.sh
2 changes: 1 addition & 1 deletion pingGoogle.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

source /jffs/tomato-grafana/variables.sh
source /opt/tomato-grafana/variables.sh

googleping=`ping -c 10 www.google.com | tail -2`
packet=`echo "$googleping" | tr ',' '\n' | grep "packet loss" | grep -o '[0-9]\+'`
Expand Down
6 changes: 3 additions & 3 deletions speedTest.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/sh

source /jffs/tomato-grafana/variables.sh
source /opt/tomato-grafana/variables.sh

[ ! -x /jffs/speedtest/speedtest ] && exit
[ ! -x /opt/speedtest/speedtest ] && exit

result=`/jffs/speedtest/speedtest -f csv`
result=`/opt/speedtest/speedtest -f csv`
down=`echo "$result" | awk -F\" '{print $12}'`
up=`echo "$result" | awk -F\" '{print $14}'`

Expand Down
Loading

0 comments on commit 2c34010

Please sign in to comment.