class Riemann::Tools::Curl

Constants

CURL_METRICS

Public Instance Methods

tick() click to toggle source
# File bin/riemann-curl, line 16
def tick
    response = ::Curl::Easy.perform(opts[:uri]) do |curl| 
        curl.headers["User-Agent"] = "riemann-curl"
        curl.timeout = opts[:max_time]
        curl.connect_timeout = opts[:connect_timeout]
        curl.follow_location = true
    end

    CURL_METRICS.each do |metric|
        value = response.send(metric)
        data = {
            :host    => URI.parse(opts[:uri]).host,
            :service => "curl #{metric}",
            :metric  => value.to_s,
            :tags    => ['curl'],
            :state   => 'ok'
        }
        report(data)
    end
end