Code Monkey home page Code Monkey logo

Comments (10)

jostrasser avatar jostrasser commented on August 18, 2024

Hi!

Yes, I have set the correct ruby version in the first line in the script. After that change it should work.

BR/JO!

from docker-telegraf-netatmo.

AlfaJackal avatar AlfaJackal commented on August 18, 2024

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 '[email protected]' \
  -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

from docker-telegraf-netatmo.

jostrasser avatar jostrasser commented on August 18, 2024

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:
#!/usr/bin/env ruby2.5

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!

from docker-telegraf-netatmo.

AlfaJackal avatar AlfaJackal commented on August 18, 2024

I started from the scratch, made only changes to the config (See first post) which all seem to be correct:

  1. Ruby 2.3.3 is running
  2. influxdb has been connected
  3. Netatmo Script has been found and used by telegraf. Double checked credentials, also no auth error - so this must be ok.
  4. Default Container Data has been written to InfluxDB.

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.

from docker-telegraf-netatmo.

jostrasser avatar jostrasser commented on August 18, 2024

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!

from docker-telegraf-netatmo.

AlfaJackal avatar AlfaJackal commented on August 18, 2024

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?

from docker-telegraf-netatmo.

benningm avatar benningm commented on August 18, 2024

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.

from docker-telegraf-netatmo.

AlfaJackal avatar AlfaJackal commented on August 18, 2024

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

from docker-telegraf-netatmo.

benningm avatar benningm commented on August 18, 2024

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.

from docker-telegraf-netatmo.

AlfaJackal avatar AlfaJackal commented on August 18, 2024

BAM! That was it!
Many thanks for your help, added that line and everything works as expected now!

I am pretty happy now! :)

from docker-telegraf-netatmo.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.