bipbip 0.0.8 → 0.0.9

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: 8aa8df7e73d0d7c9d463fb6770ad5b3e59327375
4
- data.tar.gz: 75973cff2c74e8eff315d6484b89628ec4d9e7be
3
+ metadata.gz: 917ccfd6eff250cdd46a1c9cabe716a275fce7d6
4
+ data.tar.gz: f2a20fe017f894955c0a1b217adcc6d9f6bb4326
5
5
  SHA512:
6
- metadata.gz: 0a19418f1f7693d768ab30a6b14000d2dd50fcd24b4702c8ef307962f8f77369bab604ae21f73a1daeec26d31fe3c71fd2556569a38b6ebd9cdd12639543d701
7
- data.tar.gz: c1453b8c39cb419f6c8d6ecd614d0105aa5bce98eaec83a0e5493c7d439e073a5d279c29d423aed7bfc30c6b60107595c551f4164198051763c9d830671bf88e
6
+ metadata.gz: 6334d3f0fdd5eb530375caaaf17f50970aba5226057f1892bb772c76eff8a61e32ad42b26c9bae5f1f2b94b427ad3fa3a5dfaeb149cd0faa1a81889fd1aab5b2
7
+ data.tar.gz: 744c1b6b6066c4bd5e4c724d6faaded7a55c934db1b258f67c7a518b9db87f6926d7455448d13ee0c8f0b548188fcf96ab9265379d8b2aa10ce0e73c8122cc83
data/README.md CHANGED
@@ -29,21 +29,21 @@ copperegg:
29
29
 
30
30
  services:
31
31
  -
32
- plugin: Memcached
32
+ plugin: memcached
33
33
  hostname: localhost
34
34
  port: 11211
35
35
  -
36
- plugin: Mysql
36
+ plugin: mysql
37
37
  hostname: localhost
38
38
  port: 3306
39
39
  username: root
40
40
  password: root
41
41
  -
42
- plugin: Redis
42
+ plugin: redis
43
43
  hostname: localhost
44
44
  port: 6379
45
45
  -
46
- plugin: Gearman
46
+ plugin: gearman
47
47
  hostname: localhost
48
48
  port: 4730
49
49
  ```
@@ -10,10 +10,6 @@ module Bipbip
10
10
  require 'bipbip/interruptible_sleep'
11
11
  require 'bipbip/agent'
12
12
  require 'bipbip/plugin'
13
- require 'bipbip/plugin/memcached'
14
- require 'bipbip/plugin/mysql'
15
- require 'bipbip/plugin/redis'
16
- require 'bipbip/plugin/gearman'
17
13
 
18
14
  def self.logger
19
15
  @logger || Logger.new(STDOUT)
@@ -35,7 +35,7 @@ module Bipbip
35
35
 
36
36
  plugin_names = @services.map { |service| service['plugin'] }
37
37
  plugin_names.each do |plugin_name|
38
- plugin = Plugin::const_get(plugin_name).new
38
+ plugin = plugin_factory(plugin_name)
39
39
 
40
40
  metric_group = metric_groups.detect { |m| m.name == plugin_name }
41
41
  if metric_group.nil? || !metric_group.is_a?(CopperEgg::MetricGroup)
@@ -56,8 +56,8 @@ module Bipbip
56
56
 
57
57
  @services.each do |service|
58
58
  plugin_name = service['plugin']
59
+ plugin = plugin_factory(plugin_name)
59
60
  Bipbip.logger.info "Starting plugin #{plugin_name}"
60
- plugin = Plugin::const_get(plugin_name).new
61
61
  @plugin_pids.push plugin.run(service, @frequency)
62
62
  end
63
63
 
@@ -84,6 +84,14 @@ module Bipbip
84
84
  dashboards
85
85
  end
86
86
 
87
+ def plugin_factory(plugin_name)
88
+ file_name = plugin_name.tr('-', '_')
89
+ require "bipbip/plugin/#{file_name}"
90
+
91
+ class_name = plugin_name.split('-').each { |part| part[0] = part[0].chr.upcase }.join
92
+ Plugin::const_get(class_name).new
93
+ end
94
+
87
95
  def load_config(config_file)
88
96
  config = YAML.load(File.open(config_file))
89
97
  if config.has_key?('logfile')
@@ -0,0 +1,30 @@
1
+ require 'memcached'
2
+ class MemcachedClient < Memcached
3
+ end
4
+
5
+ module Bipbip
6
+
7
+ class Plugin::FooBar < Plugin
8
+
9
+ def metrics_schema
10
+ [
11
+ {:name => 'cmd_get', :type => 'ce_counter'},
12
+ {:name => 'cmd_set', :type => 'ce_counter'},
13
+ {:name => 'get_misses', :type => 'ce_counter'},
14
+ {:name => 'limit_maxbytes', :type => 'ce_gauge', :unit => 'b'},
15
+ {:name => 'bytes', :type => 'ce_gauge', :unit => 'b'},
16
+ ]
17
+ end
18
+
19
+ def monitor(server)
20
+ cache = MemcachedClient.new(server['hostname'] + ':' + server['port'].to_s)
21
+ stats = cache.stats
22
+
23
+ data = {}
24
+ metrics_names.each do |key|
25
+ data[key] = stats[key.to_sym].shift.to_i
26
+ end
27
+ data
28
+ end
29
+ end
30
+ end
@@ -1,3 +1,3 @@
1
1
  module Bipbip
2
- VERSION = '0.0.8'
2
+ VERSION = '0.0.9'
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.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cargo Media
@@ -92,6 +92,7 @@ files:
92
92
  - bin/bipbip
93
93
  - lib/bipbip/agent.rb
94
94
  - lib/bipbip/interruptible_sleep.rb
95
+ - lib/bipbip/plugin/foo_bar.rb
95
96
  - lib/bipbip/plugin/gearman.rb
96
97
  - lib/bipbip/plugin/memcached.rb
97
98
  - lib/bipbip/plugin/mysql.rb