Skip to content

Commit

Permalink
Merge pull request zabbix#108 from tbblake/speedtest
Browse files Browse the repository at this point in the history
Tempate_App_Speedtest_Wan
  • Loading branch information
oscar120584 authored Jul 1, 2022
2 parents d96560c + ef4fd46 commit c75ac96
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Applications/Template_App_Speedtest_Wan/6.0/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Template_App_Speedtest_Wan
To store information from the ookla speedtest cli command into Zabbix.
# Author
Todd Blake
# Requirements:
* Zabbix version 6.0 or later
* the speedtest cli app from speedtest.net - https://www.speedtest.net/apps/cli (NOT the one from pypi)
Expand Down
10 changes: 7 additions & 3 deletions Applications/Template_App_Speedtest_Wan/6.0/record_speedtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,29 @@ SPEEDTESTPARAMS=""
SPEEDTEST="$(which speedtest)"
TIMEOUT="$(which timeout)"
ZABBIX_SENDER="$(which zabbix_sender)"
DATE="$(which date)"
MKTEMP="$(which mktemp)"

# timeout to run speedtest
TIMEOUTTIME=300

test -z "$SPEEDTEST" && echo "speedtest binary not found" && exit
test -z "$TIMEOUT" && echo "timeout binary not found" && exit
test -z "$ZABBIX_SENDER" && echo "zabbix_sender binary not found" && exit
test -z "$DATE" && echo "date binary not found" && exit
test -z "$MKTEMP" && echo "mktemp binary not found" && exit

if [ "$(speedtest -V | egrep -c 'Speedtest by Ookla')" -lt 1 ];then
if [ "$($SPEEDTEST -V | egrep -c 'Speedtest by Ookla')" -lt 1 ];then
echo "The speedtest binary needs to be from Ookla."
echo "Please visit https://www.speedtest.net/apps/cli"
exit
fi

# Temporary speedtest output
OUTFILE=$(mktemp)
OUTFILE=$($MKTEMP)

# what time is it?
NOW=$(date +%s)
NOW=$($DATE +%s)

$TIMEOUT $TIMEOUTTIME $SPEEDTEST $SPEEDTESTPARAMS -f json 2>/dev/null > $OUTFILE
if [ $(stat -c %s $OUTFILE) -le 100 ];then
Expand Down
2 changes: 2 additions & 0 deletions Applications/Template_App_Speedtest_Wan/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# Template_App_Speedtest_Wan
To store speedtest results inside of Zabbix. The latest vesion is for [Zabbix 6.0](6.0)
# Author
Todd Blake

0 comments on commit c75ac96

Please sign in to comment.