Closed AlfaJackal closed 4 years ago
Hi!
Yes, I have set the correct ruby version in the first line in the script. After that change it should work.
BR/JO!
First of all, thank you for supporting me!
I don't understand what is going on here. I read, that you changed the latest image to ruby 2.3 and you changed shabang line to default ruby
instead of ruby2.0
. I double checked it:
# ruby --version
ruby 2.3.3p222 (2016-11-21) [x86_64-linux-gnu]
I am also able to connect to my influxdb and telegraf default data has been written:
2020/01/16 18:12:00 I! Using config file: /etc/telegraf/telegraf.conf
2020-01-16T18:12:00Z I! Starting Telegraf v1.6.1
2020-01-16T18:12:00Z I! Loaded outputs: influxdb
2020-01-16T18:12:00Z I! Loaded inputs: inputs.processes inputs.swap inputs.system inputs.cpu inputs.disk inputs.diskio inputs.kernel inputs.mem
2020-01-16T18:12:00Z I! Tags enabled: host=telegraf-netatmo
2020-01-16T18:12:00Z I! Agent Config: Interval:10s, Quiet:false, Hostname:"telegraf-netatmo", Flush Interval:10s
And then, even if I start it with ruby ./netatmo
from within /usr/local/bin/
it throws me this:
# ruby ./netatmo
./netatmo:81:in `filter_data': private method `select' called for nil:NilClass (NoMethodError)
from ./netatmo:75:in `process_data'
from ./netatmo:104:in `block in measurements'
from ./netatmo:103:in `each'
from ./netatmo:103:in `measurements'
from ./netatmo:120:in `<main>'
I don't think there is a mistake in my configs, but please check below.
Docker
docker run \
--name telegraf-netatmo \
-e 'NETATMO_CLIENT_ID=xxx' \
-e 'NETATMO_CLIENT_SECRET=xxx' \
-e 'NETATMO_USERNAME=mail@domain.com' \
-e 'NETATMO_PASSWORD=1234' \
-e 'NETATMO_DEVICE_ID=xx:xx:xx:xx:xx:xx' \
--link influxdb \
benningm/telegraf-netatmo:latest
telegraf.conf
[[outputs.influxdb]]
urls = ["http://10.10.0.6:32784"]
database = "telegraf"
username = "telegraf"
password = "telegraf"
[[inputs.exec]]
commands = ["/usr/local/bin/netatmo"]
interval = "10m"
timeout = "15s"
data_format = "json"
name_suffix = "_netatmo"
Any help is much apprechiated!
Best, AlfaJackal
My container is running: ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux-gnu]
I have set the following as first line in the netatmo script:
telegraf.conf
DB-section:
[[outputs.influxdb]]
## The full HTTP or UDP URL for your InfluxDB instance.
##
## Multiple urls can be specified as part of the same cluster,
## this means that only ONE of the urls will be written to each interval.
# urls = ["udp://127.0.0.1:8089"] # UDP endpoint example
urls = ["http://localhost:8086"] # required
## The target database for metrics (telegraf will create it if not exists).
database = "netatmodb" # required
NETATMO-section:
[[inputs.exec]]
# ## Commands array
commands = ["/etc/telegraf/netatmo/netatmo"]
interval = "10m"
# "/tmp/test.sh",
# "/usr/bin/mycollector --foo=bar",
# "/tmp/collect_*.sh"
# ]
#
# ## Timeout for each command to complete.
timeout = "15s"
#
# ## measurement name suffix (for separating different commands)
name_suffix = "_netatmo"
#
# ## Data format to consume.
# ## Each data format has its own unique set of configuration options, read
# ## more about them here:
# ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md
data_format = "json"
Since that changes all works great. Is this a fresh install or do you have upgraded ruby and since that you get issues?
BR/JO!
I started from the scratch, made only changes to the config (See first post) which all seem to be correct:
Changing first line of netatmo
to
#!/usr/bin/env ruby2.3
doesn’t solve it. Also tried an upgrade of ruby on a clean install like you did - no luck either. Now I am back on a fresh docker install and still not working.
You have to change the first line in the netatmo script, not in the telegraf.conf file.
I have only changed the first line to match the correct installed ruby version.
A few weeks ago I have migrated from an ubuntu 16.04 to an fresh installed ubuntu 18.04 container without any issues.
BR/JO!
You have to change the first line in the netatmo script, not in the telegraf.conf file.
I have only changed the first line to match the correct installed ruby version.
Sure, did that. Just wrote in wrong in my last post.
Any more ideas, @benningm?
You can leave out the whole telegraf and influx configuration and run the script standalone.
Everything ruby >= 2.0 should work.
Currently it will use the ruby
from the PATH
:
#!/usr/bin/env ruby
The means the ruby
you see when you run which ruby
.
The nil
error reported is after the data has been retrieved from API:
./netatmo:81:in `filter_data': private method `select' called for nil:NilClass (NoMethodError)
Try adding this debug statement after line 59 (res = Net::HTTP.get_response(uri)
) in the script:
puts res.body
That should output the response body from the API to your terminal.
Please check the output for secrets or credentials before pasting it here.
Thanks for replying and trying to fix that error!
I started the script with ruby ./netatmo
with the debug statement after line 59. Data has been retrieved from API, here is the JSON: https://pastebin.com/7D9LuRbr
The script iterates over all station modules and uses 'dashboard_data'. Seems like 2 of your attached modules have no 'dashboard_data' attached in the API.
I just added a guard clause to skip these modules. Please try the latest revision in git.
BAM! That was it! Many thanks for your help, added that line and everything works as expected now!
I am pretty happy now! :)
It seems like I am experiencing a similar error to that issue linked. Could you describe, how you could solved this problem, @jostrasser?
This is my error message:
Ruby 2.3.3 is installed.
Best, AlfaJackal
Originally posted by @jostrasser in https://github.com/benningm/docker-telegraf-netatmo/issues/2#issuecomment-465143292