Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent Environment variables around password fields #12

Closed
instantdreams opened this issue Oct 18, 2022 · 5 comments
Closed

Inconsistent Environment variables around password fields #12

instantdreams opened this issue Oct 18, 2022 · 5 comments

Comments

@instantdreams
Copy link

instantdreams commented Oct 18, 2022

When using docker-compose the password fields are inconsistent. Using the following compose file results in an error:

version: "3"
services:
  netgear_exporter:
    image: druggeri/netgear_exporter:latest
    container_name: netgear_exporter
    environment:
      - URL=${URL}
      - USERNAME=${USERNAME}
      - PASSWORD=${PASSWORD}
      - WEB_AUTH_USERNAME=${WEB_AUTH_USERNAME}
      - WEB_AUTH_PASSWORD=${WEB_AUTH_PASSWORD}
      - INSECURE=true
      - CLIENTDEBUG
      - METRICS_NAMESPACE=netgear
      - TIMEOUT=2
    ports:
      - 9192:9192
    restart: unless-stopped

The error is around the environment variable:

$ docker-compose --file /srv/netgear_exporter/docker-compose.yml logs
Attaching to netgear_exporter
netgear_exporter    | ERROR: The password for the SOAP API must be set in the environment variable NETGEAR_EXPORTER_PASSWORD
netgear_exporter    | ERROR: The password for the SOAP API must be set in the environment variable NETGEAR_EXPORTER_PASSWORD
netgear_exporter    | ERROR: The password for the SOAP API must be set in the environment variable NETGEAR_EXPORTER_PASSWORD
netgear_exporter    | ERROR: The password for the SOAP API must be set in the environment variable NETGEAR_EXPORTER_PASSWORD
netgear_exporter    | ERROR: The password for the SOAP API must be set in the environment variable NETGEAR_EXPORTER_PASSWORD

Are all environment variables expected to be prefixed with NETGEAR_EXPORTER_ ?

@instantdreams
Copy link
Author

instantdreams commented Oct 18, 2022

I adjusted the docker-compose.yml as follows:

version: "3"
services:
  netgear_exporter:
    image: druggeri/netgear_exporter:latest
    container_name: netgear_exporter
    environment:
      - NETGEAR_EXPORTER_URL=${URL}
      - NETGEAR_EXPORTER_USERNAME=${USERNAME}
      - NETGEAR_EXPORTER_PASSWORD=${PASSWORD}
      - NETGEAR_EXPORTER_INSECURE=true
      - NETGEAR_EXPORTER_TIMEOUT=2
      - NETGEAR_EXPORTER_CLIENT_DEBUG=true
      - NETGEAR_EXPORTER_FILTER_COLLECTORS=Client,SystemInfo,Traffic
      - NETGEAR_EXPORTER_METRICS_NAMESPACE=netgear
    ports:
      - 9192:9192
    restart: unless-stopped

Now everything appears to be working.

$ docker-compose --file /srv/netgear_exporter/docker-compose.yml logs
Attaching to netgear_exporter
netgear_exporter    | time="2022-10-18T16:55:15Z" level=info msg="Starting node_exporter 2.0.3" source="netgear_exporter.go:180"
netgear_exporter    | 2022/10/18 16:55:15 netgear_client.go: Constructing debug client
netgear_exporter    | time="2022-10-18T16:55:15Z" level=info msg="Listening on :9192" source="netgear_exporter.go:230"

@DRuggeri Once you confirm this we can close the issue.

@instantdreams
Copy link
Author

I am getting the following in the logs now:

netgear_exporter    | 2022/10/18 17:10:21 netgear_client.go: Response code: 500
netgear_exporter    | 2022/10/18 17:10:21 netgear_client.go: Response headers:
netgear_exporter    | 2022/10/18 17:10:21 netgear_client.go:   Content-Length: 365
netgear_exporter    | 2022/10/18 17:10:21 netgear_client.go:   Date: Tue, 18 Oct 2022 17:10:21 GMT
netgear_exporter    | 2022/10/18 17:10:21 netgear_client.go:   Content-Type: text/html
netgear_exporter    | time="2022-10-18T17:10:21Z" level=error msg="Error while collecting system info: xml: encoding \"iso-8859-1\" declared but Decoder.CharsetReader is nil" source="system_info_collector.go:110"
netgear_exporter    | 2022/10/18 17:10:21 netgear_client.go: Response code: 500
netgear_exporter    | 2022/10/18 17:10:21 netgear_client.go: Response headers:
netgear_exporter    | 2022/10/18 17:10:21 netgear_client.go:   Content-Type: text/html
netgear_exporter    | 2022/10/18 17:10:21 netgear_client.go:   Content-Length: 365
netgear_exporter    | 2022/10/18 17:10:21 netgear_client.go:   Date: Tue, 18 Oct 2022 17:10:21 GMT
netgear_exporter    | time="2022-10-18T17:10:21Z" level=error msg="Error while collecting client statistics: xml: encoding \"iso-8859-1\" declared but Decoder.CharsetReader is nil" source="clients_collector.go:122"
netgear_exporter    | 2022/10/18 17:10:21 netgear_client.go: Response code: 500
netgear_exporter    | 2022/10/18 17:10:21 netgear_client.go: Response headers:
netgear_exporter    | 2022/10/18 17:10:21 netgear_client.go:   Content-Type: text/html
netgear_exporter    | 2022/10/18 17:10:21 netgear_client.go:   Content-Length: 365
netgear_exporter    | 2022/10/18 17:10:21 netgear_client.go:   Date: Tue, 18 Oct 2022 17:10:21 GMT
netgear_exporter    | time="2022-10-18T17:10:21Z" level=error msg="Error while collecting traffic statistics: xml: encoding \"iso-8859-1\" declared but Decoder.CharsetReader is nil" source="traffic_collector.go:126"

