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
# File 'lib/nutcracker/graphite.rb', line 22

def start
  @task ||= graphite.every INTERVAL do |client|
    client.metrics metrics parse nutcracker.stats
  end
  self
end

#stopObject



29
30
31
# File 'lib/nutcracker/graphite.rb', line 29

def stop
  @task and @task.cancel
end