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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7795f64525735eeb9f518150c09193ef6c91509d
4
- data.tar.gz: dfbe46387b11a91abdef6b93c9dd096b48304d84
3
+ metadata.gz: 07a183a1ec6d671c1fd72f5874607a68a7799408
4
+ data.tar.gz: 15e9ab0331b98776ac0fdba6c7cd7c5838dddc80
5
5
  SHA512:
6
- metadata.gz: 54e3d5901fbf47de34be5b00e6d4f88b3bb50c78f1816ba4b91d2d9f7d2444fd59907dbc4290a3f129dc54ca9387dab143d654d3443e3326cbb4a55ba2bef8c6
7
- data.tar.gz: 2e4972fdf1001ed8c0ff46391aa280f1bbe1abac6af87edb836f45c84d17ae0fda83ce9f868e1641b485ffe34fe289ca100755b6876834f7c2ff56d2dea21a2e
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['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
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({'total_count' => 0, 'total_time' => 0}) do |memo, database|
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
- memo['total_count'] += result['total_count']
127
- memo['total_time'] += result['total_time'].to_f/1000
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
@@ -1,3 +1,3 @@
1
1
  module Bipbip
2
- VERSION = '0.5.17'
2
+ VERSION = '0.5.18'
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.5.17
4
+ version: 0.5.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cargo Media