Sha256: d00d28145e15ab586458687741da9403d13c15a017c9574353574775983895ee
Contents?: true
Size: 845 Bytes
Versions: 16
Compression:
Stored size: 845 Bytes
Contents
module Collector def self.send!(addr,dat) require "yajl" require 'net/http' require 'net/https' puts "Sending message to: http#{CityWatch.config[:secure] ? "s" : ""}://#{addr}/receive" if CityWatch.debug? uri = URI.parse("http#{CityWatch.config[:secure] ? "s" : ""}://#{addr}/receive") http = Net::HTTP.new(uri.host, uri.port) if CityWatch.config[:secure] http.use_ssl = true http.ssl_version = :SSLv3 http.verify_mode = OpenSSL::SSL::VERIFY_PEER if File.exists?('/etc/ssl/certs') # Ubuntu http.ca_path = '/etc/ssl/certs' end end req = Net::HTTP::Post.new(uri.path) req.body = Yajl::Encoder.encode(dat) req["Content-Type"] = 'application/json' case http.request(req) when Net::HTTPSuccess puts "Successfully sent to collector." if CityWatch.debug? else raise Exception end end end
Version data entries
16 entries across 16 versions & 1 rubygems