charlie-haley / omada_exporter

Prometheus Exporter for TP-Link Omada Controller SDN.
MIT License
94 stars 16 forks source link

unable to login on controller version >=5.0.0 #7

Closed codersaur closed 2 years ago

codersaur commented 2 years ago

Hi,

This is a great project, but I'm running my docker stack, including the omada-controller, on a Raspberry Pi4. Any chance of an image that will support arm64? Or ideally, the image could have multi-arch tags?

The current amd64 image gives the following error: "panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x40 pc=0x2b1578]"

which is usually an arch mismatch issue.

Thanks.

charlie-haley commented 2 years ago

Hey, thanks for raising this issue! The image is currently built for arm64, amd64 and armv7, I'm having no issues running the image on a RPI4 on my end (albeit on kubernetes)

Could you maybe send over some more details on how you're running the container to help me recreate it on my end (docker run, docker-compose etc.)? Thanks!

codersaur commented 2 years ago

ok, weird, I swear dockerhub was only showing amd64 tags yesterday. So the arch is probably not the issue here after all...

I have played around with the environment variables and have managed to get rid of the panic. It seems that if the protocol is omitted from OMADA_HOST or if an IP address is used, or if an incorrect port is used, then it causes the panic and signal SIGSEGV (possibly some better input handling wouldn't go amiss). With better formatting of the environment variables, I now get the following errors repeating in the log:

time="2022-01-27T23:49:17Z" level=info msg="Not logged in, logging in with user: prometheus..." time="2022-01-27T23:49:17Z" level=error msg="Failed to login: %!s()" time="2022-01-27T23:49:17Z" level=error msg="Failed to login: %!s()"

So this would appear to be a completely different issue now.

I'm using the following docker-compose config:

version: "2.4"

services: ... omada-exporter: container_name: omada-exporter image: chhaley/omada_exporter:latest restart: unless-stopped depends_on:

  • "omada-controller"

    ports:

    Port mapping not needed as only used by influxdb/telegraf.

    - "9202:9202"

    env_file:

  • .omada-exporter.env

The .omada-exporter.env file contains:

OMADA_HOST=https://omada-controller:8043 OMADA_USER=prometheus OMADA_PASS=x OMADA_SITE=Default OMADA_EXPORTER_PORT=9202 OMADA_INSECURE=true

Username and password double-checked. I've also checked from other containers that they can gets a response from https://omada-controller:8043/api/v2/loginStatus

I'm running "mbentley/omada-controller:latest" on the same docker network and it's reporting version "5.0.30" in the web GUI.

The logs on the omada controller don't record the failed logins from the omada-exporter container, whereas they do record a manually-generated failed login. So I'm wondering if the omada-exporter login request is not compatible with the latest version of the controller...?

Any ideas?

charlie-haley commented 2 years ago

It looks like there were some breaking changes to the API in 5.0.30, I just upgraded my controller and can replicate the issue you mention. I'll work on adding support for >=5.0.30

codersaur commented 2 years ago

Confirmed resolved, I'm now able to get metrics. Thanks. Although I needed to update the docker image to 'chhaley/omada-exporter' instead of 'chhaley/omada_exporter'.