diff --git a/docker-compose.yml b/docker-compose.yml index 6c0679e..5eea191 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -53,12 +53,28 @@ services: build: context: nextcloud - gotify: - image: local/gotify - build: - context: gotify +# gotify: +# image: local/gotify +# build: +# context: gotify dst: image: local/dst build: - context: dst \ No newline at end of file + context: dst + + metry: + image: local/metry + build: + context: metry + +# scalliony-allium: +# image: local/scalliony-allium +# build: +# context: scalliony +# dockerfile: Dockerfile.allium +# scalliony-chives: +# image: local/scalliony-chives +# build: +# context: scalliony +# dockerfile: Dockerfile.chives diff --git a/dst b/dst index a9721d6..516d051 160000 --- a/dst +++ b/dst @@ -1 +1 @@ -Subproject commit a9721d695cbf6e9b6884c1ae77e3c2a3bb7b022e +Subproject commit 516d05132eeafbe6dca5ec95fd78f4cfe95b2ccc diff --git a/mariadb/Dockerfile b/mariadb/Dockerfile index 1ca94c8..90f7e28 100644 --- a/mariadb/Dockerfile +++ b/mariadb/Dockerfile @@ -1,4 +1,4 @@ -FROM mariadb +FROM mariadb:10.7 COPY docker-healthcheck /usr/local/bin/ diff --git a/metry/Dockerfile b/metry/Dockerfile new file mode 100644 index 0000000..3e82a5a --- /dev/null +++ b/metry/Dockerfile @@ -0,0 +1,18 @@ +FROM debian:buster-slim + +LABEL maintainer="me@wadza.fr" + +ENV INSTALL_KEY 379CE192D401AB61 +ENV DEB_DISTRO buster + +RUN apt-get update && apt-get install -y curl jq + +RUN apt-get update && apt-get install -y gnupg1 apt-transport-https dirmngr && \ + apt-key adv --keyserver keyserver.ubuntu.com --recv-keys $INSTALL_KEY && \ + echo "deb https://ookla.bintray.com/debian ${DEB_DISTRO} main" | tee /etc/apt/sources.list.d/speedtest.list && \ + apt-get update && \ + apt-get install speedtest + +COPY entrypoint.sh /usr/local/bin +ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] + diff --git a/metry/entrypoint.sh b/metry/entrypoint.sh new file mode 100755 index 0000000..dfb49b0 --- /dev/null +++ b/metry/entrypoint.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash + +# InfluxDB variables +influxdb_proto=${INFLUXDB_PROTO:-http} +influxdb_host=${INFLUXDB_HOST:-influxdb} +influxdb_port=${INFLUXDB_PORT:-8086} +influxdb_db=${INFLUXDB_DB:-metrics} +influxdb_user=${INFLUXDB_USER:-user} +influxdb_pwd=${INFLUXDB_PWD} +interval=${WAIT_INTERVAL} + +influxdb_url="${influxdb_proto}://${influxdb_host}:${influxdb_port}" + +nextcloud_host=${NEXTCLOUD_HOST} +nextcloud_user=${NEXTCLOUD_USER:-user} +nextcloud_pwd=${NEXTCLOUD_PWD} + +nextcloud_st_url="https://${nextcloud_host}/ocs/v2.php/apps/serverinfo/api/v1/info?format=json" +nextcloud_dk_url="https://${nextcloud_host}/ocs/v2.php/apps/serverinfo/api/v1/diskdata?format=json" + +while true +do + # Run speedtest & store result + speed_result=$(speedtest -f json --accept-license --accept-gdpr) + + # Extract data from speedtest result + result_id=$(echo "${speed_result}" | jq -r '.result.id') + ping_latency=$(echo "${speed_result}" | jq -r '.ping.latency') + download_bandwidth=$(echo "${speed_result}" | jq -r '.download.bandwidth') + upload_bandwidth=$(echo "${speed_result}" | jq -r '.upload.bandwidth') + + # Write speed to InfluxDB + curl \ + -H "Authorization: Token ${influxdb_user}:${influxdb_psd}" \ + -d "speedtest,result_id=${result_id} ping_latency=${ping_latency},download_bandwidth=${download_bandwidth},upload_bandwidth=${upload_bandwidth}" \ + "${influxdb_url}/write?db=${influxdb_db}" + + # Run nextcloud status + next_result=$(curl -u ${nextcloud_user}:${nextcloud_pwd} "${nextcloud_st_url}" | sed -e 's/\\/\//g') + db_size=$(echo "${next_result}" | jq -r '.ocs.data.server.database.size') + active_users=$(echo "${next_result}" | jq -r '.ocs.data.activeUsers.last5minutes') + files=$(echo "${next_result}" | jq -r '.ocs.data.nextcloud.storage.num_files') + freespace=$(echo "${next_result}" | jq -r '.ocs.data.nextcloud.system.freespace') + + # Write next to InfluxDB + curl \ + -H "Authorization: Token ${influxdb_user}:${influxdb_psd}" \ + -d "nextcloud db_size=${db_size},active_users=${active_users},files=${files},freespace=${freespace}" \ + "${influxdb_url}/write?db=${influxdb_db}" + + # Run disks usage + disk_result=$(curl -u ${nextcloud_user}:${nextcloud_pwd} -H "OCS-APIREQUEST: true" "${nextcloud_dk_url}") + disk_i=0 + disk_vals="" + for disk in $(echo "${disk_result}" | jq -r '.ocs.data[][]') + do + disk_vals+=$((($disk_i % 2)) && echo "free" || echo "used") + disk_vals+="$(($disk_i / 2))=${disk}," + disk_i=$(($disk_i + 1)) + done + + # Write disks to InfluxDB + curl \ + -H "Authorization: Token ${influxdb_user}:${influxdb_psd}" \ + -d "disks ${disk_vals::-1}" \ + "${influxdb_url}/write?db=${influxdb_db}" + + sleep "${interval}" +done diff --git a/postgres/Dockerfile.alpine b/postgres/Dockerfile.alpine index 6c95188..94b8440 100644 --- a/postgres/Dockerfile.alpine +++ b/postgres/Dockerfile.alpine @@ -1,4 +1,4 @@ -FROM postgres:alpine +FROM postgres:12-alpine RUN apk add --no-cache bash