Sha256: 156d1b121cfefd065d25e9bfd75deffe769c927e1aab179350902af2d043288a

Contents?: true

Size: 891 Bytes

Versions: 15

Compression:

Stored size: 891 Bytes

Contents

# frozen_string_literal: true

require 'riemann/tools'

# Gathers zookeeper STATS and submits them to Riemann.
module Riemann
  module Tools
    class 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

        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
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
riemann-tools-1.12.0 lib/riemann/tools/zookeeper.rb
riemann-tools-1.11.0 lib/riemann/tools/zookeeper.rb
riemann-tools-1.10.0 lib/riemann/tools/zookeeper.rb
riemann-tools-1.9.1 lib/riemann/tools/zookeeper.rb
riemann-tools-1.9.0 lib/riemann/tools/zookeeper.rb
riemann-tools-1.8.2 lib/riemann/tools/zookeeper.rb
riemann-tools-1.8.1 lib/riemann/tools/zookeeper.rb
riemann-tools-1.8.0 lib/riemann/tools/zookeeper.rb
riemann-tools-1.7.1 lib/riemann/tools/zookeeper.rb
riemann-tools-1.7.0 lib/riemann/tools/zookeeper.rb
riemann-tools-1.6.0 lib/riemann/tools/zookeeper.rb
riemann-tools-1.5.0 lib/riemann/tools/zookeeper.rb
riemann-tools-1.4.0 lib/riemann/tools/zookeeper.rb
riemann-tools-1.3.0 lib/riemann/tools/zookeeper.rb
riemann-tools-1.2.0 lib/riemann/tools/zookeeper.rb