Sha256: 4aa12fed55929d10f3a71bd2fb403594eb4a4a1703e21512e0cfb70900080ce7

Contents?: true

Size: 910 Bytes

Versions: 14

Compression:

Stored size: 910 Bytes

Contents

# frozen_string_literal: true

require 'riemann/tools'

# Gathers memcached STATS and submits them to Riemann.
module Riemann
  module Tools
    class Memcached
      include Riemann::Tools
      require 'socket'

      opt :memcached_host, 'Memcached hostname', default: 'localhost'
      opt :memcached_port, 'Memcached port', default: 11_211

      def tick
        sock = TCPSocket.new(opts[:memcached_host], opts[:memcached_port])
        sock.print("stats\r\n")
        sock.flush
        stats = sock.gets

        loop do
          stats = sock.gets
          break if stats.strip == 'END'

          m = stats.match(/STAT (\w+) (\S+)/)
          report(
            host: opts[:memcached_host].dup,
            service: "memcached #{m[1]}",
            metric: m[2].to_f,
            state: 'ok',
            tags: ['memcached'],
          )
        end
        sock.close
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

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