Skip to content

Commit

Permalink
Updated README to clarify installation, updated record_speedtest.sh t…
Browse files Browse the repository at this point in the history
…o make adding needed speedtest parameters easier
  • Loading branch information
tbblake committed Jun 26, 2022
1 parent bc1f3f9 commit bbe9ae8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
7 changes: 4 additions & 3 deletions Applications/Template_App_Speedtest_Wan/6.0/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ To store information from the ookla speedtest cli command into Zabbix.
# Installation:
1. Import the Template_App_Speedtest_Wan.yaml template into your Zabbix instance (Configuration --> Templates --> Import), and apply the template to a host
2. Copy the record_speedtest.sh script to somewhere on your system, e.g. /usr/local/bin/record_speedtest.sh
3. Edit the record_speedtest.sh script:
3. Set the script to be executable, e.g. `chmod +x /usr/local/bin/record_speedtest.sh`
4. Edit the record_speedtest.sh script:
- Set the SPDHOST variable to the name of the host you've applied the template too within Zabbix
- Set the ZABSRV variable to the name/IP of your Zabbix server or proxy that the host is reporting too
- Optionally, set the PSKID and PSKFILE variables if you're using encryption in your Zabbix environment.
4. Set the {$NO_SPDTST_DATA_SECS} macro to 300 seconds (5 minutes) more than the frequency of execution, in seconds. i.e. If you run it every 6 hours, set the macro to 21900 (6 hours * 60 minutes per hour * 60 seconds per minute, then add 300 seconds to that.)
5. Install a crontab entry to run this script on a schedule:
5. Set the {$NO_SPDTST_DATA_SECS} macro to 300 seconds (5 minutes) more than the frequency of execution, in seconds. i.e. If you run it every 6 hours, set the macro to 21900 (6 hours * 60 minutes per hour * 60 seconds per minute, then add 300 seconds to that.)
6. Install a crontab entry to run this script on a schedule:

`0 */6 * * * /usr/local/bin/record_speedtest.sh # feed speedtest info into zabbix every 6 hours`

Expand Down
11 changes: 7 additions & 4 deletions Applications/Template_App_Speedtest_Wan/6.0/record_speedtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
PSKID=""
PSKFILE=""

# Zabbix Server
# Zabbix Server hostname or IP address
ZABSRV=x.x.x.x

# Speedtest Host
SPDHOST=x.x.x.x
# Speedtest Host, the name of the host you've applied the template too as it's named in the Zabbix web UI
SPDHOST="name of the host you've applied the template too"

# Optional Speedtest CLI Params
SPEEDTESTPARAMS=""

# program locations
SPEEDTEST="$(which speedtest)"
Expand All @@ -34,7 +37,7 @@ OUTFILE=$(mktemp)
# what time is it?
NOW=$(date +%s)

$TIMEOUT $TIMEOUTTIME $SPEEDTEST -f json 2>/dev/null > $OUTFILE
$TIMEOUT $TIMEOUTTIME $SPEEDTEST $SPEEDTESTPARAMS -f json 2>/dev/null > $OUTFILE
if [ $(stat -c %s $OUTFILE) -le 100 ];then
echo "ERROR running speedtest - output file too small - $OUTFILE"
echo "You may want to try running $SPEEDTEST -f json manually"
Expand Down

0 comments on commit bbe9ae8

Please sign in to comment.