saphoooo / freebox_exporter

A prometheus exporter for freebox stats
Apache License 2.0
52 stars 26 forks source link

authentication issue with existing token #49

Closed fab-git-f closed 3 years ago

fab-git-f commented 3 years ago

Hi Saphoo and thanks for this cool container.

FIrst, sorry if this is not the right place for this message.

Container was perfectly working on freebox revolution. Since migration to Delta I cannot authenticate anymore :

I've got an error like : cannot open file /volume1/docker/freebox_exporter/.freebox_token

(please note the DOT which is added to the path)

my folder looks like : user@DS918:/volume1/docker/freebox_exporter$ ll total 12 -rwxrwxrwx+ 1 user users 6981 Apr 22 17:42 freeboxos_bash_api.sh -rwxrwxrwx+ 1 user users 65 Jun 8 19:07 freebox_token user@DS918:/volume1/docker/freebox_exporter$

Any help would be greatly appreciated I miss my stats ! Thank you, F

saphoooo commented 3 years ago

Hi fab-git-f,

Thanks for your interest in freebox_exporter :-)

I probably need more logs to figure out why you encounter this issue whit the authentication (try with the debug flag). FreeboxOS is the same for both boxes.

For the freebox token, indeed you hace to name it .freebox_exporter (with the dot) to allow the app to load it. It's the required name. Try too rename you file in your volume (as a good practice you can also change the right to 0400).

fab-git-f commented 3 years ago

Hi Saphoo and thanks for your answer,

I suppose you meant .freebox_token ? anyway I've tried with both and still no luck. I'm attaching logs with the debug flag, commands used and file structure:

freebox-exporter-3.csv freebox-exporter-2.csv freebox-exporter.csv

sudo docker run -d --name freebox-exporter --restart on-failure -p 10001:10001 -e HOME=. -v /volume1/docker/freebox_exporter/.freebox_token:/.freebox_token saphoooo/freebox-exporter -debug -fiber

sudo docker run -d --name freebox-exporter --restart on-failure -p 10001:10001 -e HOME=. -v /volume1/docker/freebox_exporter/.freebox_exporter:/.freebox_exporter saphoooo/freebox-exporter -debug -fiber

fff@DS918:/volume1/docker/freebox_exporter$ ll -a total 24 drwxrwxrwx+ 1 fff users 170 Jun 14 09:12 . drwxrwxrwx+ 1 root root 230 May 24 15:22 .. -r--r--r-- 1 fff users 65 Jun 14 09:12 .freebox_exporter -r--r--r-- 1 fff users 65 Jun 8 19:07 .freebox_token fff@DS918:/volume1/docker/freebox_exporter$

A big thanks for you help, F

I probably need more logs to figure out why you encounter this issue whit the authentication (try with the debug flag). FreeboxOS is the same for both boxes.

For the freebox token, indeed you hace to name it .freebox_exporter (with the dot) to allow the app to load it. It's the required name. Try too rename you file in your volume (as a good practice you can also change the right to 0400).

fab-git-f commented 3 years ago

Last try gives :

sudo docker run -d --name freebox-exporter --restart on-failure -p 10001:10001 -e HOME=. -v /volume1/docker/freebox_exporter/.freebox_token:/.freebox_token saphoooo/freebox-exporter -debug -fiber

and logs :

freebox-exporter date,stream,content 2021-06-14 07:44:10,stderr,2021/06/14 07:44:10 Erreur d'authentification de l'application

2021-06-14 07:44:10,stderr,2021/06/14 07:44:10 An error occured with NET metrics: Erreur d'authentification de l'application

2021-06-14 07:44:10,stderr,2021/06/14 07:44:10 An error occured with freeplug metrics: json: cannot unmarshal object into Go struct field freeplug.result of type []main.freeplugNetwork

2021-06-14 07:44:10,stderr,"2021/06/14 07:44:10 {\"uid\":\"cff6c161162a99cbfcc8008dc025171f\",\"success\":false,\"msg\":\"Vous devez vous connecter pour accéder à cette fonction\",\"result\":{\"password_salt\":\"uevfBH2thIsttJasR1uxWXfylShdosnm\",\"challenge\":\"l\/GD63XvipxgeDMx\/pfsWzoJPPeaAU5c\"},\"error_code\":\"auth_required\"} " 2021-06-14 07:44:10,stderr,2021/06/14 07:44:10 freebox_exporter started on port :10001

2021-06-14 07:44:02,stderr,2021/06/14 07:44:02 Erreur d'authentification de l'application

