bipbip 0.0.9 → 0.1.0

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: 917ccfd6eff250cdd46a1c9cabe716a275fce7d6
4
- data.tar.gz: f2a20fe017f894955c0a1b217adcc6d9f6bb4326
3
+ metadata.gz: 8903502222cc5f314d6127cd5426ee671bd37ad6
4
+ data.tar.gz: 8acc5e65784a3df1dae968a0951f0033ec690bdb
5
5
  SHA512:
6
- metadata.gz: 6334d3f0fdd5eb530375caaaf17f50970aba5226057f1892bb772c76eff8a61e32ad42b26c9bae5f1f2b94b427ad3fa3a5dfaeb149cd0faa1a81889fd1aab5b2
7
- data.tar.gz: 744c1b6b6066c4bd5e4c724d6faaded7a55c934db1b258f67c7a518b9db87f6926d7455448d13ee0c8f0b548188fcf96ab9265379d8b2aa10ce0e73c8122cc83
6
+ metadata.gz: f0ea82bd53a4b1e1b63510228ef7524db047e9f2e8d22e0e7dbdd0858409e210c5601ad6aac295dbbf5123a55aafbdb68474db346be2a27b893a90e27d03e43d
7
+ data.tar.gz: e9d8e3765e4ef52ef388353dd28463427921d4f0c52aa6fe86c89c1f7b29b6c9ef932065cde8e65500dbf401552b61a172e84b6c782f8159aee73f6ac987b99f
data/README.md CHANGED
@@ -46,6 +46,12 @@ services:
46
46
  plugin: gearman
47
47
  hostname: localhost
48
48
  port: 4730
49
+ -
50
+ plugin: apache2
51
+ url: http://localhost:80/server-status?auto
52
+ -
53
+ plugin: nginx
54
+ url: http://localhost:80/server-status
49
55
  ```
50
56
 
51
57
  Include configuration
@@ -58,7 +64,7 @@ This will include files from `/etc/bipbip/services.d/` and load them into the `s
58
64
 
59
65
  You could then add a file `/etc/bipbip/services.d/memcached.yml`:
60
66
  ```yml
61
- plugin: Memcached
67
+ plugin: memcached
62
68
  hostname: localhost
63
69
  port: 11211
64
70
  ```
@@ -57,8 +57,9 @@ module Bipbip
57
57
  @services.each do |service|
58
58
  plugin_name = service['plugin']
59
59
  plugin = plugin_factory(plugin_name)
60
+ service_config = service.select { |key| !['plugin'].include?(key) }
60
61
  Bipbip.logger.info "Starting plugin #{plugin_name}"
61
- @plugin_pids.push plugin.run(service, @frequency)
62
+ @plugin_pids.push plugin.run(service_config, @frequency)
62
63
  end
63
64
 
64
65
  p Process.waitall
@@ -88,8 +89,8 @@ module Bipbip
88
89
  file_name = plugin_name.tr('-', '_')
89
90
  require "bipbip/plugin/#{file_name}"
90
91
 
91
- class_name = plugin_name.split('-').each { |part| part[0] = part[0].chr.upcase }.join
92
- Plugin::const_get(class_name).new
92
+ class_name = plugin_name.split('-').map{|w| w.capitalize}.join
93
+ Plugin::const_get(class_name).new(plugin_name)
93
94
  end
94
95
 
95
96
  def load_config(config_file)
@@ -3,7 +3,8 @@ module Bipbip
3
3
  class Plugin
4
4
  include InterruptibleSleep
5
5
 
6
- def initialize
6
+ def initialize(name)
7
+ @name = name.to_s
7
8
  end
8
9
 
9
10
  def run(server, frequency)
@@ -43,11 +44,15 @@ module Bipbip
43
44
  end
44
45
 
45
46
  def name
46
- self.class.name.split('::').last
47
+ @name
47
48
  end
48
49
 
49
50
  def metric_identifier(server)
50
- Bipbip.fqdn + '::' + server['hostname']
51
+ identifier = Bipbip.fqdn
52
+ unless server.empty?
53
+ identifier += '::' + server.values.first
54
+ end
55
+ identifier
51
56
  end
52
57
 
53
58
  def metrics_names
@@ -0,0 +1,29 @@
1
+ module Bipbip
2
+
3
+ class Plugin::Apache2 < Plugin
4
+
5
+ def metrics_schema
6
+ [
7
+ {:name => 'request_per_sec', :type => 'ce_gauge', :unit => 'Requests'},
8
+ {:name => 'busy_workers', :type => 'ce_gauge', :unit => 'Workers'},
9
+ ]
10
+ end
11
+
12
+ def monitor(server)
13
+ uri = URI.parse(server['url'])
14
+ response = Net::HTTP.get_response(uri)
15
+
16
+ raise "Invalid response from server at #{server['url']}" unless response.code == '200'
17
+
18
+ astats = response.body.split(/\r*\n/)
19
+
20
+ ainfo = {}
21
+ astats.each do |row|
22
+ name, value = row.split(': ')
23
+ ainfo[name] = value
24
+ end
25
+
26
+ {:request_per_sec => ainfo['ReqPerSec'].to_f, :busy_workers => ainfo['BusyWorkers'].to_i}
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,23 @@
1
+ module Bipbip
2
+
3
+ class Plugin::Nginx < Plugin
4
+
5
+ def metrics_schema
6
+ [
7
+ {:name => 'connections_requested', :type => 'ce_counter', :unit => 'Requests'},
8
+ ]
9
+ end
10
+
11
+ def monitor(server)
12
+ uri = URI.parse(server['url'])
13
+ response = Net::HTTP.get_response(uri)
14
+
15
+ raise "Invalid response from server at #{server['url']}" unless response.code == "200"
16
+
17
+ nstats = response.body.split(/\r*\n/)
18
+ connections_requested = nstats[2].lstrip.split(/\s+/)[2].to_i
19
+
20
+ {:connections_requested => connections_requested}
21
+ end
22
+ end
23
+ end
@@ -1,3 +1,3 @@
1
1
  module Bipbip
2
- VERSION = '0.0.9'
2
+ VERSION = '0.1.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bipbip
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cargo Media
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-10 00:00:00.000000000 Z
11
+ date: 2013-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: copperegg
@@ -92,10 +92,11 @@ 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
+ - lib/bipbip/plugin/apache2.rb
96
96
  - lib/bipbip/plugin/gearman.rb
97
97
  - lib/bipbip/plugin/memcached.rb
98
98
  - lib/bipbip/plugin/mysql.rb
99
+ - lib/bipbip/plugin/nginx.rb
99
100
  - lib/bipbip/plugin/redis.rb
100
101
  - lib/bipbip/plugin.rb
101
102
  - lib/bipbip/version.rb
@@ -1,30 +0,0 @@
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