mongodb-graphite-agent 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
@@ -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(
|
6
|
-
@graphite = ::Graphite.new({:host => host, :port => port})
|
7
|
-
@
|
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| ["#{
|
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
|
@@ -40,7 +40,10 @@ module Mongodb
|
|
40
40
|
|
41
41
|
|
42
42
|
unless (@opts[:dry_run])
|
43
|
-
graphite_writer = GraphiteWriter.new(
|
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
|