alexjustesen / speedtest-tracker

Speedtest Tracker is a self-hosted internet performance tracking application that runs speedtest checks against Ookla's Speedtest service.
https://speedtest-tracker.dev/
MIT License
2.86k stars 108 forks source link

speedtest-tracker can't save data #1622

Closed NicoHag closed 3 months ago

NicoHag commented 3 months ago

speedtest-tracker can't save data. It doesn't matter if I create a new user, change the default, add the InfluxDB (I know InfluxDB is having an issue about the API), or make a speedtest. But everytime speedtest-tracker is restarted, all is "reset".

I've tried collecting all the information I can think of below. I've anonymized the password etc.

I'm using docker compose.

This is my docker compose file: https://hastebin.com/share/ilonuxijuw.yaml

./speedtest-tracker/postgresql/.env contains: https://hastebin.com/share/cewobadube.ini

./speedtest-tracker/config/.env contains: https://hastebin.com/share/konakekucu.ini

./speedtest-tracker/influxdb/.env contains: https://hastebin.com/share/vocixelahu.ini

Log from startup: https://hastebin.com/share/isubotimam.swift

docker logs speedtest-tracker output: https://hastebin.com/share/ulalopopil.yaml

docker logs influxdb output: https://hastebin.com/share/vaborebade.makefile

docker logs speedtest-tracker_database output: https://hastebin.com/share/mujeyoqeli.yaml

The /config/log/laravel.log: https://hastebin.com/share/vubesanisi.css

I'm using Ubunt 22.04 in a VM om Proxmox.

VM info: agent: 1 boot: order=scsi0;net0 cores: 8 cpu: x86-64-v2-AES hotplug: disk,network,usb,memory,cpu memory: 1024 meta: creation-qemu=8.1.5,ctime=1717359686 name: speedtest-01.home.lab net0: virtio=BC:24:11:A8:FD:19,bridge=vmbr1,firewall=1,tag=100 net1: virtio=BC:24:11:9A:CC:63,bridge=vmbr1,firewall=1,tag=70 numa: 1 onboot: 1 ostype: l26 scsi0: local-jbod-zfs:vm-109-disk-0,discard=on,size=2G scsi1: local-jbod-zfs:vm-109-disk-1,size=32G scsihw: virtio-scsi-pci smbios1: uuid=3b32bfa8-abc7-4570-a80a-e31be7a42b1e sockets: 1 tags: ubuntu2204 vcpus: 1 vmgenid: d7250023-2393-48d0-98e5-f5dfb77ab8d8

OS info: PRETTY_NAME="Ubuntu 22.04.4 LTS" NAME="Ubuntu" VERSION_ID="22.04" VERSION="22.04.4 LTS (Jammy Jellyfish)" VERSION_CODENAME=jammy ID=ubuntu ID_LIKE=debian HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" UBUNTU_CODENAME=jammy

Fully updated from today (24th of july 2024)

Browser: Vivaldi 6.8.3381.48 (Stable channel) (64-bit) Revision 79dc6e3dc75f1ca82759568b8aaa16287cbeedb4 OS Windows 11 Version 23H2 (Build 22631.3880) JavaScript V8 12.6.228.28

The docker user: docker:x:1001:999::/home/docker:/bin/sh

I've used ACL to set current and future file permissions for the docker group, and owner for the docker group: chown -R :docker /data/docker setfacl -Rm d:g:docker:rwx /data/docker setfacl -Rm g:docker:rwx /data/docker

Permissions in the folder it's running from: drwxrwxr-x+ 6 911 docker 69 Jul 24 10:27 speedtest-tracker -rw-rwxr--+ 1 root docker 1040 Jul 24 15:02 speedtest-tracker.yml

I asked on the LinuxServer.io Discord server about the problem, and they asked me to try here after we tried a few things. I can't tell if it's a bug, or I am just missing something.

svenvg93 commented 3 months ago

Not it is related but in env your using DB_HOST=database But the containername is speedtest-tracker_database

DB_HOST should be the container name of the postgress container

NicoHag commented 3 months ago

Thanks. Changed it to speedtest-tracker_database now, so the file looks like this: https://hastebin.com/share/vajigowelo.ini

I've brought the containers down and up again, then changed the password of the default account. Again down and up on the containers, and then it was still the default password I had to login with. Tried the same with adding a new user, it was gone after the container reboot. I'm not running out of RAM either: image

I can't figure out what I'm missing.

