mongodb-graphite-agent 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +20 -20
- data/.travis.yml +7 -0
- data/Gemfile +2 -2
- data/README.md +21 -29
- data/Rakefile +6 -0
- data/bin/mongodb-graphite-agent.rb +28 -27
- data/lib/mongodb/graphite/agent.rb +81 -81
- data/lib/mongodb/graphite/agent/graphite_writer.rb +21 -21
- data/lib/mongodb/graphite/agent/mongo_cient_extensions.rb +15 -15
- data/lib/mongodb/graphite/agent/op_counters_sample.rb +25 -25
- data/lib/mongodb/graphite/agent/utils.rb +29 -29
- data/lib/mongodb/graphite/agent/version.rb +7 -7
- data/mongodb-graphite-agent.gemspec +32 -31
- data/spec/agent_spec.rb +13 -0
- data/spec/op_counters_sample_spec.rb +17 -0
- metadata +25 -10
data/.gitignore
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
*.gem
|
2
|
-
*.rbc
|
3
|
-
.bundle
|
4
|
-
.config
|
5
|
-
.yardoc
|
6
|
-
Gemfile.lock
|
7
|
-
InstalledFiles
|
8
|
-
_yardoc
|
9
|
-
coverage
|
10
|
-
doc/
|
11
|
-
lib/bundler/man
|
12
|
-
pkg
|
13
|
-
rdoc
|
14
|
-
spec/reports
|
15
|
-
test/tmp
|
16
|
-
test/version_tmp
|
17
|
-
tmp
|
18
|
-
.idea/*
|
19
|
-
lastsample
|
20
|
-
*.iml
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
.idea/*
|
19
|
+
lastsample
|
20
|
+
*.iml
|
data/.travis.yml
ADDED
data/Gemfile
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
3
|
gemspec
|
data/README.md
CHANGED
@@ -1,29 +1,21 @@
|
|
1
|
-
# Mongodb::Graphite::Agent
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
gem
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
## Contributing
|
24
|
-
|
25
|
-
1. Fork it
|
26
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
-
5. Create new Pull Request
|
1
|
+
# Mongodb::Graphite::Agent
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/emmekappa/mongodb-graphite-agent.png)](https://travis-ci.org/emmekappa/mongodb-graphite-agent)
|
4
|
+
|
5
|
+
Sends MongoDB metrics to Graphite.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
$ gem install mongodb-graphite-agent
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
mongodb-graphite-agent.rb --mongodb-host localhost --graphite-host graphite.local --graphite-port 9090 --graphite-metrics-prefix "localhost.mongodb" --verbose
|
14
|
+
|
15
|
+
## Contributing
|
16
|
+
|
17
|
+
1. Fork it
|
18
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
19
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
20
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
21
|
+
5. Create new Pull Request
|
data/Rakefile
CHANGED
@@ -1,28 +1,29 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
$:.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib")
|
4
|
-
|
5
|
-
require 'trollop'
|
6
|
-
require 'mongodb/graphite/agent'
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
opt :
|
11
|
-
opt :
|
12
|
-
opt :
|
13
|
-
opt :
|
14
|
-
opt :
|
15
|
-
opt :
|
16
|
-
opt :
|
17
|
-
opt :
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$:.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib")
|
4
|
+
|
5
|
+
require 'trollop'
|
6
|
+
require 'mongodb/graphite/agent'
|
7
|
+
require 'mongodb/graphite/agent/graphite_writer'
|
8
|
+
|
9
|
+
opts = Trollop::options do
|
10
|
+
opt :mongodb_username, "MongoDB username", :type => :string
|
11
|
+
opt :mongodb_host, "MongoDB host", :type => :string, :default => "localhost"
|
12
|
+
opt :mongodb_post, "MongoDB port", :type => :int, :default => 27017
|
13
|
+
opt :mongodb_password, "MongoDB password", :type => :string
|
14
|
+
opt :graphite_host, "Graphite host", :type => :string
|
15
|
+
opt :graphite_port, "Graphite port", :type => :string
|
16
|
+
opt :graphite_metrics_prefix, "Graphite metrics prefix", :type => :string, :default => Socket.gethostname
|
17
|
+
opt :dry_run, "Dry run", :type => :boolean, :default => false
|
18
|
+
opt :verbose, "Verbose", :type => :boolean, :default => false
|
19
|
+
end
|
20
|
+
|
21
|
+
if opts[:dry_run]
|
22
|
+
puts "\n\nWARNING!!! This is a dry run\n\n\n"
|
23
|
+
sleep 1
|
24
|
+
end
|
25
|
+
|
26
|
+
Trollop::die :graphite_host, "(or --dry-run) must be specified" if (opts[:graphite_host].blank? and opts[:dry_run].blank?)
|
27
|
+
|
28
|
+
runner = Mongodb::Graphite::Agent::Runner.new(opts)
|
28
29
|
runner.run
|
@@ -1,82 +1,82 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'bundler/setup'
|
3
|
-
require 'mongo'
|
4
|
-
require 'simple-graphite'
|
5
|
-
require 'bson'
|
6
|
-
require 'socket'
|
7
|
-
require 'awesome_print'
|
8
|
-
require 'time_difference'
|
9
|
-
require 'mongodb/graphite/agent/utils'
|
10
|
-
require 'mongodb/graphite/agent/op_counters_sample'
|
11
|
-
require 'mongodb/graphite/agent/mongo_cient_extensions'
|
12
|
-
|
13
|
-
module Mongodb
|
14
|
-
module Graphite
|
15
|
-
module Agent
|
16
|
-
class Runner
|
17
|
-
|
18
|
-
def initialize(opts)
|
19
|
-
@opts = opts
|
20
|
-
end
|
21
|
-
|
22
|
-
def run
|
23
|
-
connection = Mongo::MongoClient.new(@opts
|
24
|
-
unless (@opts[:mongodb_username].blank? && @opts[:mongodb_password].blank?)
|
25
|
-
connection["admin"].authenticate(@opts.mongodb_username, @opts.mongodb_password)
|
26
|
-
end
|
27
|
-
|
28
|
-
server_status_result = connection["local"].command('serverStatus' => 1)
|
29
|
-
metric_hash = Utils.to_hash(server_status_result).select { |k|
|
30
|
-
k.match('^connection|^network\.|^cursors|^mem\.mapped|^indexCounters|^repl.oplog')
|
31
|
-
}
|
32
|
-
|
33
|
-
opcounters_per_second_metric_hash = calculate_opcounters_per_second server_status_result["opcounters"]
|
34
|
-
|
35
|
-
if @opts[:verbose]
|
36
|
-
puts "Calculating metrics..."
|
37
|
-
ap metric_hash
|
38
|
-
ap opcounters_per_second_metric_hash
|
39
|
-
end
|
40
|
-
|
41
|
-
|
42
|
-
unless (@opts[:dry_run])
|
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]})
|
47
|
-
graphite_writer.write(metric_hash)
|
48
|
-
graphite_writer.write(opcounters_per_second_metric_hash)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def calculate_opcounters_per_second(opcounters)
|
53
|
-
current_sample = OpCountersSample.new Hash[opcounters]
|
54
|
-
previous_sample = current_sample.dup
|
55
|
-
result = {}
|
56
|
-
|
57
|
-
if File.exist? 'lastsample'
|
58
|
-
File.open('lastsample', 'r') do |file|
|
59
|
-
previous_sample = Marshal.load(file)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
delta = TimeDifference.between(Time.parse(current_sample.sample_time), Time.parse(previous_sample.sample_time))
|
64
|
-
puts "Last sample was taken #{delta.in_seconds.round(0)} seconds ago"
|
65
|
-
|
66
|
-
previous_sample.values.keys.sort.each do |k|
|
67
|
-
previous_sample_value = previous_sample.values[k]
|
68
|
-
current_sample_value = current_sample.values[k]
|
69
|
-
value_per_seconds = ((current_sample_value - previous_sample_value) / delta.in_seconds).round(2)
|
70
|
-
result["#{k}_per_seconds"] = value_per_seconds
|
71
|
-
end
|
72
|
-
|
73
|
-
File.open('lastsample', 'w') do |file|
|
74
|
-
Marshal.dump(current_sample, file)
|
75
|
-
end
|
76
|
-
|
77
|
-
result
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
require 'mongo'
|
4
|
+
require 'simple-graphite'
|
5
|
+
require 'bson'
|
6
|
+
require 'socket'
|
7
|
+
require 'awesome_print'
|
8
|
+
require 'time_difference'
|
9
|
+
require 'mongodb/graphite/agent/utils'
|
10
|
+
require 'mongodb/graphite/agent/op_counters_sample'
|
11
|
+
require 'mongodb/graphite/agent/mongo_cient_extensions'
|
12
|
+
|
13
|
+
module Mongodb
|
14
|
+
module Graphite
|
15
|
+
module Agent
|
16
|
+
class Runner
|
17
|
+
|
18
|
+
def initialize(opts)
|
19
|
+
@opts = opts
|
20
|
+
end
|
21
|
+
|
22
|
+
def run
|
23
|
+
connection = Mongo::MongoClient.new(@opts[:mongodb_host], @opts[:mongodb_port], :slave_ok => true)
|
24
|
+
unless (@opts[:mongodb_username].blank? && @opts[:mongodb_password].blank?)
|
25
|
+
connection["admin"].authenticate(@opts.mongodb_username, @opts.mongodb_password)
|
26
|
+
end
|
27
|
+
|
28
|
+
server_status_result = connection["local"].command('serverStatus' => 1)
|
29
|
+
metric_hash = Utils.to_hash(server_status_result).select { |k|
|
30
|
+
k.match('^connection|^network\.|^cursors|^mem\.mapped|^indexCounters|^repl.oplog')
|
31
|
+
}
|
32
|
+
|
33
|
+
opcounters_per_second_metric_hash = calculate_opcounters_per_second server_status_result["opcounters"]
|
34
|
+
|
35
|
+
if @opts[:verbose]
|
36
|
+
puts "Calculating metrics..."
|
37
|
+
ap metric_hash
|
38
|
+
ap opcounters_per_second_metric_hash
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
unless (@opts[:dry_run])
|
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]})
|
47
|
+
graphite_writer.write(metric_hash)
|
48
|
+
graphite_writer.write(opcounters_per_second_metric_hash)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def calculate_opcounters_per_second(opcounters)
|
53
|
+
current_sample = OpCountersSample.new Hash[opcounters]
|
54
|
+
previous_sample = current_sample.dup
|
55
|
+
result = {}
|
56
|
+
|
57
|
+
if File.exist? 'lastsample'
|
58
|
+
File.open('lastsample', 'r') do |file|
|
59
|
+
previous_sample = Marshal.load(file)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
delta = TimeDifference.between(Time.parse(current_sample.sample_time), Time.parse(previous_sample.sample_time))
|
64
|
+
puts "Last sample was taken #{delta.in_seconds.round(0)} seconds ago"
|
65
|
+
|
66
|
+
previous_sample.values.keys.sort.each do |k|
|
67
|
+
previous_sample_value = previous_sample.values[k]
|
68
|
+
current_sample_value = current_sample.values[k]
|
69
|
+
value_per_seconds = ((current_sample_value - previous_sample_value) / delta.in_seconds).round(2)
|
70
|
+
result["#{k}_per_seconds"] = value_per_seconds
|
71
|
+
end
|
72
|
+
|
73
|
+
File.open('lastsample', 'w') do |file|
|
74
|
+
Marshal.dump(current_sample, file)
|
75
|
+
end
|
76
|
+
|
77
|
+
result
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
82
|
end
|
@@ -1,21 +1,21 @@
|
|
1
|
-
module Mongodb
|
2
|
-
module Graphite
|
3
|
-
module Agent
|
4
|
-
class GraphiteWriter
|
5
|
-
def initialize(opts)
|
6
|
-
@graphite = ::Graphite.new({:host => opts[:host], :port => opts[:port]})
|
7
|
-
@opts = opts
|
8
|
-
end
|
9
|
-
|
10
|
-
def write(metric_hash)
|
11
|
-
@metric_hash_with_hostname = Hash[metric_hash.map { |k,v| ["#{@opts[:metrics_prefix]}.#{k}", v]}]
|
12
|
-
if @opts[:verbose]
|
13
|
-
puts "Sending data to graphite..."
|
14
|
-
ap @metric_hash_with_hostname
|
15
|
-
end
|
16
|
-
@graphite.send_metrics @metric_hash_with_hostname
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
1
|
+
module Mongodb
|
2
|
+
module Graphite
|
3
|
+
module Agent
|
4
|
+
class GraphiteWriter
|
5
|
+
def initialize(opts)
|
6
|
+
@graphite = ::Graphite.new({:host => opts[:host], :port => opts[:port]})
|
7
|
+
@opts = opts
|
8
|
+
end
|
9
|
+
|
10
|
+
def write(metric_hash)
|
11
|
+
@metric_hash_with_hostname = Hash[metric_hash.map { |k,v| ["#{@opts[:metrics_prefix]}.#{k}", v]}]
|
12
|
+
if @opts[:verbose]
|
13
|
+
puts "Sending data to graphite..."
|
14
|
+
ap @metric_hash_with_hostname
|
15
|
+
end
|
16
|
+
@graphite.send_metrics @metric_hash_with_hostname
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -1,15 +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
|
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
|
@@ -1,26 +1,26 @@
|
|
1
|
-
require 'date'
|
2
|
-
|
3
|
-
module Mongodb
|
4
|
-
module Graphite
|
5
|
-
module Agent
|
6
|
-
|
7
|
-
class OpCountersSample
|
8
|
-
attr_reader :values, :sample_time
|
9
|
-
|
10
|
-
def initialize(values, sample_time = DateTime.now.to_s)
|
11
|
-
@values = values
|
12
|
-
@sample_time = sample_time
|
13
|
-
end
|
14
|
-
|
15
|
-
def marshal_dump
|
16
|
-
[@sample_time, @values]
|
17
|
-
end
|
18
|
-
|
19
|
-
def marshal_load array
|
20
|
-
@sample_time, @values = array
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
1
|
+
require 'date'
|
2
|
+
|
3
|
+
module Mongodb
|
4
|
+
module Graphite
|
5
|
+
module Agent
|
6
|
+
|
7
|
+
class OpCountersSample
|
8
|
+
attr_reader :values, :sample_time
|
9
|
+
|
10
|
+
def initialize(values, sample_time = DateTime.now.to_s)
|
11
|
+
@values = values
|
12
|
+
@sample_time = sample_time
|
13
|
+
end
|
14
|
+
|
15
|
+
def marshal_dump
|
16
|
+
[@sample_time, @values]
|
17
|
+
end
|
18
|
+
|
19
|
+
def marshal_load array
|
20
|
+
@sample_time, @values = array
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
26
|
end
|
@@ -1,29 +1,29 @@
|
|
1
|
-
module Mongodb
|
2
|
-
module Graphite
|
3
|
-
module Agent
|
4
|
-
|
5
|
-
module Utils
|
6
|
-
def self.merge_all
|
7
|
-
self.inject({}) { |h1, h2|
|
8
|
-
h1.merge! h2
|
9
|
-
}
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.json_descent(pre, json)
|
13
|
-
json.map do |k, v|
|
14
|
-
key = pre + [k]
|
15
|
-
if v.is_a? BSON::OrderedHash
|
16
|
-
json_descent(key, v)
|
17
|
-
else
|
18
|
-
{key.join('.') => v}
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.to_hash(s)
|
24
|
-
json_descent([], s).flatten.reduce Hash.new, :merge
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
1
|
+
module Mongodb
|
2
|
+
module Graphite
|
3
|
+
module Agent
|
4
|
+
|
5
|
+
module Utils
|
6
|
+
def self.merge_all
|
7
|
+
self.inject({}) { |h1, h2|
|
8
|
+
h1.merge! h2
|
9
|
+
}
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.json_descent(pre, json)
|
13
|
+
json.map do |k, v|
|
14
|
+
key = pre + [k]
|
15
|
+
if v.is_a? BSON::OrderedHash
|
16
|
+
json_descent(key, v)
|
17
|
+
else
|
18
|
+
{key.join('.') => v}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.to_hash(s)
|
24
|
+
json_descent([], s).flatten.reduce Hash.new, :merge
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
module Mongodb
|
2
|
-
module Graphite
|
3
|
-
module Agent
|
4
|
-
VERSION = "0.1.
|
5
|
-
end
|
6
|
-
end
|
7
|
-
end
|
1
|
+
module Mongodb
|
2
|
+
module Graphite
|
3
|
+
module Agent
|
4
|
+
VERSION = "0.1.2"
|
5
|
+
end
|
6
|
+
end
|
7
|
+
end
|
@@ -1,31 +1,32 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'mongodb/graphite/agent/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "mongodb-graphite-agent"
|
8
|
-
spec.version = Mongodb::Graphite::Agent::VERSION
|
9
|
-
spec.authors = ["Michele Cantelli"]
|
10
|
-
spec.email = ["michele.cantelli@jobrapido.com"]
|
11
|
-
spec.description = ""
|
12
|
-
spec.summary = ""
|
13
|
-
spec.homepage = "https://github.com/emmekappa/mongodb-graphite-agent"
|
14
|
-
spec.license = "MIT"
|
15
|
-
|
16
|
-
spec.files = `git ls-files`.split($/)
|
17
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = ["lib"]
|
20
|
-
|
21
|
-
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
-
spec.add_development_dependency "rake"
|
23
|
-
|
24
|
-
|
25
|
-
spec.add_dependency '
|
26
|
-
spec.add_dependency '
|
27
|
-
spec.add_dependency '
|
28
|
-
spec.add_dependency '
|
29
|
-
spec.add_dependency '
|
30
|
-
spec.add_dependency '
|
31
|
-
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'mongodb/graphite/agent/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "mongodb-graphite-agent"
|
8
|
+
spec.version = Mongodb::Graphite::Agent::VERSION
|
9
|
+
spec.authors = ["Michele Cantelli"]
|
10
|
+
spec.email = ["michele.cantelli@jobrapido.com"]
|
11
|
+
spec.description = ""
|
12
|
+
spec.summary = ""
|
13
|
+
spec.homepage = "https://github.com/emmekappa/mongodb-graphite-agent"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec"
|
24
|
+
|
25
|
+
spec.add_dependency 'mongo'
|
26
|
+
spec.add_dependency 'simple-graphite'
|
27
|
+
spec.add_dependency 'bson'
|
28
|
+
spec.add_dependency 'bson_ext'
|
29
|
+
spec.add_dependency 'awesome_print'
|
30
|
+
spec.add_dependency 'time_difference'
|
31
|
+
spec.add_dependency 'trollop'
|
32
|
+
end
|
data/spec/agent_spec.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'mongodb/graphite/agent'
|
3
|
+
|
4
|
+
describe 'MongoDB Server Status' do
|
5
|
+
|
6
|
+
it 'should read server status' do
|
7
|
+
|
8
|
+
#To change this template use File | Settings | File Templates.
|
9
|
+
runner = Mongodb::Graphite::Agent::Runner.new({ :mongodb_host => 'localhost', :mongodb_port => '27017', :dry_run => true, :verbose => true})
|
10
|
+
runner.run
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'mongodb/graphite/agent/op_counters_sample'
|
3
|
+
|
4
|
+
describe 'OpCounters' do
|
5
|
+
it 'should reload last sample' do
|
6
|
+
current_sample = Mongodb::Graphite::Agent::OpCountersSample.new(100)
|
7
|
+
|
8
|
+
File.open('lastsample-test', 'w') do |file|
|
9
|
+
Marshal.dump(current_sample, file)
|
10
|
+
end
|
11
|
+
|
12
|
+
File.open('lastsample-test', 'r') do |file|
|
13
|
+
previous_sample = Marshal.load(file)
|
14
|
+
previous_sample.values.should eq(100)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
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.1.
|
4
|
+
version: 0.1.2
|
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-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -43,6 +43,22 @@ dependencies:
|
|
43
43
|
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
46
62
|
- !ruby/object:Gem::Dependency
|
47
63
|
name: mongo
|
48
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -164,6 +180,7 @@ extensions: []
|
|
164
180
|
extra_rdoc_files: []
|
165
181
|
files:
|
166
182
|
- .gitignore
|
183
|
+
- .travis.yml
|
167
184
|
- Gemfile
|
168
185
|
- LICENSE.txt
|
169
186
|
- README.md
|
@@ -176,6 +193,8 @@ files:
|
|
176
193
|
- lib/mongodb/graphite/agent/utils.rb
|
177
194
|
- lib/mongodb/graphite/agent/version.rb
|
178
195
|
- mongodb-graphite-agent.gemspec
|
196
|
+
- spec/agent_spec.rb
|
197
|
+
- spec/op_counters_sample_spec.rb
|
179
198
|
homepage: https://github.com/emmekappa/mongodb-graphite-agent
|
180
199
|
licenses:
|
181
200
|
- MIT
|
@@ -189,22 +208,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
189
208
|
- - ! '>='
|
190
209
|
- !ruby/object:Gem::Version
|
191
210
|
version: '0'
|
192
|
-
segments:
|
193
|
-
- 0
|
194
|
-
hash: 2967853814840194051
|
195
211
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
196
212
|
none: false
|
197
213
|
requirements:
|
198
214
|
- - ! '>='
|
199
215
|
- !ruby/object:Gem::Version
|
200
216
|
version: '0'
|
201
|
-
segments:
|
202
|
-
- 0
|
203
|
-
hash: 2967853814840194051
|
204
217
|
requirements: []
|
205
218
|
rubyforge_project:
|
206
|
-
rubygems_version: 1.8.
|
219
|
+
rubygems_version: 1.8.24
|
207
220
|
signing_key:
|
208
221
|
specification_version: 3
|
209
222
|
summary: ''
|
210
|
-
test_files:
|
223
|
+
test_files:
|
224
|
+
- spec/agent_spec.rb
|
225
|
+
- spec/op_counters_sample_spec.rb
|