class Ring::SQA::Alarm::Collector
Constants
- TIMEOUT
- URL
Public Instance Methods
send(opts)
click to toggle source
# File lib/ring/sqa/alarm/collector.rb, line 11 def send opts @url = CFG.collector.url? ? CFG.collector.url : URL json = JSON.pretty_generate( { :alarm_buffer => opts[:alarm_buffer].exceeding_nodes, :nodes => opts[:nodes].all, :short => opts[:short], :long => opts[:long], :status => opts[:status], :afi => opts[:afi], }) post json rescue => error Log.error "Collector send raised '#{error.class}' with message '#{error.message}'" end
Private Instance Methods
post(json)
click to toggle source
# File lib/ring/sqa/alarm/collector.rb, line 28 def post json Thread.new do begin Timeout::timeout(TIMEOUT) do uri = URI.parse @url http = Net::HTTP.new uri.host, uri.port http.use_ssl = true if uri.scheme == 'https' http.post uri.path, json end rescue Timeout::Error Log.error "Collector post timed out" rescue => error Log.error "Collector post raised '#{error.class}' with message '#{error.message}'" end end end