bipbip 0.5.14 → 0.5.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bipbip/plugin/mongodb.rb +25 -11
- data/lib/bipbip/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ddfc3ddd44eded3569a8967a2ee2afbab46d874a
|
4
|
+
data.tar.gz: 97bc00b753c876da95ab4f1c0ebe4516a3409c4d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35561804f688ee6fb08154151c28b00c28e14b8885a0751c46909bcac5da4e5cfa9c7c79be1b9079dff8e214088cf92aed4e3b3db28cac37d65ebffd25c7a593
|
7
|
+
data.tar.gz: c25eb8bb521915d0a4afb6394b4bb75fe554d8b067263f95e322b62862111a8527d15ee8630a50c77d00fb05167c0f9fa9eec3ef808aa701ae4bd349c27245e8
|
@@ -20,7 +20,8 @@ module Bipbip
|
|
20
20
|
{:name => 'mem_pagefaults', :type => 'counter', :unit => 'faults'},
|
21
21
|
{:name => 'globalLock_currentQueue', :type => 'gauge'},
|
22
22
|
{:name => 'replication_lag', :type => 'gauge', :unit => 'Seconds'},
|
23
|
-
{:name => '
|
23
|
+
{:name => 'slow_queries_count', :type => 'gauge', :unit => 'Queries'},
|
24
|
+
{:name => 'slow_queries_time_avg', :type => 'gauge', :unit => 'Seconds'},
|
24
25
|
]
|
25
26
|
end
|
26
27
|
|
@@ -28,6 +29,7 @@ module Bipbip
|
|
28
29
|
@mongodb_client = nil
|
29
30
|
|
30
31
|
status = fetch_server_status
|
32
|
+
slow_queries_status = fetch_slow_queries_status
|
31
33
|
|
32
34
|
data = {}
|
33
35
|
|
@@ -62,7 +64,8 @@ module Bipbip
|
|
62
64
|
data['replication_lag'] = replication_lag
|
63
65
|
end
|
64
66
|
|
65
|
-
data['
|
67
|
+
data['slow_queries_count'] = slow_queries_status['total_count']
|
68
|
+
data['slow_queries_time_avg'] = slow_queries_status['total_count'] > 0 ? (slow_queries_status['total_time'].to_f/slow_queries_status['total_count'].to_f) : 0
|
66
69
|
|
67
70
|
data
|
68
71
|
end
|
@@ -103,20 +106,31 @@ module Bipbip
|
|
103
106
|
old
|
104
107
|
end
|
105
108
|
|
106
|
-
def
|
109
|
+
def fetch_slow_queries_status
|
107
110
|
timestamp_last_check = slow_query_last_check
|
111
|
+
time_period = Time.now - timestamp_last_check
|
108
112
|
|
109
|
-
|
113
|
+
database_names_ignore = ['admin', 'system']
|
114
|
+
database_list = (mongodb_client.database_names - database_names_ignore).map { |name| mongodb_database(name) }
|
110
115
|
|
111
|
-
(
|
112
|
-
end
|
116
|
+
stats = database_list.reduce({'total_count' => 0, 'total_time' => 0}) do |memo, database|
|
113
117
|
|
114
|
-
|
115
|
-
|
116
|
-
|
118
|
+
results = database.collection('system.profile').aggregate(
|
119
|
+
[
|
120
|
+
{'$match' => {'millis' => {'$gte' => slow_query_threshold}, 'ts' => {'$gt' => timestamp_last_check}}},
|
121
|
+
{'$group' => {'_id' => 'null', 'total_count' => {'$sum' => 1}, 'total_time' => {'$sum' => '$millis'}}}
|
122
|
+
])
|
117
123
|
|
118
|
-
|
119
|
-
|
124
|
+
unless results.empty?
|
125
|
+
result = results.pop
|
126
|
+
memo['total_count'] += result['total_count']
|
127
|
+
memo['total_time'] += result['total_time'].to_f/1000
|
128
|
+
end
|
129
|
+
|
130
|
+
memo
|
131
|
+
end
|
132
|
+
|
133
|
+
stats.each { |metric, value| stats[metric] = value/time_period }
|
120
134
|
end
|
121
135
|
|
122
136
|
def replication_lag
|
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.5.
|
4
|
+
version: 0.5.15
|
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-01-
|
13
|
+
date: 2015-01-23 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: copperegg
|