Sha256: 3f75ecdde93897fbe38e35acf012a762c8403ccfa5a74db2242394e1241bd8aa

Contents?: true

Size: 892 Bytes

Versions: 51

Compression:

Stored size: 892 Bytes

Contents

require 'net/http'
require 'csv'

class Riemann::Babbler::Plugin::Haproxy < Riemann::Babbler::Plugin

  def init
    plugin.set_default(:service, 'haproxy')
    plugin.set_default(:interval, 60)
    plugin.set_default(:url, 'http://user:password@localhost/stats;csv')
  end

  def collect
    status  = Array.new
    content = rest_get(plugin.url)
    csv     = CSV.parse(content.split('# ')[1], { :headers => true })
    csv.each do |row|
      row = row.to_hash
      ns  = "haproxy #{row['pxname']} #{row['svname']}"
      row.each do |property, metric|
        unless (property.nil? || property == 'pxname' || property == 'svname')
          status << {
              :service => "#{ns} #{property}",
              :metric  => metric.to_f,
              :state   => (%w(UP OPEN).include?(row['status']) ? 'ok' : 'critical')
          }
        end
      end
    end
    status
  end

end

Version data entries

51 entries across 51 versions & 1 rubygems

Version Path
riemann-babbler-2.8.5 lib/riemann/babbler/plugins/haproxy.rb
riemann-babbler-2.8.4 lib/riemann/babbler/plugins/haproxy.rb
riemann-babbler-2.8.3 lib/riemann/babbler/plugins/haproxy.rb
riemann-babbler-2.8.2 lib/riemann/babbler/plugins/haproxy.rb
riemann-babbler-2.8.1 lib/riemann/babbler/plugins/haproxy.rb
riemann-babbler-2.8.0 lib/riemann/babbler/plugins/haproxy.rb
riemann-babbler-2.6.0 lib/riemann/babbler/plugins/haproxy.rb
riemann-babbler-2.5.9 lib/riemann/babbler/plugins/haproxy.rb
riemann-babbler-2.5.8 lib/riemann/babbler/plugins/haproxy.rb
riemann-babbler-2.5.7 lib/riemann/babbler/plugins/haproxy.rb
riemann-babbler-2.5.6 lib/riemann/babbler/plugins/haproxy.rb
riemann-babbler-2.5.5 lib/riemann/babbler/plugins/haproxy.rb
riemann-babbler-2.5.4 lib/riemann/babbler/plugins/haproxy.rb
riemann-babbler-2.5.3 lib/riemann/babbler/plugins/haproxy.rb
riemann-babbler-2.5.2 lib/riemann/babbler/plugins/haproxy.rb
riemann-babbler-2.5.1 lib/riemann/babbler/plugins/haproxy.rb
riemann-babbler-2.5.0 lib/riemann/babbler/plugins/haproxy.rb
riemann-babbler-2.1.5 lib/riemann/babbler/plugins/haproxy.rb
riemann-babbler-2.1.4 lib/riemann/babbler/plugins/haproxy.rb
riemann-babbler-2.1.3.2 lib/riemann/babbler/plugins/haproxy.rb