Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docker container to run ookla speedtest #390

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Applications/Template_App_Speedtest_Wan/7.0/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM docker.io/library/alpine:latest AS build
RUN wget -O speedtest.tgz \
"https://install.speedtest.net/app/cli/ookla-speedtest-1.2.0-linux-x86_64.tgz" \
&& tar zxvf speedtest.tgz \
&& chmod +x speedtest && chown root:root speedtest

FROM docker.io/library/alpine:latest
COPY --from=build /speedtest /bin/
COPY record_speedtest_docker.sh /bin/record_speedtest.sh
RUN apk add --no-cache zabbix-utils
RUN adduser -S speedtest
USER speedtest

ENTRYPOINT ["/bin/record_speedtest.sh"]
7 changes: 7 additions & 0 deletions Applications/Template_App_Speedtest_Wan/7.0/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ Todd Blake

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

# Docker:
Alternatively to collect the speedtest data, a docker container can be run:

```bash
$ docker run --rm -e ZABBIX_SERVER="123.123.123.123" -e SPEEDTEST_HOST="my-speedtest-host" -e SPEEDTESTPARAMS="--accept-license" siegy22/speedtest-cli-zabbix
```

# Example Dashboard
![Example Dashboard](dashboard.png?raw=true "Example Dashboard")

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh
set -e

test -z "$ZABBIX_SERVER" && echo "ZABBIX_SERVER enviornment variable is required." && exit
test -z "$SPEEDTEST_HOST" && echo "SPEEDTEST_HOST enviornment variable is required." && exit

OUTFILE=$(mktemp)
NOW=$(date +%s)

speedtest $SPEEDTESTPARAMS -f json --accept-license > $OUTFILE

F="$(cat $OUTFILE)"

# do we have PSKID and PSKFILE?
if [ -f "$PSKFILE" -a -n "$PSKID" ];then
zabbix_sender --tls-connect psk --tls-psk-identity "$PSKID" --tls-psk-file "$PSKFILE" -z "$ZABBIX_SERVER" -s "$SPEEDTEST_HOST" -k "custom.speedtest[runtime]" -o "$NOW" > /dev/null 2>&1
zabbix_sender --tls-connect psk --tls-psk-identity "$PSKID" --tls-psk-file "$PSKFILE" -z "$ZABBIX_SERVER" -s "$SPEEDTEST_HOST" -k "custom.speedtest[json]" -o "$F" > /dev/null 2>&1
else
zabbix_sender -z "$ZABBIX_SERVER" -s "$SPEEDTEST_HOST" -k "custom.speedtest[runtime]" -o "$NOW"
zabbix_sender -z "$ZABBIX_SERVER" -s "$SPEEDTEST_HOST" -k "custom.speedtest[json]" -o "$F"
fi