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 +4 -4
- data/lib/bipbip/plugin.rb +1 -2
- data/lib/bipbip/plugin/log_parser.rb +4 -2
- data/lib/bipbip/plugin/mongodb.rb +9 -10
- data/lib/bipbip/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed5dd8b5457dc9bf2b7542ffc50667195f588742
|
4
|
+
data.tar.gz: f7f8a323faf65296263a40b056f56b0708862812
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
48
|
+
file_stat = File.stat(config['path'])
|
49
|
+
raise "Cannot read file `#{config['path']}`" unless file_stat.readable?
|
49
50
|
@lines = []
|
50
|
-
@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::
|
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::
|
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
|
-
|
93
|
-
|
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
|
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.
|
127
|
-
result = results.
|
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']
|
data/lib/bipbip/version.rb
CHANGED
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.
|
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-
|
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:
|
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:
|
126
|
+
version: 2.0.5
|
127
127
|
- !ruby/object:Gem::Dependency
|
128
|
-
name:
|
128
|
+
name: bson
|
129
129
|
requirement: !ruby/object:Gem::Requirement
|
130
130
|
requirements:
|
131
131
|
- - "~>"
|
132
132
|
- !ruby/object:Gem::Version
|
133
|
-
version:
|
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:
|
140
|
+
version: 3.0.3
|
141
141
|
- !ruby/object:Gem::Dependency
|
142
142
|
name: rb-inotify
|
143
143
|
requirement: !ruby/object:Gem::Requirement
|