Sha256: dc2627195db7d1149417069a1d9d3c94abbb4777653c6f3d1945e50dfeb553aa

Contents?: true

Size: 908 Bytes

Versions: 8

Compression:

Stored size: 908 Bytes

Contents

#!/usr/bin/env ruby

# Gathers memcached STATS and submits them to Riemann.

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

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

  opt :memcached_host, "Memcached hostname", :default => 'localhost'
  opt :memcached_port, "Memcached port", :default => 11211

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

    data = {}
    while true
      stats = sock.gets
      break if stats.strip == 'END'
      m = stats.match /STAT (\w+) (\S+)/
      report(
             :host => opts[:memcached_host],
             :service => "memcached #{m[1]}",
             :metric => m[2].to_f,
             :state => 'ok',
             :tags => ['memcached']
             )
    end
    sock.close
  end
end

Riemann::Tools::Memcached.run

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
riemann-tools-0.1.7 bin/riemann-memcached
riemann-tools-0.1.6 bin/riemann-memcached
riemann-tools-0.1.5 bin/riemann-memcached
riemann-tools-0.1.4 bin/riemann-memcached
riemann-tools-0.1.3 bin/riemann-memcached
riemann-tools-0.1.2 bin/riemann-memcached
riemann-tools-0.1.1 bin/riemann-memcached
riemann-tools-0.1.0 bin/riemann-memcached