benningm / docker-telegraf-netatmo

script and docker image to retrieve data from netatmo API
10 stars 8 forks source link

Error in plugin [inputs.exec]: exec: exit status 1 #1

Closed Nesousx closed 6 years ago

Nesousx commented 6 years ago

Hi Markus,

First of all, thanks for the script / docker.

However, I have an issue making it run, here is the output of the docker-compose up command:

docker-compose up
Creating netatmo ... 
Creating netatmo ... done
Attaching to netatmo
netatmo    | 2018/02/26 11:08:03 I! Using config file: /etc/telegraf/telegraf.conf
netatmo    | 2018-02-26T11:08:04Z I! Starting Telegraf (version 1.3.5)
netatmo    | 2018-02-26T11:08:04Z I! Loaded outputs: influxdb
netatmo    | 2018-02-26T11:08:04Z I! Loaded inputs: inputs.exec
netatmo    | 2018-02-26T11:08:04Z I! Tags enabled: host=256a9033364d
netatmo    | 2018-02-26T11:08:04Z I! Agent Config: Interval:10s, Quiet:false, Hostname:"256a9033364d", Flush Interval:10s 
netatmo    | 2018-02-26T11:08:10Z E! Error in plugin [inputs.exec]: exec: exit status 1 for command '/usr/local/bin/netatmo'

and the output when running "manually", the script from within the container:

ruby ./netatmo 
 (RuntimeError) `refresh_token': login failed: <html>
<head><title>400 The plain HTTP request was sent to HTTPS port</title></head>
<body bgcolor="white">
<center><h1>400 Bad Request</h1></center>
<center>The plain HTTP request was sent to HTTPS port</center>
<hr><center>nginx</center>
</body>
</html>
    from ./netatmo:18:in `initialize'
    from ./netatmo:114:in `new'
    from ./netatmo:114:in `<main>'

or

./netatmo 
./netatmo:31:in `refresh_token': login failed: {"error":"invalid_client"} (RuntimeError)
    from ./netatmo:18:in `initialize'
    from ./netatmo:114:in `new'
    from ./netatmo:114:in `<main>'

I am not sure why I get this error... I am already using the the same telegraf.conf on several servers and it works OK. I am pretty sure my credentials are all good. I triple checked them.

Telegraf conf:

 [[outputs.influxdb]]
   urls = ["http://xxxxx.yyyy.com:8086"] # required
   database = "telegraf" # required
   username = "telegraf"
   password = "xxxxxx"

 [[inputs.exec]]
   commands = ["/usr/local/bin/netatmo"]
   interval = "10m"
   timeout = "15s"
   data_format = "json"
   name_suffix = "_netatmo"

And finally docker-compose.yml file:

version: '2'
services:
    netatmo:
        container_name: netatmo
        image: benningm/telegraf-netatmo
        restart: unless-stopped
        volumes:
          - ./conf/telegraf.conf:/etc/telegraf/telegraf.conf:ro
        environment:
          - NETATMO_CLIENT_ID=
          - NETATMO_CLIENT_SECRET=
          - NETATMO_USERNAME=
          - NETATMO_PASSWORD=
          - NETATMO_DEVICE_ID=

Trying to change "urls" in the telegraf config with and without httpS didn't changed anything.

Thanks a lot for your help.

benningm commented 6 years ago

Can you check if a http_proxy or https_proxy is set within the container?

Nesousx commented 6 years ago

Hi,

As far as I know there is no proxy in use, I tested like this :

root@9952e78e52e9:/# printenv | grep -i proxy  
root@9952e78e52e9:/# exit

and : docker inspect netatmo | grep -i proxy

Both queries return nothing.

benningm commented 6 years ago

The proxy error is because of using ruby 1.9 instead of ruby 2.0. I updated the README to make clear ruby 2.0 or newer is required. The shebang line specifies the correct ruby binary.

The second error seems to be related to credentials:

./netatmo:31:in `refresh_token': login failed: {"error":"invalid_client"} (RuntimeError)

According to the API specification:

https://dev.netatmo.com/en-US/resources/technical/guides/authentication/clientcredentials

The value invalid_client means The client identifier provided is invalid.

Please check the NETATMO_CLIENT_ID= parameter.