bipbip 0.5.2 → 0.5.3
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/mongodb.rb +39 -10
- 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: 9f3f706944fb1a4083b89c9be46134dfd8865b82
|
4
|
+
data.tar.gz: 79932d0864a70ec3baeb2b15e82902c74dd8c95b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79c99748103287522a626b7f549f00ad8650c9b742a47456ebb4f50545f06a757abcc8a70668acf349374acaf8ae547522c468e64794837eaf68b0a6297c4ece
|
7
|
+
data.tar.gz: f15aacbead140f12ebc0334401e79c023702c75043a9e08eee2c08e845fe9f140fd6cf844e624a7e7e7d726b2fe968ee333b7ff7f5ec2606029c1ddee7ed0f75
|
@@ -19,20 +19,12 @@ module Bipbip
|
|
19
19
|
{:name => 'mem_mapped', :type => 'gauge', :unit => 'MB'},
|
20
20
|
{:name => 'mem_pagefaults', :type => 'gauge', :unit => 'faults'},
|
21
21
|
{:name => 'globalLock_currentQueue', :type => 'gauge'},
|
22
|
+
{:name => 'replication_lag', :type => 'gauge', :unit => 'Seconds'},
|
22
23
|
]
|
23
24
|
end
|
24
25
|
|
25
26
|
def monitor
|
26
|
-
|
27
|
-
'hostname' => 'localhost',
|
28
|
-
'port' => 27017,
|
29
|
-
'username' => nil,
|
30
|
-
'password' => nil
|
31
|
-
}.merge(config)
|
32
|
-
connection = Mongo::MongoClient.new(options['hostname'], options['port'], {:op_timeout => 2, :slave_ok => true})
|
33
|
-
mongo = connection.db('admin')
|
34
|
-
mongo.authenticate(options['username'], options['password']) unless options['password'].nil?
|
35
|
-
mongoStats = mongo.command('serverStatus' => 1)
|
27
|
+
mongoStats = server_status
|
36
28
|
|
37
29
|
data = {}
|
38
30
|
|
@@ -63,7 +55,44 @@ module Bipbip
|
|
63
55
|
if mongoStats['globalLock'] && mongoStats['globalLock']['currentQueue']
|
64
56
|
data['globalLock_currentQueue'] = mongoStats['globalLock']['currentQueue']['total'].to_i
|
65
57
|
end
|
58
|
+
if mongoStats['repl'] && mongoStats['repl']['secondary'] == true
|
59
|
+
data['replication_lag'] = replication_lag
|
60
|
+
end
|
66
61
|
data
|
67
62
|
end
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
def admin_database
|
67
|
+
options = {
|
68
|
+
'hostname' => 'localhost',
|
69
|
+
'port' => 27017,
|
70
|
+
'username' => nil,
|
71
|
+
'password' => nil
|
72
|
+
}.merge(config)
|
73
|
+
connection = Mongo::MongoClient.new(options['hostname'], options['port'], {:op_timeout => 2, :slave_ok => true})
|
74
|
+
mongo = connection.db('admin')
|
75
|
+
mongo.authenticate(options['username'], options['password']) unless options['password'].nil?
|
76
|
+
mongo
|
77
|
+
end
|
78
|
+
|
79
|
+
def server_status
|
80
|
+
admin_database.command('serverStatus' => 1)
|
81
|
+
end
|
82
|
+
|
83
|
+
def replica_status
|
84
|
+
admin_database.command('replSetGetStatus' => 1)
|
85
|
+
end
|
86
|
+
|
87
|
+
def replication_lag
|
88
|
+
member_list = replica_status['members']
|
89
|
+
primary = member_list.select { |member| member['stateStr'] == 'PRIMARY' }.first
|
90
|
+
secondary = member_list.select { |member| member['stateStr'] == 'SECONDARY' and member['self'] == true }.first
|
91
|
+
|
92
|
+
raise "No primary member in replica `#{replica_status['set']}`" if primary.nil?
|
93
|
+
raise "Cannot find itself as secondary member in replica `#{replica_status['set']}`" if secondary.nil?
|
94
|
+
|
95
|
+
(primary['optime'].seconds - secondary['optime'].seconds)
|
96
|
+
end
|
68
97
|
end
|
69
98
|
end
|
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.3
|
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: 2014-
|
13
|
+
date: 2014-12-01 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: copperegg
|