-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspeedtest.sh
17 lines (13 loc) · 1.14 KB
/
speedtest.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#! /bin/bash
###################################################################
#Script Name : speedtest.sh
#Description : Calls the speedtest cli and writes the ping, download and upload to a local InfluxDB-database
#Author : Eric Klatzer
#Email : [email protected]
###################################################################
source <(sed $'s/\r$//' .env)
result=$(/usr/bin/speedtest --accept-license --accept-gdpr --format=json)
ping=$(/usr/bin/jq '.ping.latency' <<< "${result}")
download=$(/usr/bin/jq '.download.bandwidth' <<< "${result}")
upload=$(/usr/bin/jq '.upload.bandwidth' <<< "${result}")
/usr/bin/curl -i -XPOST "http://localhost:8086/write?db=speedtest&u=${INFLUXDB_PASSWORD}&p=${INFLUXDB_PASSWORD}" --data-binary "results ping=${ping},download=${download},upload=${upload}"