Not sure how to set CharsetReader to iso-8859-1.

@DRuggeri
Copy link
Owner

Hi, @instantdreams. You are correct - all of the variables are prepended by the name of the exporter. For a complete list of valid variables, have a look at the README (or the -h output of the program)

I'm afraid I haven't seen that other error message related to the XML encoding and don't seem to have the same issue on my local orbi system. There are a few hints on stack overflow that describe options to work around this or fix it, but I don't know if the Netgear API actually makes use of the Latin characters that this CharSet calls for. Any ideas based on the output of debug mode? It might give some hints on the appropriate next action.

Also, are you able to build and run a test binary to see if a patch helps should we get to that point?

@instantdreams
Copy link
Author

The encoding is set to UTF-8 on my system, which is visible in the debug logs:

netgear_exporter    | 2022/10/18 22:30:53 netgear_client.go:   Date: Tue, 18 Oct 2022 22:30:53 GMT
netgear_exporter    | time="2022-10-18T22:30:53Z" level=error msg="Error while collecting system info: xml: encoding \"iso-8859-1\" declared but Decoder.CharsetReader is nil" source="system_info_collector.go:110"
netgear_exporter    | 2022/10/18 22:31:06 netgear_client.go: full url (derived)='http://192.168.1.1/soap/server_sa/', data='<?xml version="1.0" encoding="UTF-8" standalone="no"?>
netgear_exporter    | <SOAP-ENV:Envelope
netgear_exporter    |   xmlns:SOAPSDK1="http://www.w3.org/2001/XMLSchema"
netgear_exporter    |   xmlns:SOAPSDK2="http://www.w3.org/2001/XMLSchema-instance"
netgear_exporter    |   xmlns:SOAPSDK3="http://schemas.xmlsoap.org/soap/encoding/"
netgear_exporter    |   xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
netgear_exporter    |   <SOAP-ENV:Header>
netgear_exporter    |     <SessionID>[session]</SessionID>
netgear_exporter    |   </SOAP-ENV:Header>
netgear_exporter    |   <SOAP-ENV:Body>
netgear_exporter    |     <M1:GetTrafficMeterStatistics xmlns:M1="urn:NETGEAR-ROUTER:service:DeviceConfig:1">
netgear_exporter    |     </M1:GetTrafficMeterStatistics>
netgear_exporter    |   </SOAP-ENV:Body>
netgear_exporter    | </SOAP-ENV:Envelope>'
netgear_exporter    | 2022/10/18 22:31:06 netgear_client.go: Sending HTTP request to http://192.168.1.1/soap/server_sa/...
netgear_exporter    | 2022/10/18 22:31:06 netgear_client.go: Request headers:
netgear_exporter    | 2022/10/18 22:31:06 netgear_client.go:   Cookie:
netgear_exporter    | 2022/10/18 22:31:06 netgear_client.go:   Content-Length: 580
netgear_exporter    | 2022/10/18 22:31:06 netgear_client.go:   User-Agent: curl/7.59.0
netgear_exporter    | 2022/10/18 22:31:06 netgear_client.go:   Content-Type: text/xml;charset=utf-8
netgear_exporter    | 2022/10/18 22:31:06 netgear_client.go:   Soapaction: urn:NETGEAR-ROUTER:service:DeviceConfig:1#GetTrafficMeterStatistics
netgear_exporter    | 2022/10/18 22:31:06 netgear_client.go:   Host: routerlogin.net
netgear_exporter    | 2022/10/18 22:31:06 netgear_client.go: BODY:
netgear_exporter    | 2022/10/18 22:31:06 <?xml version="1.0" encoding="UTF-8" standalone="no"?>

The only other difference is with the settings for the router:
image

The debug response and the web interface for my LAN router page encode in utf-8.

I can likely put together an environment to build a binary if needed.

@DRuggeri
Copy link
Owner

Hey there again, @instantdreams

I had some time to look at this again today and I don't think the issue stems from this codebase. Rather, I believe it comes from the netgear_client codebase (also one of my repos).

I'd like to go ahead and close the issue here and take the discussion to the other repo in a new issue. There are instructions there on how we can test this in your environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants