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