Sha256: b031b115b20bf92c1c8f010f2a22b105ec4576602bb1b3baf557778283215248
Contents?: true
Size: 1.33 KB
Versions: 3
Compression:
Stored size: 1.33 KB
Contents
class ResendRequest def call(env) post_data = begin Yajl::Parser.new(:symbolize_keys => true).parse(env["rack.input"].read) || {} rescue {} end post_data[:received_at] = Time.now.to_s CityWatch.redis.sadd "#{CityWatch.config[:prefix]}::known_hosts", post_data[:hostname] CityWatch.redis.zadd "#{CityWatch.config[:prefix]}::#{post_data[:hostname]}::raw_stats", Time.now.to_i, Yajl::Encoder.encode(post_data) summary = {} post_data[:watchmen].each do |watchman,dat| CityWatch.redis.zadd "#{CityWatch.config[:prefix]}::#{post_data[:hostname]}::#{watchman}", Time.now.to_i, Yajl::Encoder.encode(dat.merge({:received_at => post_data[:received_at]})) if dat[:summary] sum = dat[:summary].is_a?(Array) ? dat[:summary].inject({}) {|acc,k| acc[k.to_sym] = dat[k.to_sym]; acc}.merge({:received_at => post_data[:received_at]}) : dat[:summary] CityWatch.redis.zadd "#{CityWatch.config[:prefix]}::#{post_data[:hostname]}::#{watchman}::summary", Time.now.to_i, Yajl::Encoder.encode(sum) summary[watchman] = sum end end CityWatch.redis.zadd "#{CityWatch.config[:prefix]}::#{post_data[:hostname]}::summary", Time.now.to_i, Yajl::Encoder.encode(summary) [200,{"Content-Type" => "text/plain"},["Got it!"]] end Routes.add_route new, { :request_method => 'POST', :path_info => %r{^/receive} }, {}, :receive_data end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
city-watch-0.3.2 | lib/city_watch/collector/receive.rb |
city-watch-0.3.1 | lib/city_watch/collector/receive.rb |
city-watch-0.3.0 | lib/city_watch/collector/receive.rb |