bipbip 0.5.17 → 0.5.18
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 +14 -7
- data/lib/bipbip/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07a183a1ec6d671c1fd72f5874607a68a7799408
|
4
|
+
data.tar.gz: 15e9ab0331b98776ac0fdba6c7cd7c5838dddc80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 686f19d252febc67ac1d5592211c277da737b464c3c645ca56b709aac7fff7efc435593b9005d6e3d323ecf45499efde172e99e548f9e5640e753183f5e862af
|
7
|
+
data.tar.gz: f0933411816db888b9a6aa249efa69b1bd68c07e6da36f49326f26c4d7a0ad7048201763b42d0a7772b1a9f069bdb1fcd673fcbba343b4e564279fabe66b115d
|
@@ -22,6 +22,7 @@ module Bipbip
|
|
22
22
|
{:name => 'replication_lag', :type => 'gauge', :unit => 'Seconds'},
|
23
23
|
{:name => 'slow_queries_count', :type => 'gauge_f', :unit => 'Queries'},
|
24
24
|
{:name => 'slow_queries_time_avg', :type => 'gauge_f', :unit => 'Seconds'},
|
25
|
+
{:name => 'slow_queries_time_max', :type => 'gauge_f', :unit => 'Seconds'},
|
25
26
|
]
|
26
27
|
end
|
27
28
|
|
@@ -64,8 +65,9 @@ module Bipbip
|
|
64
65
|
data['replication_lag'] = replication_lag
|
65
66
|
end
|
66
67
|
|
67
|
-
data['slow_queries_count'] = slow_queries_status['
|
68
|
-
data['slow_queries_time_avg'] = slow_queries_status['
|
68
|
+
data['slow_queries_count'] = slow_queries_status['total']['count']
|
69
|
+
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
|
70
|
+
data['slow_queries_time_max'] = slow_queries_status['max']['time']
|
69
71
|
|
70
72
|
data
|
71
73
|
end
|
@@ -113,24 +115,29 @@ module Bipbip
|
|
113
115
|
database_names_ignore = ['admin', 'system']
|
114
116
|
database_list = (mongodb_client.database_names - database_names_ignore).map { |name| mongodb_database(name) }
|
115
117
|
|
116
|
-
stats = database_list.reduce({'
|
118
|
+
stats = database_list.reduce({'total' => {'count' => 0, 'time' => 0}, 'max' => {'time' => 0}}) do |memo, database|
|
117
119
|
|
118
120
|
results = database.collection('system.profile').aggregate(
|
119
121
|
[
|
120
122
|
{'$match' => {'millis' => {'$gte' => slow_query_threshold}, 'ts' => {'$gt' => timestamp_last_check}}},
|
121
|
-
{'$group' => {'_id' => 'null', 'total_count' => {'$sum' => 1}, 'total_time' => {'$sum' => '$millis'}}}
|
123
|
+
{'$group' => {'_id' => 'null', 'total_count' => {'$sum' => 1}, 'total_time' => {'$sum' => '$millis'}, 'max_time' => {'$max' => '$millis'}}}
|
122
124
|
])
|
123
125
|
|
124
126
|
unless results.empty?
|
125
127
|
result = results.pop
|
126
|
-
|
127
|
-
|
128
|
+
max_time = result['max_time'].to_f/1000
|
129
|
+
|
130
|
+
memo['total']['count'] += result['total_count']
|
131
|
+
memo['total']['time'] += result['total_time'].to_f/1000
|
132
|
+
memo['max']['time'] = max_time if memo['max']['time'] < max_time
|
128
133
|
end
|
129
134
|
|
130
135
|
memo
|
131
136
|
end
|
132
137
|
|
133
|
-
stats.each { |metric, value| stats[metric] = value/time_period }
|
138
|
+
stats['total'].each { |metric, value| stats['total'][metric] = value/time_period }
|
139
|
+
|
140
|
+
stats
|
134
141
|
end
|
135
142
|
|
136
143
|
def replication_lag
|
data/lib/bipbip/version.rb
CHANGED