Skip to content

Instantly share code, notes, and snippets.

@goyox86
Created November 20, 2014 13:07
Show Gist options
  • Save goyox86/44a9580b2f5e23bf9f59 to your computer and use it in GitHub Desktop.
Save goyox86/44a9580b2f5e23bf9f59 to your computer and use it in GitHub Desktop.
InfluxdbEmitter
require 'influxdb'
class InfluxdbEmitter
def initialize
@username = "root"
@password = "root"
@database = "rbx"
#InfluxDB::Client.new.create_database(@database)
@influxdb = InfluxDB::Client.new @database, username: @username,
password: @password
end
def start!
if RUBY_ENGINE != 'rbx'
puts "Not RBX. Nothing to do here!"
return
end
Thread.new do
loop do
metrics = Rubinius::Metrics.data.keys
metrics.each do |metric|
@influxdb.write_point(metric, { value: Rubinius::Metrics.data[metric] })
end
sleep 1
end
end.join
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment