riemann-babbler 1.3.8 → 1.3.9

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.
@@ -22,7 +22,7 @@ class Riemann::Babbler::Http < Riemann::Babbler
22
22
  command += " -w '%{http_code}\\n'"
23
23
  command += " --retry #{plugin.retry} --retry-delay #{plugin.retry_delay}"
24
24
  command += " --max-time #{plugin.max_time} --fail"
25
- command += " #{plugin.url} -o /dev/null"
25
+ command += " #{plugin.url} -o /dev/null || echo 1"
26
26
 
27
27
  out = shell(command).to_i
28
28
 
@@ -0,0 +1,3 @@
1
+ class Riemann::Babbler::PluginHelperError < StandardError
2
+
3
+ end
@@ -5,10 +5,11 @@ module Riemann
5
5
 
6
6
  def helper_error(msg = 'Unknown helper error')
7
7
  report({
8
- :service => plugin.service,
9
- :state => 'critical',
10
- :description => msg
8
+ :service => plugin.service,
9
+ :state => 'critical',
10
+ :description => msg
11
11
  })
12
+ raise Riemann::Babbler::PluginHelperError
12
13
  end
13
14
 
14
15
  def plugin_timeout
@@ -34,7 +35,7 @@ module Riemann
34
35
  end
35
36
  if exit_status.to_i > 0
36
37
  err = err.chomp if err
37
- helper_error(err)
38
+ helper_error("Error while running shell: " + err.to_s)
38
39
  elsif out
39
40
  return out.strip
40
41
  else
@@ -1,5 +1,5 @@
1
1
  module Riemann
2
2
  class Babbler
3
- VERSION = '1.3.8'
3
+ VERSION = '1.3.9'
4
4
  end
5
5
  end
@@ -9,6 +9,7 @@ require 'socket'
9
9
  require 'net/ping'
10
10
  require 'file/tail'
11
11
  require 'riemann/babbler/support/monkey_patches'
12
+ require 'riemann/babbler/support/errors'
12
13
 
13
14
 
14
15
  # Базовое описание плагина
@@ -117,7 +118,7 @@ module Riemann
117
118
  # error - текущая ошибка, @has_last_error - предыдущая
118
119
  # две переменные для того что бы не удвоить сообщения об 'ОК'
119
120
  return 0 unless run_plugin
120
- error = true
121
+ error = false
121
122
  t0 = Time.now
122
123
  loop do
123
124
 
@@ -126,11 +127,14 @@ module Riemann
126
127
  rescue TimeoutError
127
128
  report({:state => 'critical', :service => plugin.service + " plugin errors", :description => "Broken plugin: deadlock"})
128
129
  logger.error("Plugin #{self.class.name} timed out!")
130
+ error = true
131
+ rescue Riemann::Babbler::PluginHelperError
132
+ logger.error("Plugin helper error!")
133
+ error = true
129
134
  rescue => e
130
135
  report({:state => 'critical', :service => plugin.service + " plugin errors", :description => "Plugin exception: #{e.class}\n #{e.backtrace.join "\n"}"})
131
136
  logger.error("Plugin #{self.class.name} : #{e.class} #{e}\n#{e.backtrace.join "\n"}")
132
- else
133
- error = false
137
+ error = true
134
138
  end
135
139
 
136
140
  report({:state => 'ok', :service => plugin.service + " plugin errors"}) if (not error && @has_last_error)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: riemann-babbler
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.8
4
+ version: 1.3.9
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: 2013-10-01 00:00:00.000000000 Z
12
+ date: 2013-10-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: riemann-client
@@ -212,6 +212,7 @@ files:
212
212
  - lib/riemann/babbler/plugins/tw_cli.rb
213
213
  - lib/riemann/babbler/start.rb
214
214
  - lib/riemann/babbler/support/deep_merge.rb
215
+ - lib/riemann/babbler/support/errors.rb
215
216
  - lib/riemann/babbler/support/monkey_patches.rb
216
217
  - lib/riemann/babbler/support/plugin_helpers.rb
217
218
  - lib/riemann/babbler/support/responder.rb