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

Version Path
city-watch-0.5.2 lib/city_watch/util/collector.rb
city-watch-0.5.1 lib/city_watch/util/collector.rb
city-watch-0.5.0 lib/city_watch/util/collector.rb
city-watch-0.4.9 lib/city_watch/util/collector.rb
city-watch-0.4.7 lib/city_watch/util/collector.rb
city-watch-0.4.6 lib/city_watch/util/collector.rb
city-watch-0.4.5 lib/city_watch/util/collector.rb
city-watch-0.4.4 lib/city_watch/util/collector.rb
city-watch-0.4.3 lib/city_watch/util/collector.rb
city-watch-0.4.2 lib/city_watch/util/collector.rb
city-watch-0.4.1 lib/city_watch/util/collector.rb
city-watch-0.4.0 lib/city_watch/util/collector.rb
city-watch-0.3.3 lib/city_watch/util/collector.rb
city-watch-0.3.2 lib/city_watch/util/collector.rb
city-watch-0.3.1 lib/city_watch/util/collector.rb
city-watch-0.3.0 lib/city_watch/util/collector.rb