bipbip 0.6.1 → 0.6.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: db42c48899ca1b505940c48ee73bb1c3b63c1bc5
4
- data.tar.gz: 8148d92d85f7654f58050188a0868d4231480ca4
3
+ metadata.gz: ed5dd8b5457dc9bf2b7542ffc50667195f588742
4
+ data.tar.gz: f7f8a323faf65296263a40b056f56b0708862812
5
5
  SHA512:
6
- metadata.gz: 015d0a47ea3ed3d61c0e1b076b0c49e521fd1438a65c8f437d4cc0e3789dcd960d45c8db2d80f3d5dfb65bf071a0e4dd25b9c0121659c94c7406b532f8cb004f
7
- data.tar.gz: cf50716d8156361d0795a62b307f1bf731be6d5a8ab812ee3b0cc72116be867f89ccc9735d1f977fa69ff02ff527468be71a07fdc7a1160c37b4ca42b3a6cb71
6
+ metadata.gz: 7f79b1e624132364c18f7a82831d73d18b5f074ff84a9d944f2f077936b3b6a9cf2af154fd1d74ee75bffdeee7f2d7a64bf3809c22317e12751f448a4425082d
7
+ data.tar.gz: efc5c47e03a5026c5a717a28a20e4d0de03c43292fed109b3163320910ac4e9548c9df0348db621a77c7b0c245bb197f824536af11a1c27b39fae394297f1807
data/lib/bipbip/plugin.rb CHANGED
@@ -21,8 +21,7 @@ module Bipbip
21
21
  # @param [Bipbip::Plugin] plugin
22
22
  # @return [Bipbip::Plugin]
23
23
  def self.factory_from_plugin(plugin)
24
- class_name = plugin.class.name.gsub(/^Bipbip::/, '')
25
- Bipbip::const_get(class_name).new(plugin.name, plugin.config, plugin.frequency, plugin.tags, plugin.metric_group)
24
+ plugin.class.new(plugin.name, plugin.config, plugin.frequency, plugin.tags, plugin.metric_group)
26
25
  end
27
26
 
28
27
  def initialize(name, config, frequency, tags = nil, metric_group = nil)
@@ -45,9 +45,11 @@ module Bipbip
45
45
 
46
46
  def notifier
47
47
  if @notifier.nil?
48
- @notifier = create_notifier
48
+ file_stat = File.stat(config['path'])
49
+ raise "Cannot read file `#{config['path']}`" unless file_stat.readable?
49
50
  @lines = []
50
- @size = File.stat(config['path']).size
51
+ @size = file_stat.size
52
+ @notifier = create_notifier
51
53
  end
52
54
  @notifier
53
55
  end
@@ -78,28 +78,27 @@ module Bipbip
78
78
  config['slow_query_threshold'] || 0
79
79
  end
80
80
 
81
- # @return [Mongo::MongoClient]
81
+ # @return [Mongo::Client]
82
82
  def mongodb_client
83
83
  options = {
84
84
  'hostname' => 'localhost',
85
85
  'port' => 27017,
86
86
  }.merge(config)
87
- @mongodb_client ||= Mongo::MongoClient.new(options['hostname'], options['port'], {:op_timeout => 2, :slave_ok => true})
87
+ @mongodb_client ||= Mongo::Client.new([options['hostname'] + ':' + options['port'].to_s], :socket_timeout => 2, :slave_ok => true)
88
88
  end
89
89
 
90
90
  # @return [Mongo::DB]
91
91
  def mongodb_database(db_name)
92
- db = mongodb_client.db(db_name)
93
- db.authenticate(config['username'], config['password']) unless config['password'].nil?
94
- db
92
+ mongodb_client.with(config['username'], config['password']) unless config['password'].nil?
93
+ mongodb_client.use(db_name)
95
94
  end
96
95
 
97
96
  def fetch_server_status
98
- mongodb_database('admin').command('serverStatus' => 1)
97
+ mongodb_database('admin').command('serverStatus' => 1).documents.first
99
98
  end
100
99
 
101
100
  def fetch_replica_status
102
- mongodb_database('admin').command('replSetGetStatus' => 1)
101
+ mongodb_database('admin').command('replSetGetStatus' => 1).documents.first
103
102
  end
104
103
 
105
104
  def slow_query_last_check
@@ -117,14 +116,14 @@ module Bipbip
117
116
 
118
117
  stats = database_list.reduce({'total' => {'count' => 0, 'time' => 0}, 'max' => {'time' => 0}}) do |memo, database|
119
118
 
120
- results = database.collection('system.profile').aggregate(
119
+ results = database['system.profile'].find.aggregate(
121
120
  [
122
121
  {'$match' => {'millis' => {'$gte' => slow_query_threshold}, 'ts' => {'$gt' => timestamp_last_check}}},
123
122
  {'$group' => {'_id' => 'null', 'total_count' => {'$sum' => 1}, 'total_time' => {'$sum' => '$millis'}, 'max_time' => {'$max' => '$millis'}}}
124
123
  ])
125
124
 
126
- unless results.empty?
127
- result = results.pop
125
+ unless results.count == 0
126
+ result = results.first
128
127
  max_time = result['max_time'].to_f/1000
129
128
 
130
129
  memo['total']['count'] += result['total_count']
@@ -1,3 +1,3 @@
1
1
  module Bipbip
2
- VERSION = '0.6.1'
2
+ VERSION = '0.6.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bipbip
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cargo Media
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-04-21 00:00:00.000000000 Z
13
+ date: 2015-06-19 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: copperegg-revealmetrics
@@ -116,28 +116,28 @@ dependencies:
116
116
  requirements:
117
117
  - - "~>"
118
118
  - !ruby/object:Gem::Version
119
- version: '1.10'
119
+ version: 2.0.5
120
120
  type: :runtime
121
121
  prerelease: false
122
122
  version_requirements: !ruby/object:Gem::Requirement
123
123
  requirements:
124
124
  - - "~>"
125
125
  - !ruby/object:Gem::Version
126
- version: '1.10'
126
+ version: 2.0.5
127
127
  - !ruby/object:Gem::Dependency
128
- name: bson_ext
128
+ name: bson
129
129
  requirement: !ruby/object:Gem::Requirement
130
130
  requirements:
131
131
  - - "~>"
132
132
  - !ruby/object:Gem::Version
133
- version: '1.10'
133
+ version: 3.0.3
134
134
  type: :runtime
135
135
  prerelease: false
136
136
  version_requirements: !ruby/object:Gem::Requirement
137
137
  requirements:
138
138
  - - "~>"
139
139
  - !ruby/object:Gem::Version
140
- version: '1.10'
140
+ version: 3.0.3
141
141
  - !ruby/object:Gem::Dependency
142
142
  name: rb-inotify
143
143
  requirement: !ruby/object:Gem::Requirement