mongodb-graphite 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/bin/mongodb-graphite CHANGED
@@ -4,15 +4,15 @@ require 'mongo'
4
4
  require 'graphite'
5
5
  require 'peach'
6
6
 
7
- graphite_server = ARGV[0]
8
-
7
+ graphite_server = ARGV[1]
8
+ prefix_common = ARGV[0]+"."
9
+ puts graphite_server
9
10
  g = Graphite::Logger.new(graphite_server)
10
11
 
11
12
  to_ignore =[ "set", "repl", "time","qr|qw","ar|aw","conn"]
12
13
  to_convert = ["mapped","vsize","res","netIn","netOut"]
13
14
  output_average = ["mapped","vsize","res","locked","idxmiss"]
14
15
  output_sum = ["netIn", "netOut","insert","query","update","delete","getmore","command","flushes","faults"]
15
- prefix_common = "criteo.mongodb."
16
16
 
17
17
  def convert(s)
18
18
  mul = case s[-1]
@@ -41,7 +41,7 @@ end
41
41
 
42
42
 
43
43
 
44
- def treat_replicaset(g,to_ignore,to_convert, output_average, output_sum ,prefix_common,host,port)
44
+ def treat_replicaset(g,to_ignore,to_convert, output_average, output_sum ,prefix_common,host,port, shard_name)
45
45
  #puts "shard : ", host,port
46
46
  connHost = Mongo::Connection.new(host, port)
47
47
  slaves = Array.new
@@ -58,7 +58,7 @@ def treat_replicaset(g,to_ignore,to_convert, output_average, output_sum ,prefix_
58
58
  values= values.delete_if {|line| line.start_with?('insert')}.map { |line| line.gsub('*','').split}
59
59
  values = values.transpose
60
60
 
61
- prefix = prefix_common + host +"."+port+"."
61
+ prefix = prefix_common +shard_name+"."+ host +"."+port+"."
62
62
  headers = headers.map { |key| prefix+key }
63
63
  metrics = Hash[headers.zip(values)]
64
64
  to_ignore.each { |key| metrics.delete(prefix + key) }
@@ -80,13 +80,14 @@ begin
80
80
  shards = Array.new
81
81
  puts @conn["config"]["shards"].find().each { |shard| shards << shard["host"] }
82
82
  shards.each { |s|
83
+ puts s
83
84
  Process.fork do
84
85
  host,port = s.split(/,|\//)[1].split(':')
85
- treat_replicaset(g,to_ignore,to_convert, output_average, output_sum ,prefix_common,host,port)
86
+ treat_replicaset(g,to_ignore,to_convert, output_average, output_sum ,prefix_common,host,port, s.split(/,|\//)[0])
86
87
  end
87
88
  }
88
89
  rescue
89
90
  puts "not mongos"
90
- treat_replicaset(g,to_ignore,to_convert, output_average, output_sum ,prefix_common,hostt,portt)
91
+ treat_replicaset(g,to_ignore,to_convert, output_average, output_sum ,prefix_common,hostt,portt, "direct")
91
92
  end
92
- Process.wait
93
+ Process.wait
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "mongodb-graphite"
6
- s.version = '0.1.4'
6
+ s.version = '0.1.5'
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["Grégoire Seux"]
9
9
  s.email = ["g.seux@criteo.com"]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongodb-graphite
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 4
10
- version: 0.1.4
9
+ - 5
10
+ version: 0.1.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - "Gr\xC3\xA9goire Seux"
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-03-09 00:00:00 Z
18
+ date: 2012-03-15 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: mongo