Class: GraphiteInterface
- Inherits:
-
Object
- Object
- GraphiteInterface
- Defined in:
- lib/capistrano/graphite.rb
Class Method Summary collapse
Class Method Details
.events_enabled ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/capistrano/graphite.rb', line 8 def self.events_enabled if fetch(:graphite_enable_events).to_i == 1 return 1 elsif fetch(:graphite_enable_events).to_i == 0 puts "Not sending an event: graphite_enable_events was set to 0." return 0 else warn "Not sending an event: graphite_enable_events was assigned an "\ "invalid value." return 0 end end |
.post_event(action) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/capistrano/graphite.rb', line 21 def self.post_event(action) uri = URI::parse("#{fetch(:graphite_url)}") req = Net::HTTP::Post.new(uri.path) req.basic_auth(uri.user, uri.password) if uri.user req.body = "{\"what\": \"#{action} #{fetch(:application)} in #{fetch(:stage)}\", \"tags\": \"#{fetch(:application)},#{fetch(:stage)},#{},#{action}\", \"data\": \"#{fetch(:local_user)}\"}" Net::HTTP.start(uri.host, uri.port) do |http| http.request(req) end end |