svenvg93 commented 3 months ago

Can you try with SQLite has database to rule out postgres. pinging @alexjustesen as well as he might have a idea

NicoHag commented 3 months ago

Yes, I'll try it tomorrow, and get back to you with the answer.

NicoHag commented 3 months ago

Sorry, my weekend was busy. I'll get it done as soon as possible.

alexjustesen commented 3 months ago

If you're using mysql/pgsql and you change the password or username you'll need to delete the db's volume as well. Part of the startup script takes the username/password/database name from your environment variables and automatically creates that DB and user/pass.

NicoHag commented 3 months ago

Sorry about the late reply.

I just tried making a test with:

services:
  speedtest-tracker:
    image: lscr.io/linuxserver/speedtest-tracker:latest
    container_name: speedtest-tracker
    environment:
#      - PUID=1000
#      - PGID=1000
#      - TZ=Etc/UTC
#      - APP_KEY=base64:XYZ/k=
      - DB_CONNECTION=sqlite
      - SPEEDTEST_SCHEDULE="0 * * * *"
      - SPEEDTEST_SERVERS=9891
#      - DB_HOST= #optional
#      - DB_PORT= #optional
#      - DB_DATABASE= #optional
#      - DB_USERNAME= #optional
#      - DB_PASSWORD= #optional
#      - DISPLAY_TIMEZONE=Etc/UTC #optional
#      - PRUNE_RESULTS_OLDER_THAN=0 #optional
    volumes:
      - ./data:/config
    ports:
      - 80:80
    restart: unless-stopped

Changing the username and password, bringing it down, and backup. Which worked.

The other setup with PostgreSQL and InfluxDB, I did as Alex wrote, I think. After changing the password or username, I deleted the postgresql folders content. I tried deleting it while it was running but also between the stop and start. But the original username and password persisted. Should I not specify the database name, user and password in the environment variable? I can't figure out what I'm doing wrong here.

alexjustesen commented 3 months ago

You should specify the DB creds in your environment variables, if you're using SQLite the DB username and password wont matter though.

Make sure you always pass your PUID and PGID though as these are critical to making sure the application has the correct permissions, especially writing files/data.

NicoHag commented 3 months ago

So this would work:

services:
  speedtest-tracker:
    image: lscr.io/linuxserver/speedtest-tracker:latest
    container_name: speedtest-tracker
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/Copenhagen
      - APP_KEY=base64:XYZ/k=
      - DB_CONNECTION=sqlite
      - SPEEDTEST_SCHEDULE="0 * * * *"
      - SPEEDTEST_SERVERS=9891

      - DISPLAY_TIMEZONE=Europe/Copenhagen 
      - PRUNE_RESULTS_OLDER_THAN=3650
    volumes:
      - ./data:/config
    ports:
      - 80:80
    restart: unless-stopped

Without problems?

svenvg93 commented 3 months ago

So this would work:

services:
  speedtest-tracker:
    image: lscr.io/linuxserver/speedtest-tracker:latest
    container_name: speedtest-tracker
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/Copenhagen
      - APP_KEY=base64:XYZ/k=
      - DB_CONNECTION=sqlite
      - SPEEDTEST_SCHEDULE="0 * * * *"
      - SPEEDTEST_SERVERS=9891

      - DISPLAY_TIMEZONE=Europe/Copenhagen 
      - PRUNE_RESULTS_OLDER_THAN=3650
    volumes:
      - ./data:/config
    ports:
      - 80:80
    restart: unless-stopped

Without problems?

Looks similair to mine, should be fine :)

NicoHag commented 3 months ago

Do I need the Influx database for it to store the speed test over a period, or would this work?

svenvg93 commented 3 months ago

Do I need the Influx database for it to store the speed test over a period, or would this work?

It should work. Influxdb is only needed is you want to store the data to be shown in other tools like Grafana.

NicoHag commented 3 months ago

Oh, I thought it was needed. This makes it so much easier! I'll test it right away, and get back like tomorrow to tell you the result.

NicoHag commented 3 months ago

I don't know how I complicated it this much. But it's working now.

Thanks a lot guys! :)

svenvg93 commented 3 months ago

Good to hear it now works. You can still use a external db if you want instead of sqlite (just not Influxdb 😉) You can see the install docs to it here; https://docs.speedtest-tracker.dev/getting-started/installation/installation Or just keep it to sqlite like I do, it fine for small installs

If your problem is solved please close the issue :)