Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #18 from tomvachon/graphite_TCPSocket

Modularize graphite calls using TCPSocket
  • Loading branch information...
commit 06fc9218a841b1e8e4ed6799da03f5f6ce4a01e6 2 parents 8c6508b + 2cf63e9
@jgoulah jgoulah authored
Showing with 16 additions and 3 deletions.
  1. +2 −3 helpers.rb
  2. +14 −0 helpers/graphite.rb
View
5 helpers.rb
@@ -298,7 +298,7 @@ def log(env, who, msg, stack)
def timing_log(duration, type, stack)
log_string_to_file("#{now}|#{type}|#{stack}|#{duration}", timing_log_path)
- %x{echo "deploylong.#{stack}.#{type} #{duration} #{Time.now.to_i}" | nc #{Deployinator.graphite_host} #{Deployinator.graphite_port || 2003}}
+ graphite_plot("deploylong.#{stack}.#{type} #{duration}")
end
def log_string_to_file(string, path)
@@ -335,8 +335,7 @@ def after_stream(args, extra={})
end
# ping graphite!
- time = args["time"] || Time.now
- %x{echo "deploys.#{args["stack"]}.#{env} 1 #{time.to_i}" | nc #{Deployinator.graphite_host} #{Deployinator.graphite_port || 2003}}
+ graphite_plot("deploys.#{args["stack"]}.#{env} 1")
end
end
View
14 helpers/graphite.rb
@@ -0,0 +1,14 @@
+module Deployinator
+ module Helpers
+ module GraphiteHelpers
+ require 'socket'
+ def graphite_plot(logString)
+ if Deployinator.graphite_host
+ s = TCPSocket.new(Deployinator.graphite_host,Deployinator.graphite_port || 2003)
+ s.write "#{logString} #{Time.now.to_i}\n"
+ s.close
+ end
+ end
+ end
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.