mongodb-graphite-agent 0.0.5 → 0.0.6

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.
@@ -13,6 +13,7 @@ opts = Trollop::options do
13
13
  opt :mongodb_password, "MongoDB password", :type => :string
14
14
  opt :graphite_host, "Graphite host", :type => :string
15
15
  opt :graphite_port, "Graphite port", :type => :string
16
+ opt :graphite_metrics_prefix, "Graphite metrics prefix", :type => :string, :default => Socket.gethostname
16
17
  opt :dry_run, "Dry run", :type => :boolean, :default => false
17
18
  opt :verbose, "Verbose", :type => :boolean, :default => false
18
19
  end
@@ -2,14 +2,14 @@ module Mongodb
2
2
  module Graphite
3
3
  module Agent
4
4
  class GraphiteWriter
5
- def initialize(host, port, verbose)
6
- @graphite = ::Graphite.new({:host => host, :port => port})
7
- @verbose = verbose
5
+ def initialize(opts)
6
+ @graphite = ::Graphite.new({:host => opts[:host], :port => opts[:port]})
7
+ @opts = opts
8
8
  end
9
9
 
10
10
  def write(metric_hash)
11
- @metric_hash_with_hostname = Hash[metric_hash.map { |k,v| ["#{Socket.gethostname}.mongodb.#{k}", v]}]
12
- if @verbose
11
+ @metric_hash_with_hostname = Hash[metric_hash.map { |k,v| ["#{@opts[:metrics_prefix]}.#{k}", v]}]
12
+ if @opts[:verbose]
13
13
  puts "Sending data to graphite..."
14
14
  ap @metric_hash_with_hostname
15
15
  end
@@ -1,7 +1,7 @@
1
1
  module Mongodb
2
2
  module Graphite
3
3
  module Agent
4
- VERSION = "0.0.5"
4
+ VERSION = "0.0.6"
5
5
  end
6
6
  end
7
7
  end
@@ -40,7 +40,10 @@ module Mongodb
40
40
 
41
41
 
42
42
  unless (@opts[:dry_run])
43
- graphite_writer = GraphiteWriter.new(@opts[:graphite_host], @opts[:graphite_port], @opts[:verbose])
43
+ graphite_writer = GraphiteWriter.new({:host => @opts[:graphite_host],
44
+ :port => @opts[:graphite_port],
45
+ :verbose => @opts[:verbose],
46
+ :metrics_prefix => @opts[:graphite_metrics_prefix]})
44
47
  graphite_writer.write(metric_hash)
45
48
  graphite_writer.write(opcounters_per_second_metric_hash)
46
49
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongodb-graphite-agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: