Speedtest-for-InfluxDB-and-Grafana icon indicating copy to clipboard operation
Speedtest-for-InfluxDB-and-Grafana copied to clipboard

Latest Docker Image fails immediately on start

Open n1nj4888 opened this issue 6 years ago • 26 comments

I just updated the atribe/Speedtest-for-InfluxDB-and-Grafana image to the latest version and the container restarts because of the following errors immediately after starting the container - This didn't happen with the previous container/image so not sure what has changed here in this latest build?

Loading Configuration File config.ini Configuration Successfully Loaded 2019-02-11 01:29:55,627 - DEBUG: Testing connection to InfluxDb using provided credentials

There are no other indicators as to why to container dies and it dies that quickly after starting that I can't seem to get into the container to find out why?

PS: I'm running the docker atribe/Speedtest-for-InfluxDB-and-Grafana:latest on Synology

Thanks!

n1nj4888 avatar Feb 11 '19 07:02 n1nj4888

Same here without container. Script simply finishes after "Configuration Successfully Loaded". No other output, no error.

cyablo avatar Feb 13 '19 20:02 cyablo

I upgraded the image 2 days ago (also on a Synology NAS), and I am encountering exactly the same issue: the container is stuck restarting. Here's a sample from the logs, obtained using Portainer:

Loading Configuration File config.ini
Configuration Successfully Loaded
2019-02-13 22:42:22,980 - DEBUG: Testing connection to InfluxDb using provided credentials
Loading Configuration File config.ini
Configuration Successfully Loaded
2019-02-13 22:42:50,590 - DEBUG: Testing connection to InfluxDb using provided credentials
Loading Configuration File config.ini
Configuration Successfully Loaded
2019-02-13 22:43:44,746 - DEBUG: Testing connection to InfluxDb using provided credentials
Loading Configuration File config.ini
Configuration Successfully Loaded
2019-02-13 22:44:47,671 - DEBUG: Testing connection to InfluxDb using provided credentials

If the speed test is even run at all, the results are certainly not being saved to InfluxDB.

fanaticDavid avatar Feb 15 '19 18:02 fanaticDavid

I don't maintain the Docker image currently. If I have time this weekend I'll setup an officially supported on.

barrycarey avatar Feb 15 '19 19:02 barrycarey

Not sure why this is causing an issue for you two. For what it's worth, I'm running the atribe/speedtest-for-influxdb-and-grafana:latest docker image chart definition here and the config file at runtime looks like this:

/src # cat config.ini
[GENERAL]
Delay = 7200
[INFLUXDB]
Address = influxdb-influxdb
Port = 8086
Database = speedtests
Username =
Password =
Verify_SSL = False
[SPEEDTEST]
Server =
[LOGGING]
Level = debug

sample log output is:

Loading Configuration File config.ini
Configuration Successfully Loaded
2019-02-15 14:06:39,683 - DEBUG: Testing connection to InfluxDb using provided credentials
2019-02-15 14:06:39,816 - DEBUG: Successful connection to InfluxDb
2019-02-15 14:06:39,816 - INFO: Starting Speed Test For Server None
2019-02-15 14:06:39,892 - DEBUG: Setting up SpeedTest.net client
2019-02-15 14:06:40,505 - DEBUG: Picking the closest server
2019-02-15 14:06:41,207 - INFO: Selected Server 1767 in Atlanta, GA
2019-02-15 14:06:41,208 - INFO: Starting download test
2019-02-15 14:06:51,237 - INFO: Starting upload test
2019-02-15 14:07:01,860 - DEBUG: [{'measurement': 'speed_test_results', 'fields': {'download': 269215505.17997843, 'upload': 23655377.193265762, 'ping': 18.512}, 'tags': {'server': '1767'}}]
2019-02-15 14:07:01,886 - DEBUG: Data written to InfluxDB
2019-02-15 14:07:01,887 - INFO: Download: 269.22Mbps - Upload: 23.66Mbps - Latency: 18.512ms
2019-02-15 14:07:01,887 - INFO: Waiting 7200 seconds until next test

billimek avatar Feb 15 '19 21:02 billimek

It's not only the Docker Container. The latest bare Script also does not work on my Debian Stretch Machine:

Loading Configuration File config.ini Configuration Successfully Loaded 2019-02-18 19:34:43,188 - DEBUG: Testing connection to InfluxDb using provided credentials root@cybstretch1:~/Speedtest-for-InfluxDB-and-Grafana#

cyablo avatar Feb 18 '19 18:02 cyablo

@cyablo I just did a pull straight from the Repo on Ubuntu and it worked no issue. Can you post your config? Just leave out username/password stuff.

barrycarey avatar Feb 18 '19 18:02 barrycarey

Ok, pretty sure I know what's going on. If it fails to connect to InfluxDB it was failing silently with a sys.exit(). Looks like each time this happens the container restarts the script so it just loops.

I just updated the repo to output an error if it fails to connect to Influx.

For any of you having this issue, ensure your InfluxDB connection details are correct.

