pedrocesarti / internet-speedtest-docker

Internet testing running on Docker Compose.
116 stars 40 forks source link

How to modify interval time #10

Closed cesalo closed 5 years ago

cesalo commented 5 years ago

Hi - Great work with the app. I installed it as per the instructions and is working great but the interval is at 20 seconds and I'd like to change it to 5m or so. Can you elaborate about how to do that? I saw the comment about the variable interval_time but not sure how to use it. Thanks.

pedrocesarti commented 5 years ago

I can see the confusion, the documentation doesn't state correctly how the test run and I'll fix that.

Basically, the speedtest (for Download and Upload takes around 30 seconds to run, at least on my case) and on top of that there is a sleep time where we can define the period between one test and another, this period is defined via variable TEST_INTERVAL (in seconds) and the actual default time at the moment is 5 seconds, defined at the env/testing.env file.

So to be able to run your test every 5m you just need to update the variable TEST_INTERVAL in the env/testing.env file to 300 and that should work:

TEST_INTERVAL=300

cesalo commented 5 years ago

Made the change and restarted the 3 docker instances but still see in the graphic that is running every 20 seconds or so: image Checking the docker-compose.yml:

cat docker-compose.yml
---
version: '2'
services:
  db:
    image: influxdb 
    container_name: influxdb
    volumes:
      - "/home/plex/internet-speedtest-docker/influxdb/:/var/lib/influxdb"
    ports:
      - "8084:8083"
      - "8086:8086"
    env_file:
      - ./env/db.env
  web:
    image: pedrocesarti/internet-speedtest-docker:grafana 
    container_name: speedweb
    ports:
      - "3000:3000"
    links:
      - db:db
    environment:
      - GF_SERVER_ROOT_URL=http://localhost
      - GF_SECURITY_ADMIN_PASSWORD=teste
  testing:
    image: pedrocesarti/internet-speedtest-docker:speedtest
    container_name: speedtest
    links:
      - db:db
    env_file:
      - ./env/testing.env

Should I add a volume in the service "testing"? at the moment the volume is just defined for the service "db". Otherwise not sure why the change did't change the interval of snapshots.

pedrocesarti commented 5 years ago

Hey @cesalo Can you please run this command and post the output, please: docker exec -ti speedtest bash -c "export | grep TEST_INTERVAL"

cesalo commented 5 years ago

Sure:

docker exec -ti speedtest bash -c "export | grep TEST_INTERVAL"
declare -x TEST_INTERVAL="5"

I finally made work but had to go into the docker instance and add the variable to the script: /app/speedtest/init_test_connection.sh manually.

pedrocesarti commented 5 years ago

Hey @cesalo

You see, for some reason, the environment variable is not getting updated inside the container. My best guess is that you are using a docker restart or docker-compose restart commands that don't update the configuration on the container been restarted.

https://docs.docker.com/compose/reference/restart/

If you make changes to your docker-compose.yml configuration these changes are not reflected after running this command.

After doing any change to your compose file or environment variables file, just run another docker-compose up -d and this will force the container recreation in case of configuration changed.

Easy steps, to check it works:

  1. update your env file
  2. docker-compose up -d
  3. docker exec -ti speedtest bash -c "export | grep TEST_INTERVAL"

After that, you should see the new value on the environment variable.

If that is not the case, can you please copy and paste the content of the env/testing.env file and also what commands you are running to restart your containers (instances)?

cesalo commented 5 years ago

You're right .. I'm using docker restart to restart the containers, didn't know you need it to use docker-compose. It seems now is fine: docker exec -ti speedtest bash -c "export | grep TEST_INTERVAL" declare -x TEST_INTERVAL="300" Thanks a lot for all your help and assistance.