Sha256: 88abc85606e08eab98f41a5b4b09edf457a55069f1dd88e8a94f62f931986c72

Contents?: true

Size: 917 Bytes

Versions: 16

Compression:

Stored size: 917 Bytes

Contents

#!/usr/bin/env ruby

# Gathers zookeeper STATS and submits them to Riemann.

require File.expand_path('../../lib/riemann/tools', __FILE__)

class Riemann::Tools::Zookeeper
  include Riemann::Tools
  require 'socket'

  opt :zookeeper_host, "Zookeeper hostname", :default => 'localhost'
  opt :zookeeper_port, "Zookeeper port", :default => 2181

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

    data = {}
    while true
      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
end

Riemann::Tools::Zookeeper.run

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
riemann-tools-0.2.14 bin/riemann-zookeeper
riemann-tools-0.2.13 bin/riemann-zookeeper
riemann-tools-0.2.11 bin/riemann-zookeeper
riemann-tools-0.2.10 bin/riemann-zookeeper
riemann-tools-0.2.9 bin/riemann-zookeeper
riemann-tools-0.2.8 bin/riemann-zookeeper
riemann-tools-0.2.7 bin/riemann-zookeeper
riemann-tools-0.2.6 bin/riemann-zookeeper
riemann-tools-0.2.5 bin/riemann-zookeeper
riemann-tools-0.2.4 bin/riemann-zookeeper
riemann-tools-0.2.3 bin/riemann-zookeeper
riemann-tools-dgvz-0.2.2.3 bin/riemann-zookeeper
riemann-tools-dgvz-0.2.2.2 bin/riemann-zookeeper
riemann-tools-dgvz-0.2.2.1 bin/riemann-zookeeper
riemann-tools-0.2.2 bin/riemann-zookeeper
riemann-tools-0.2.1 bin/riemann-zookeeper