bipbip 0.2.7 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -0
- data/lib/bipbip/agent.rb +6 -3
- data/lib/bipbip/plugin/redis.rb +17 -1
- data/lib/bipbip/plugin/resque.rb +55 -0
- data/lib/bipbip/version.rb +1 -1
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 083225503257d0bef472a8af9249318fb5f8ebf1
|
4
|
+
data.tar.gz: c9ebda005ce2b5034b34a688c8e767849255f6e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 244d5a7981d237a0e7ca25df707a41fc2d76b5d696c800c67d9c3ed2a4dcf0b4edfb059cd27a5e225aab75a5da4975e3beaeabfe401e6818ebc1606a3d468fad
|
7
|
+
data.tar.gz: 76ea6d676ed59161fb69829621a49193f91484cc86a2a915905a434e91c416652697c21844c1ebe40ff9f7ac8cc8aa6ae33f5345fe229a015c93f77ce2ab4270
|
data/README.md
CHANGED
@@ -44,6 +44,13 @@ services:
|
|
44
44
|
plugin: redis
|
45
45
|
hostname: localhost
|
46
46
|
port: 6379
|
47
|
+
-
|
48
|
+
plugin: resque
|
49
|
+
hostname: localhost
|
50
|
+
port: 6379
|
51
|
+
database: 10
|
52
|
+
namespace: resque-prefix
|
53
|
+
frequency: 60
|
47
54
|
-
|
48
55
|
plugin: gearman
|
49
56
|
hostname: localhost
|
@@ -89,6 +96,8 @@ hostname: localhost
|
|
89
96
|
port: 11211
|
90
97
|
```
|
91
98
|
|
99
|
+
You can also set an override frequency per service in the main config or in these included configs.
|
100
|
+
|
92
101
|
Plugins
|
93
102
|
-------
|
94
103
|
#### fastcgi-php-fpm
|
data/lib/bipbip/agent.rb
CHANGED
@@ -56,13 +56,16 @@ module Bipbip
|
|
56
56
|
services = config['services'].to_a
|
57
57
|
if config['include']
|
58
58
|
include_path = File.expand_path(config['include'].to_s, File.dirname(config_file))
|
59
|
+
|
59
60
|
files = Dir[include_path + '/**/*.yaml', include_path + '/**/*.yml']
|
60
61
|
services += files.map { |file| YAML.load(File.open(file)) }
|
61
|
-
end
|
62
|
+
end
|
63
|
+
|
62
64
|
@plugins = services.map do |service|
|
63
65
|
service_name = service['plugin'].to_s
|
64
|
-
|
65
|
-
|
66
|
+
frequency = service['frequency'].nil? ? config['frequency'] : service['frequency'].to_i
|
67
|
+
service_config = service.reject { |key, value| ['plugin','frequency'].include?(key) }
|
68
|
+
Bipbip::Plugin.factory(service_name, service_config, frequency)
|
66
69
|
end
|
67
70
|
|
68
71
|
storages = config['storages'].to_a
|
data/lib/bipbip/plugin/redis.rb
CHANGED
@@ -10,9 +10,19 @@ module Bipbip
|
|
10
10
|
[
|
11
11
|
{:name => 'total_commands_processed', :type => 'counter', :unit => 'Commands'},
|
12
12
|
{:name => 'used_memory', :type => 'gauge', :unit => 'b'},
|
13
|
+
{:name => 'used_memory_rss', :type => 'gauge', :unit => 'b'},
|
14
|
+
{:name => 'mem_fragmentation_ratio', :type => 'gauge', :unit => 'Frag'},
|
15
|
+
{:name => 'connected_clients', :type => 'gauge', :unit => 'Clients'},
|
16
|
+
{:name => 'blocked_clients', :type => 'gauge', :unit => 'BlockedClients'},
|
13
17
|
]
|
14
18
|
end
|
15
19
|
|
20
|
+
def float_roundings
|
21
|
+
{
|
22
|
+
'mem_fragmentation_ratio' => 2
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
16
26
|
def monitor
|
17
27
|
redis = RedisClient.new(
|
18
28
|
:host => config['hostname'],
|
@@ -21,9 +31,15 @@ module Bipbip
|
|
21
31
|
stats = redis.info
|
22
32
|
redis.quit
|
23
33
|
|
34
|
+
roundings = float_roundings
|
24
35
|
data = {}
|
36
|
+
|
25
37
|
metrics_names.each do |key|
|
26
|
-
|
38
|
+
if !roundings[key].nil?
|
39
|
+
data[key] = stats[key].to_f.round(roundings[key])
|
40
|
+
else
|
41
|
+
data[key] = stats[key].to_i
|
42
|
+
end
|
27
43
|
end
|
28
44
|
data
|
29
45
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'redis'
|
2
|
+
require 'resque'
|
3
|
+
|
4
|
+
module Bipbip
|
5
|
+
|
6
|
+
class Plugin::Resque < Plugin
|
7
|
+
|
8
|
+
def metrics_schema
|
9
|
+
schema_list = [
|
10
|
+
{:name => 'num_workers', :type => 'counter', :unit => 'Workers'},
|
11
|
+
{:name => 'num_idle_workers', :type => 'counter', :unit => 'Workers'},
|
12
|
+
{:name => 'num_active_workers', :type => 'counter', :unit => 'Workers'},
|
13
|
+
]
|
14
|
+
|
15
|
+
with_resque_connection do
|
16
|
+
::Resque.queues.each do |queue|
|
17
|
+
schema_list << {:name => "queue_size_#{sanitize_queue_name(queue)}", :type => 'gauge', :unit => 'Jobs'}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
schema_list
|
22
|
+
end
|
23
|
+
|
24
|
+
def sanitize_queue_name(queue)
|
25
|
+
queue.gsub(/\s/, '-')
|
26
|
+
end
|
27
|
+
|
28
|
+
def with_resque_connection
|
29
|
+
redis = ::Redis.new(
|
30
|
+
:host => config['hostname'] || 'localhost',
|
31
|
+
:port => config['port'] || 6369
|
32
|
+
)
|
33
|
+
redis.select config['database']
|
34
|
+
::Resque.redis = redis
|
35
|
+
::Resque.redis.namespace = config['namespace'] unless config['namespace'].nil?
|
36
|
+
|
37
|
+
yield
|
38
|
+
|
39
|
+
redis.quit
|
40
|
+
end
|
41
|
+
|
42
|
+
def monitor
|
43
|
+
data = {}
|
44
|
+
with_resque_connection do
|
45
|
+
data['num_workers'] = ::Resque.workers.count
|
46
|
+
data['num_idle_workers'] = ::Resque.workers.select { |w| w.idle? }.count
|
47
|
+
data['num_active_workers'] = data['num_workers'] - data['num_idle_workers']
|
48
|
+
::Resque.queues.each do |queue|
|
49
|
+
data["queue_size_#{sanitize_queue_name(queue)}"] = ::Resque.size(queue).to_i
|
50
|
+
end
|
51
|
+
end
|
52
|
+
data
|
53
|
+
end
|
54
|
+
end
|
55
|
+
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.2.
|
4
|
+
version: 0.2.8
|
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-03-
|
13
|
+
date: 2014-03-27 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: copperegg
|
@@ -82,6 +82,20 @@ dependencies:
|
|
82
82
|
- - ">="
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
version: '0'
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: resque
|
87
|
+
requirement: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - "~>"
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '1.25'
|
92
|
+
type: :runtime
|
93
|
+
prerelease: false
|
94
|
+
version_requirements: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - "~>"
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '1.25'
|
85
99
|
- !ruby/object:Gem::Dependency
|
86
100
|
name: rake
|
87
101
|
requirement: !ruby/object:Gem::Requirement
|
@@ -137,6 +151,7 @@ files:
|
|
137
151
|
- lib/bipbip/plugin/nginx.rb
|
138
152
|
- lib/bipbip/plugin/php_apc.rb
|
139
153
|
- lib/bipbip/plugin/redis.rb
|
154
|
+
- lib/bipbip/plugin/resque.rb
|
140
155
|
- lib/bipbip/storage.rb
|
141
156
|
- lib/bipbip/storage/copperegg.rb
|
142
157
|
- lib/bipbip/version.rb
|