Class: Nutcracker::Graphite::Agent

Inherits:
Object
  • Object
show all
Defined in:
lib/nutcracker/graphite.rb

Constant Summary collapse

INTERVAL =
60

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(nutcracker, options) ⇒ Agent

Returns a new instance of Agent.



17
18
19
20
# File 'lib/nutcracker/graphite.rb', line 17

def initialize nutcracker, options
  @nutcracker = nutcracker
  @graphite = GraphiteAPI.new options.merge interval: INTERVAL
end

Instance Attribute Details

#graphiteObject (readonly)

Returns the value of attribute graphite.



15
16
17
# File 'lib/nutcracker/graphite.rb', line 15

def graphite
  @graphite
end

#nutcrackerObject (readonly)

Returns the value of attribute nutcracker.



15
16
17
# File 'lib/nutcracker/graphite.rb', line 15

def nutcracker
  @nutcracker
end

Instance Method Details

#startObject



22
23
24
25
26
27
28
29
30
31
# File 'lib/nutcracker/graphite.rb', line 22

def start
  @task ||= graphite.every(INTERVAL) do |client|
    begin
      client.metrics metrics nutcracker.overview
    rescue Exception => e
      STDERR.puts [e.message,e.backtrace.join("\n")]
    end
  end
  self
end

#stopObject



33
34
35
# File 'lib/nutcracker/graphite.rb', line 33

def stop
  @task and @task.cancel
end