lib/ring/sqa/graphite.rb in ring-sqa-0.3.1 vs lib/ring/sqa/graphite.rb in ring-sqa-0.4.1

- old
+ new

@@ -5,24 +5,30 @@ class Graphite ROOT = "nlnog.ring_sqa.#{CFG.afi}" def add records + host = @hostname.split(".").first + node = @nodes.all records.each do |record| + nodename = noderec = node[record.peer][:name].split(".").first + nodecc = noderec = node[record.peer][:cc].downcase hash = { - "#{ROOT}.#{record.peer}.state" => record.result + "#{ROOT}.#{host}.#{nodecc}.#{nodename}.state" => record.result } - if record.result == 'success' - hash["#{ROOT}.#{record.peer}.latency"] = record.latency + if record.result != 'no response' + hash["#{ROOT}.#{host}.#{nodecc}.#{nodename}.latency"] = record.latency end @client.metrics hash, record.time end end private - - def initialize server=CFG.graphite + + def initialize nodes, server=CFG.graphite @client = GraphiteAPI.new graphite: server + @hostname = Ring::SQA::CFG.host.name + @nodes = nodes end end end end