ganymed 0.4.3 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
data/.rvmrc CHANGED
@@ -1 +1 @@
1
- rvm use --create ruby-1.9.3-p194@ganymed
1
+ rvm use --create ruby-1.9.3-p392@ganymed
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
@@ -53,6 +53,7 @@ module Ganymed
53
53
  collectors.each do |file|
54
54
  name = File.basename(file, '.rb')
55
55
  config = @config.collectors[name.to_sym] || Section.new
56
+ config.name = name
56
57
 
57
58
  log.debug("loading collector #{name} from #{file}")
58
59
  Plugin.new(config).from_file(file).tap do |collector|
@@ -90,6 +91,10 @@ module Ganymed
90
91
  # @return [Fixnum,Float]
91
92
  attr_accessor :interval
92
93
 
94
+ # Plugin splay
95
+ # @return [Fixnum]
96
+ attr_reader :splay
97
+
93
98
  # Create a new plugin instance.
94
99
  #
95
100
  # @param [Section] config The configuration object.
@@ -103,6 +108,7 @@ module Ganymed
103
108
  # @return [void]
104
109
  def collect(interval=nil, &block)
105
110
  @interval = interval || config.interval.tap{} || 1
111
+ @splay = 0
106
112
  @collector = Proc.new(&block)
107
113
  end
108
114
 
@@ -110,18 +116,22 @@ module Ganymed
110
116
  # interval.
111
117
  # @return [void]
112
118
  def run
113
- EM.add_periodic_timer(interval) do
114
- EM.defer { collect! }
119
+ # we do not use a periodic timer here so that we can simply increase
120
+ # the splay to slow down the collector in case it throws lots of
121
+ # exceptions
122
+ EM.add_timer(interval * (2 ** splay)) do
123
+ EM.defer { collect!; run }
115
124
  end
116
125
  end
117
126
 
118
127
  # @private
119
128
  def collect!
120
- begin
121
- @collector.call if @collector.is_a?(Proc)
122
- rescue Exception => exc
123
- log.exception(exc)
124
- end
129
+ @collector.call if @collector.is_a?(Proc)
130
+ @splay = 0
131
+ rescue Exception => exc
132
+ @splay += 1
133
+ log.exception(exc)
134
+ log.info("slowing down collector #{config.name}", interval: @interval, splay: @splay)
125
135
  end
126
136
 
127
137
  # Loads a given ruby file, and runs instance_eval against it in the
@@ -2,7 +2,7 @@ require 'sys/filesystem'
2
2
 
3
3
  collect do
4
4
  Sys::Filesystem.mounts do |mount|
5
- st = Sys::Filesystem.stat(mount.mount_point)
5
+ st = Sys::Filesystem.stat(mount.mount_point) rescue next
6
6
  next if st.blocks == 0 or st.files == 0
7
7
 
8
8
  case mp = mount.mount_point
@@ -1,4 +1,4 @@
1
1
  module Ganymed
2
2
  # @private
3
- VERSION = '0.4.3'
3
+ VERSION = '0.4.4'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ganymed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-21 00:00:00.000000000 Z
12
+ date: 2013-03-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -222,7 +222,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
222
222
  version: '0'
223
223
  segments:
224
224
  - 0
225
- hash: 841601178190202909
225
+ hash: -2160081704488403590
226
226
  required_rubygems_version: !ruby/object:Gem::Requirement
227
227
  none: false
228
228
  requirements:
@@ -231,10 +231,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
231
231
  version: '0'
232
232
  segments:
233
233
  - 0
234
- hash: 841601178190202909
234
+ hash: -2160081704488403590
235
235
  requirements: []
236
236
  rubyforge_project:
237
- rubygems_version: 1.8.24
237
+ rubygems_version: 1.8.25
238
238
  signing_key:
239
239
  specification_version: 3
240
240
  summary: Ganymed is a daemon that collects Metriks from third-party applications