Sha256: d808b84ce3e46ac3f319087193ce14b6596fc5feeb7cac3585422956b968cec7

Contents?: true

Size: 726 Bytes

Versions: 13

Compression:

Stored size: 726 Bytes

Contents

require 'json'

class Riemann::Babbler::Cloudrestreamerstatus < Riemann::Babbler

  def init
    plugin.set_default(:service, 'cloud restreamer clients')
    plugin.set_default(:interval, 60)
    plugin.set_default(:url, 'http://localhost/client/all')
  end

  def collect
    clients = 0
    json = JSON.parse rest_get(plugin.url)
    json.each do |worker|
      next unless worker.has_key? "processors"
      worker["processors"].each do |key, client_hash|
        next unless client_hash.has_key? "clients"
        client_hash["clients"].each {|key| clients += 1}
      end
    end
    {:service => plugin.service, :description => "Cloud restreamer clients in #{plugin.url}", :metric => clients, :state => 'ok' }
  end

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
riemann-babbler-1.0.7.2 lib/riemann/babbler/plugins/cloudrestreamerstatus.rb
riemann-babbler-1.0.7.1 lib/riemann/babbler/plugins/cloudrestreamerstatus.rb
riemann-babbler-1.0.7 lib/riemann/babbler/plugins/cloudrestreamerstatus.rb
riemann-babbler-1.0.6 lib/riemann/babbler/plugins/cloudrestreamerstatus.rb
riemann-babbler-1.0.5.7 lib/riemann/babbler/plugins/cloudrestreamerstatus.rb
riemann-babbler-1.0.5.6 lib/riemann/babbler/plugins/cloudrestreamerstatus.rb
riemann-babbler-1.0.5.5 lib/riemann/babbler/plugins/cloudrestreamerstatus.rb
riemann-babbler-1.0.5.4 lib/riemann/babbler/plugins/cloudrestreamerstatus.rb
riemann-babbler-1.0.5.3 lib/riemann/babbler/plugins/cloudrestreamerstatus.rb
riemann-babbler-1.0.5.2 lib/riemann/babbler/plugins/cloudrestreamerstatus.rb
riemann-babbler-1.0.5.1 lib/riemann/babbler/plugins/cloudrestreamerstatus.rb
riemann-babbler-1.0.5 lib/riemann/babbler/plugins/cloudrestreamerstatus.rb
riemann-babbler-1.0.4 lib/riemann/babbler/plugins/cloudrestreamerstatus.rb