Sha256: dc14ed8ffbcd2814ce1b30ef903eff3cd109878cdb66a92d9ebbd799b7dee9a0

Contents?: true

Size: 1.02 KB

Versions: 27

Compression:

Stored size: 1.02 KB

Contents

class Riemann::Babbler::Http < Riemann::Babbler

  def init
    plugin.set_default(:service, 'http check')
    plugin.set_default(:interval, 60)

    plugin.states.set_default(:critical, 1)

    plugin.set_default(:http_code, 200)
    plugin.set_default(:http_method, 'GET')
    plugin.set_default(:connect_timeout, 5)
    plugin.set_default(:retry, 0)
    plugin.set_default(:retry_delay, 0)
    plugin.set_default(:max_time, 10)
   
    plugin.set_default(:url, 'http://127.0.0.1:80')
  end

  def collect
    command = "curl -X#{plugin.http_method} -s"
    command += " --connect-timeout #{plugin.connect_timeout}"
    command += " -w '%{http_code}\\n'"
    command += " --retry #{plugin.retry} --retry-delay #{plugin.retry_delay}"
    command += " --max-time #{plugin.max_time} --fail"
    command += " #{plugin.url} -o /dev/null"

    out = shell(command)

    if out.to_i != plugin.http_code
      metric = 1
    else
      metric = 0
    end

    {:service => plugin.service, :metric => metric, :description => "http_code: #{out}"}
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
riemann-babbler-1.0.8 lib/riemann/babbler/plugins/http.rb
riemann-babbler-1.0.7.9 lib/riemann/babbler/plugins/http.rb
riemann-babbler-1.0.7.8 lib/riemann/babbler/plugins/http.rb
riemann-babbler-1.0.7.7 lib/riemann/babbler/plugins/http.rb
riemann-babbler-1.0.7.5 lib/riemann/babbler/plugins/http.rb
riemann-babbler-1.0.7.4 lib/riemann/babbler/plugins/http.rb
riemann-babbler-1.1.0pre2 lib/riemann/babbler/plugins/http.rb
riemann-babbler-1.0.7.3 lib/riemann/babbler/plugins/http.rb
riemann-babbler-1.0.7.2 lib/riemann/babbler/plugins/http.rb
riemann-babbler-1.0.7.1 lib/riemann/babbler/plugins/http.rb
riemann-babbler-1.0.7 lib/riemann/babbler/plugins/http.rb
riemann-babbler-1.0.6 lib/riemann/babbler/plugins/http.rb
riemann-babbler-1.0.5.7 lib/riemann/babbler/plugins/http.rb
riemann-babbler-1.0.5.6 lib/riemann/babbler/plugins/http.rb
riemann-babbler-1.0.5.5 lib/riemann/babbler/plugins/http.rb
riemann-babbler-1.0.5.4 lib/riemann/babbler/plugins/http.rb
riemann-babbler-1.0.5.3 lib/riemann/babbler/plugins/http.rb
riemann-babbler-1.0.5.2 lib/riemann/babbler/plugins/http.rb
riemann-babbler-1.0.5.1 lib/riemann/babbler/plugins/http.rb
riemann-babbler-1.0.5 lib/riemann/babbler/plugins/http.rb