mongodb-graphite-agent 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
@@ -4,14 +4,12 @@ $:.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib")
|
|
4
4
|
|
5
5
|
require 'trollop'
|
6
6
|
require 'mongodb/graphite/agent'
|
7
|
-
require 'mongodb/graphite/agent/graphite_writer'
|
8
7
|
|
9
8
|
opts = Trollop::options do
|
10
9
|
opt :mongodb_username, "MongoDB username", :type => :string
|
11
10
|
opt :mongodb_host, "MongoDB host", :type => :string, :default => "localhost"
|
12
11
|
opt :mongodb_post, "MongoDB host", :type => :int, :default => 27017
|
13
12
|
opt :mongodb_password, "MongoDB password", :type => :string
|
14
|
-
opt :mongodb_replicaset, "Set this flag if the host is part of a MongoDB replicaSet", :type => :boolean, :default => false
|
15
13
|
opt :graphite_host, "Graphite host", :type => :string
|
16
14
|
opt :graphite_port, "Graphite port", :type => :string
|
17
15
|
opt :graphite_metrics_prefix, "Graphite metrics prefix", :type => :string, :default => Socket.gethostname
|
@@ -8,6 +8,7 @@ require 'awesome_print'
|
|
8
8
|
require 'time_difference'
|
9
9
|
require 'mongodb/graphite/agent/utils'
|
10
10
|
require 'mongodb/graphite/agent/op_counters_sample'
|
11
|
+
require 'mongodb/graphite/agent/mongo_cient_extensions'
|
11
12
|
|
12
13
|
module Mongodb
|
13
14
|
module Graphite
|
@@ -29,9 +30,11 @@ module Mongodb
|
|
29
30
|
k.match('^connection|^network\.|^cursors|^mem\.mapped|^indexCounters|^repl.oplog')
|
30
31
|
}
|
31
32
|
|
32
|
-
|
33
|
+
if (connection.is_replicaset?)
|
34
|
+
puts "ReplicaSet detected" if @opts[:verbose]
|
33
35
|
opcounters_per_second_metric_hash = calculate_opcounters_per_second server_status_result["opcountersRepl"]
|
34
36
|
else
|
37
|
+
puts "Single host mode detected" if @opts[:verbose]
|
35
38
|
opcounters_per_second_metric_hash = calculate_opcounters_per_second server_status_result["opcounters"]
|
36
39
|
end
|
37
40
|
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Mongo
|
2
|
+
|
3
|
+
class MongoClient
|
4
|
+
def is_replicaset?
|
5
|
+
begin
|
6
|
+
cmd = BSON::OrderedHash.new
|
7
|
+
cmd["replSetGetStatus"] = 1
|
8
|
+
result = self.db("admin").command(cmd)
|
9
|
+
return !result["set"].blank?
|
10
|
+
rescue Mongo::OperationFailure
|
11
|
+
return false
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
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
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-07-
|
12
|
+
date: 2013-07-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -171,6 +171,7 @@ files:
|
|
171
171
|
- bin/mongodb-graphite-agent.rb
|
172
172
|
- lib/mongodb/graphite/agent.rb
|
173
173
|
- lib/mongodb/graphite/agent/graphite_writer.rb
|
174
|
+
- lib/mongodb/graphite/agent/mongo_cient_extensions.rb
|
174
175
|
- lib/mongodb/graphite/agent/op_counters_sample.rb
|
175
176
|
- lib/mongodb/graphite/agent/utils.rb
|
176
177
|
- lib/mongodb/graphite/agent/version.rb
|
@@ -190,7 +191,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
190
191
|
version: '0'
|
191
192
|
segments:
|
192
193
|
- 0
|
193
|
-
hash:
|
194
|
+
hash: 4101892219957888543
|
194
195
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
195
196
|
none: false
|
196
197
|
requirements:
|
@@ -199,7 +200,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
199
200
|
version: '0'
|
200
201
|
segments:
|
201
202
|
- 0
|
202
|
-
hash:
|
203
|
+
hash: 4101892219957888543
|
203
204
|
requirements: []
|
204
205
|
rubyforge_project:
|
205
206
|
rubygems_version: 1.8.25
|