Class: Riemann::Tools::Zookeeper

Inherits:
Object
  • Object
show all
Includes:
Riemann::Tools
Defined in:
lib/riemann/tools/zookeeper.rb

Constant Summary

Constants included from Riemann::Tools

VERSION

Instance Attribute Summary

Attributes included from Riemann::Tools

#argv

Instance Method Summary collapse

Methods included from Riemann::Tools

#attributes, #endpoint_name, included, #initialize, #options, #report, #riemann, #run

Instance Method Details

#tickObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/riemann/tools/zookeeper.rb', line 15

def tick
  sock = TCPSocket.new(opts[:zookeeper_host], opts[:zookeeper_port])
  sock.sync = true
  sock.print('mntr')
  sock.flush

  loop do
    stats = sock.gets

    break if stats.nil?

    m = stats.match(/^(\w+)\t+(.*)/)

    report(
      host: opts[:zookeeper_host].dup,
      service: "zookeeper #{m[1]}",
      metric: m[2].to_f,
      state: 'ok',
      tags: ['zookeeper'],
    )
  end
  sock.close
end