bipbip 0.6.22 → 0.6.23

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: f33e545c81e128bad9a19a2700b5a7b91ff6183e
4
- data.tar.gz: d5a950064107b491a79d897599a396c7582a0b8e
3
+ metadata.gz: 5add0615083de3e6e65144b8d3e8595aeae99f92
4
+ data.tar.gz: cc10bece60af5768c38c579244caca1f22de048f
5
5
  SHA512:
6
- metadata.gz: f4bde45b9595343c0686575a0f0de40cd7312093fa72f46b95dfc6824435fe87645d55bf9e8d458ea0d3930355ff421d9d5b48b28f40bac7971e7b89e1921177
7
- data.tar.gz: 1598338e7a03fb49300eb8ed33f846f6f39d591581052c2c70c93dd0261c6d5d94aea5b9e1930e92edc7566f181c87ee82bc3ad1b9799c5892f5ae6625940a48
6
+ metadata.gz: d37e21902e8c5e8aa61178fb341dd7c27a7e88e6204a9cb3192bdd0b138e7cfe3e968b9cc80f2d9a303331d836fbe4858df8e11fd62727f5b967dcd01ca669af
7
+ data.tar.gz: 00678bbd5ce3c3ae3433052e3052be654182d97d6793855f59ce851873df70eef459fde451f294ade4771da87ec6bc69a51741d5b39c0113bd88ac16373242de
@@ -20,13 +20,16 @@ module Bipbip
20
20
  { name: 'replication_lag', type: 'gauge', unit: 'Seconds' },
21
21
  { name: 'slow_queries_count', type: 'gauge_f', unit: 'Queries' },
22
22
  { name: 'slow_queries_time_avg', type: 'gauge_f', unit: 'Seconds' },
23
- { name: 'slow_queries_time_max', type: 'gauge_f', unit: 'Seconds' }
23
+ { name: 'slow_queries_time_max', type: 'gauge_f', unit: 'Seconds' },
24
+ { name: 'total_index_size', type: 'gauge', unit: 'MB' },
25
+ { name: 'total_index_size_percentage_of_memory', type: 'gauge', unit: '%' }
24
26
  ]
25
27
  end
26
28
 
27
29
  def monitor
28
30
  status = fetch_server_status
29
31
  slow_queries_status = fetch_slow_queries_status
32
+ all_index_size = total_index_size
30
33
 
31
34
  data = {}
32
35
 
@@ -65,6 +68,9 @@ module Bipbip
65
68
  data['slow_queries_time_avg'] = slow_queries_status['total']['time'].to_f / (slow_queries_status['total']['count'].to_f.nonzero? || 1)
66
69
  data['slow_queries_time_max'] = slow_queries_status['max']['time']
67
70
 
71
+ data['total_index_size'] = all_index_size / (1024 * 1024)
72
+ data['total_index_size_percentage_of_memory'] = (all_index_size.to_f / total_system_memory.to_f) * 100
73
+
68
74
  data
69
75
  end
70
76
 
@@ -103,6 +109,22 @@ module Bipbip
103
109
  old
104
110
  end
105
111
 
112
+ # @return [Integer]
113
+ def total_index_size
114
+ database_names_ignore = %w(admin system local)
115
+ database_list = (mongodb_client.database_names - database_names_ignore).map { |name| mongodb_database(name) }
116
+
117
+ database_list.map do |database|
118
+ results = database.command('dbstats' => 1)
119
+ results.count == 0 ? 0 : results.documents.first['indexSize']
120
+ end.reduce(:+)
121
+ end
122
+
123
+ # @return [Integer]
124
+ def total_system_memory
125
+ `free -b`.lines.to_a[1].split[1].to_i
126
+ end
127
+
106
128
  def fetch_slow_queries_status
107
129
  timestamp_last_check = slow_query_last_check
108
130
  time_period = Time.now - timestamp_last_check
@@ -1,3 +1,3 @@
1
1
  module Bipbip
2
- VERSION = '0.6.22'
2
+ VERSION = '0.6.23'
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.22
4
+ version: 0.6.23
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: 2016-07-11 00:00:00.000000000 Z
13
+ date: 2016-07-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: copperegg-revealmetrics
@@ -314,7 +314,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
314
314
  version: '0'
315
315
  requirements: []
316
316
  rubyforge_project:
317
- rubygems_version: 2.4.8
317
+ rubygems_version: 2.5.0
318
318
  signing_key:
319
319
  specification_version: 4
320
320
  summary: Gather services data and store in CopperEgg