barrycarey avatar Feb 18 '19 18:02 barrycarey

I just pulled that change into the docker image and it is rebuilding right now.

atribe avatar Feb 18 '19 19:02 atribe

You are right:

2019-02-18 19:59:33,803 - CRITICAL: Failed to connect to InfluxDB for unknown reason

But my InfluxDB Credentials are 100% correct. I even did reset the password to be sure and I'm using the same credentials in Grafana. Here is my config:

[GENERAL]

Delay = 300

[INFLUXDB] Address = localhost Port = 8086 Database = speedtests Username = speedtests Password = ****** Verify_SSL = False

[SPEEDTEST]

Leave blank to auto pick server

Server =

[LOGGING]

Valid Options: critical, error, warning, info, debug

Level = debug

cyablo avatar Feb 18 '19 19:02 cyablo

Are you influx with or without SSL?

barrycarey avatar Feb 18 '19 19:02 barrycarey

I'm not using SSL on Influx.

cyablo avatar Feb 18 '19 19:02 cyablo

If you have python on your machine pip install influxdb and then try running this (either save as .py or do it in the Python console):

influx = InfluxDBClient( '111.111.111.111, 8086, database=DATABASE, ssl=False, verify_ssl=False, username=Username, password=Password, timeout=5 )

influx.get_list_users()

Trying to figure out if this is an issue with my script or just a failure connect to Influx in general.

barrycarey avatar Feb 18 '19 19:02 barrycarey

I have a few own Scripts, FHEM & LibreNMS pushing data to Influx without Problems. An older Version of your Script was also working fine.

THERE WAS CRAP HERE

cyablo avatar Feb 18 '19 19:02 cyablo

My bad, forgot to add '' to my database name, username etc...

influxdb.exceptions.InfluxDBClientError: 403: {"error":"error authorizing query: speedtests not authorized to execute statement 'SHOW USERS', requires admin privilege"}

cyablo avatar Feb 18 '19 19:02 cyablo

Do you have restricted permissions on that user?

Currently, to test if the Influx Connection is working I'm sending a show users command. If the command throws and exception the script exists. I didn't do this prior to the major updates I did recently which would explain why it worked before.

I never explored what level of permissions were required for that command. It might require root. You may need to use a user with more permissions until I can explore a better way to verify the Influx credentials.

barrycarey avatar Feb 18 '19 20:02 barrycarey

Sure, the user only has permission to read and write to it's own DB.

I just commented out the lines to test the connection, it's working now and I'll take it as a workaround.

cyablo avatar Feb 18 '19 20:02 cyablo

Glad to hear that worked. Admittedly not an ideal work around. When I have some time I'll see if I can come up with a better way to verify the credentials.

barrycarey avatar Feb 18 '19 22:02 barrycarey

Thanks for looking into this - I can confirm I also use a user which only has read/write to the specific speedtest DB in influxdb so assume this is the cause of the issue. Rather than granting that user admin rights, I’d also like to comment out the access test if possible as a workaround so am keen to understand:

(1) Which files / lines need commenting out? (2) How are you commenting these lines out since I only expose the container’s /src (the config files, no code) at present and cant get into the container quick enough after starting it to make the amendments before the container errors and stops?

Thanks!

n1nj4888 avatar Feb 19 '19 01:02 n1nj4888

It's line 41 in InfluxdbSpeedtest.py that's causing the issue.

The easiest solution would be using a user with root permissions temporary. I'll get it fixed this weekend.

barrycarey avatar Feb 19 '19 01:02 barrycarey

In the Home Assistant project, they recently introduced a similar bug. They fixed it by using the following query: SHOW SERIES LIMIT 1; I'm not sure if that would work in this case, but I just thought I'd share :wink:

fanaticDavid avatar Feb 19 '19 13:02 fanaticDavid

Nice! Thanks for the heads up. I'll mess with it this weekend.

barrycarey avatar Feb 20 '19 02:02 barrycarey

Hi @barrycarey - Were you able to fix the "show users" error stopping the container?

n1nj4888 avatar Mar 12 '19 08:03 n1nj4888

Hi @barrycarey - Do you plan to release a fix for this? The only way i can get the docker to run currently is to manually comment out the "show users" test in the script inside the container...

n1nj4888 avatar Apr 17 '19 08:04 n1nj4888

Hi @barrycarey - Just checking in on whether you're still planning to fix this to save those of us with user permissions in InfluxDB from having to manually edit the line 41 of InfluxdbSpeedtest.py that's causing the issue?

Thanks!

n1nj4888 avatar Aug 08 '19 06:08 n1nj4888

Welp, this is a shame....

My user only has access to the db, and not admin rights, so of course that fails.

douglasg14b avatar May 12 '20 18:05 douglasg14b

So, it is just a one-line change right? Would you will to do it? I will just fork the project and do it myself, but I'm using a helm chart that uses this image, so many levels of indirection...

danielo515 avatar Nov 05 '20 20:11 danielo515