2021-06-14 07:44:02,stderr,2021/06/14 07:44:02 An error occured with NET metrics: Erreur d'authentification de l'application

2021-06-14 07:44:02,stderr,2021/06/14 07:44:02 An error occured with freeplug metrics: json: cannot unmarshal object into Go struct field freeplug.result of type []main.freeplugNetwork

2021-06-14 07:44:02,stderr,"2021/06/14 07:44:02 {\"uid\":\"cff6c161162a99cbfcc8008dc025171f\",\"success\":false,\"msg\":\"Vous devez vous connecter pour accéder à cette fonction\",\"result\":{\"password_salt\":\"uevfBH2thIsttJasR1uxWXfylShdosnm\",\"challenge\":\"l\/GD63XvipxgeDMx\/pfsWzoJPPeaAU5c\"},\"error_code\":\"auth_required\"} " 2021-06-14 07:44:02,stderr,2021/06/14 07:44:02 freebox_exporter started on port :10001

2021-06-14 07:43:57,stderr,2021/06/14 07:43:57 Erreur d'authentification de l'application

2021-06-14 07:43:57,stderr,2021/06/14 07:43:57 An error occured with NET metrics: Erreur d'authentification de l'application

2021-06-14 07:43:57,stderr,2021/06/14 07:43:57 An error occured with freeplug metrics: json: cannot unmarshal object into Go struct field freeplug.result of type []main.freeplugNetwork

2021-06-14 07:43:57,stderr,"2021/06/14 07:43:57 {\"uid\":\"cff6c161162a99cbfcc8008dc025171f\",\"success\":false,\"msg\":\"Vous devez vous connecter pour accéder à cette fonction\",\"result\":{\"password_salt\":\"uevfBH2thIsttJasR1uxWXfylShdosnm\",\"challenge\":\"l\/GD63XvipxgeDMx\/pfsWzoJPPeaAU5c\"},\"error_code\":\"auth_required\"} " 2021-06-14 07:43:57,stderr,2021/06/14 07:43:57 freebox_exporter started on port :10001

2021-06-14 07:43:54,stderr,2021/06/14 07:43:54 Erreur d'authentification de l'application

2021-06-14 07:43:54,stderr,2021/06/14 07:43:54 An error occured with NET metrics: Erreur d'authentification de l'application

2021-06-14 07:43:54,stderr,2021/06/14 07:43:54 An error occured with freeplug metrics: json: cannot unmarshal object into Go struct field freeplug.result of type []main.freeplugNetwork

2021-06-14 07:43:54,stderr,"2021/06/14 07:43:54 {\"uid\":\"cff6c161162a99cbfcc8008dc025171f\",\"success\":false,\"msg\":\"Vous devez vous connecter pour accéder à cette fonction\",\"result\":{\"password_salt\":\"uevfBH2thIsttJasR1uxWXfylShdosnm\",\"challenge\":\"l\/GD63XvipxgeDMx\/pfsWzoJPPeaAU5c\"},\"error_code\":\"auth_required\"} " 2021-06-14 07:43:54,stderr,2021/06/14 07:43:54 freebox_exporter started on port :10001

2021-06-14 07:43:52,stderr,2021/06/14 07:43:52 Erreur d'authentification de l'application

2021-06-14 07:43:52,stderr,2021/06/14 07:43:52 An error occured with NET metrics: Erreur d'authentification de l'application

2021-06-14 07:43:52,stderr,2021/06/14 07:43:52 An error occured with freeplug metrics: json: cannot unmarshal object into Go struct field freeplug.result of type []main.freeplugNetwork

2021-06-14 07:43:52,stderr,"2021/06/14 07:43:52 {\"uid\":\"cff6c161162a99cbfcc8008dc025171f\",\"success\":false,\"msg\":\"Vous devez vous connecter pour accéder à cette fonction\",\"result\":{\"password_salt\":\"uevfBH2thIsttJasR1uxWXfylShdosnm\",\"challenge\":\"l\/GD63XvipxgeDMx\/pfsWzoJPPeaAU5c\"},\"error_code\":\"auth_required\"} " 2021-06-14 07:43:52,stderr,2021/06/14 07:43:52 freebox_exporter started on port :10001

2021-06-14 07:43:50,stderr,2021/06/14 07:43:50 Erreur d'authentification de l'application

2021-06-14 07:43:50,stderr,2021/06/14 07:43:50 An error occured with NET metrics: Erreur d'authentification de l'application

2021-06-14 07:43:50,stderr,2021/06/14 07:43:50 An error occured with freeplug metrics: json: cannot unmarshal object into Go struct field freeplug.result of type []main.freeplugNetwork

