Bläddra i källkod

Add the 'debug' option on the entrypoint script

By giving the 'debug' argument to the entrypoint you
can list what value you will send to the influxdb database

Signed-off-by: Jeremy MAURO <jeremy.mauro@gmail.com>
Jeremy MAURO 4 år sedan
förälder
incheckning
9996cccfbf
1 ändrade filer med 14 tillägg och 8 borttagningar
  1. 14 8
      scripts/docker-entrypoint.sh

+ 14 - 8
scripts/docker-entrypoint.sh

@@ -18,12 +18,18 @@ download_bandwidth=$(echo "${json_result}" | jq -r '.download.bandwidth')
 upload_bandwidth=$(echo "${json_result}" | jq -r '.upload.bandwidth')
 packet_loss=$(echo "${json_result}" | jq -r '.packetLoss')
 
-# Ensure InfluxDB database exists
-curl \
-    -d "q=CREATE DATABASE ${influxdb_db}" \
-    "${influxdb_url}/query"
-
 # Write metric to InfluxDB
-curl \
-    -d "speedtest,result_id=${result_id} ping_latency=${ping_latency},download_bandwidth=${download_bandwidth},upload_bandwidth=${upload_bandwidth},packet_loss=${packet_loss}" \
-    "${influxdb_url}/write?db=${influxdb_db}"
+INFLUXDB_APPEND="speedtest,result_id=${result_id} ping_latency=${ping_latency},download_bandwidth=${download_bandwidth},upload_bandwidth=${upload_bandwidth},packet_loss=${packet_loss}"
+
+if [ "$1" == "debug" ]; then
+	echo "[DEBUG] INFLUXDB: ${INFLUXDB_APPEND}"
+else
+	# Ensure InfluxDB database exists
+	curl \
+	    -d "q=CREATE DATABASE ${influxdb_db}" \
+	    "${influxdb_url}/query"
+
+	curl \
+	    -d "${INFLUXDB_APPEND}" \
+	    "${influxdb_url}/write?db=${influxdb_db}"
+fi