2021-06-14 07:43:50,stderr,"2021/06/14 07:43:50 {\"uid\":\"cff6c161162a99cbfcc8008dc025171f\",\"success\":false,\"msg\":\"Vous devez vous connecter pour accéder à cette fonction\",\"result\":{\"password_salt\":\"uevfBH2thIsttJasR1uxWXfylShdosnm\",\"challenge\":\"l\/GD63XvipxgeDMx\/pfsWzoJPPeaAU5c\"},\"error_code\":\"auth_required\"} " 2021-06-14 07:43:50,stderr,2021/06/14 07:43:50 freebox_exporter started on port :10001

2021-06-14 07:43:48,stderr,2021/06/14 07:43:48 Erreur d'authentification de l'application

2021-06-14 07:43:48,stderr,2021/06/14 07:43:48 An error occured with NET metrics: Erreur d'authentification de l'application

2021-06-14 07:43:48,stderr,2021/06/14 07:43:48 An error occured with freeplug metrics: json: cannot unmarshal object into Go struct field freeplug.result of type []main.freeplugNetwork

2021-06-14 07:43:48,stderr,"2021/06/14 07:43:48 {\"uid\":\"cff6c161162a99cbfcc8008dc025171f\",\"success\":false,\"msg\":\"Vous devez vous connecter pour accéder à cette fonction\",\"result\":{\"password_salt\":\"uevfBH2thIsttJasR1uxWXfylShdosnm\",\"challenge\":\"l\/GD63XvipxgeDMx\/pfsWzoJPPeaAU5c\"},\"error_code\":\"auth_required\"} " 2021-06-14 07:43:48,stderr,2021/06/14 07:43:48 freebox_exporter started on port :10001

2021-06-14 07:43:46,stderr,2021/06/14 07:43:46 Erreur d'authentification de l'application

2021-06-14 07:43:46,stderr,2021/06/14 07:43:46 An error occured with NET metrics: Erreur d'authentification de l'application

2021-06-14 07:43:46,stderr,2021/06/14 07:43:46 An error occured with freeplug metrics: json: cannot unmarshal object into Go struct field freeplug.result of type []main.freeplugNetwork

2021-06-14 07:43:46,stderr,"2021/06/14 07:43:46 {\"uid\":\"cff6c161162a99cbfcc8008dc025171f\",\"success\":false,\"msg\":\"Vous devez vous connecter pour accéder à cette fonction\",\"result\":{\"password_salt\":\"uevfBH2thIsttJasR1uxWXfylShdosnm\",\"challenge\":\"l\/GD63XvipxgeDMx\/pfsWzoJPPeaAU5c\"},\"error_code\":\"auth_required\"} " 2021-06-14 07:43:46,stderr,2021/06/14 07:43:46 freebox_exporter started on port :10001

BTW, token works with bash script from https://github.com/JrCs/freeboxos-bash-api and as been named prometheus-exporter, with additional rights for "modifications des reglages de la freebox"

fab-git-f commented 3 years ago

Also, on last question Saphoo, I don't get the point of the -home mode if you use volumes to access the token already ?

saphoooo commented 3 years ago

Hi fab-git-f,

You're right, the HOME env is not the best option when running in a containerized fashion. It points to the directory where your token is inside the container.

So in your case, I recommend you to try with this option -e HOME=token -v /volume1/docker/freebox_exporter/:/token where /volume1/docker/freebox_exporter/ is the path on your computer where you store the token, and /token is the volume where the exporter expect to find it.

fab-git-f commented 3 years ago

Hi Saphoo,

Sorry for my late answer! but thanks for the explanation - I'm up&running again now. Great work ! last question, would it be possible to add freebox 4 switchports monitoring ?

Thanks, F

saphoooo commented 3 years ago

Great!

For your request, I'm not sure to understand. Freebox switches (wire) are already monitored under switches.

fab-git-f commented 3 years ago

Thanks Saphoo. Yes, I meant monitor individual (wired) switchports of the Freebox. Cannot find anything like 'switches' nor in 'freebox_*' values in my prometheus. Any flag to add for this ?

THanks !

saphoooo commented 3 years ago

Normally, you should have something like rx_1 and tx_1 for switch ports 1 and so on. Maybe you could try to have a look on this.

fab-git-f commented 3 years ago

Strangely, I can't find them. Using the docker version https://hub.docker.com/r/saphoooo/freebox-exporter/ with the last update.

Anyway, thank you very much for your help and time. Much appreciated! :-)