lib/riemann/babbler/plugin_helpers.rb in riemann-babbler-0.8.8 vs lib/riemann/babbler/plugin_helpers.rb in riemann-babbler-0.8.9

- old
+ new

@@ -1,11 +1,11 @@ #encoding: utf-8 module Riemann class Babbler - def helper_error(msg = "Unknown helper error") + def helper_error(msg = 'Unknown helper error') report({ :service => plugin.service, :state => 'critical', :description => msg }) @@ -18,14 +18,14 @@ out=nil begin timeout_shell = ( plugin.interval * 2 ).to_f/3 Timeout::timeout(timeout_shell) { Open3.popen3(*cmd) do |stdin, stdout, stderr, wait_thread| - err = stderr.gets(nil) - out = stdout.gets(nil) + + [stdin, stdout, stderr].each{|stream| stream.send('close')} - exit_status = wait_thread.value + end } rescue => e helper_error "#{e.class} #{e}\n#{e.backtrace.join "\n"}" end @@ -34,22 +34,10 @@ helper_error(err) elsif out return out.chomp else # статус 0, вывода stdout нет - return "" - end - end - - # db get - # http://sequel.rubyforge.org/rdoc/files/doc/opening_databases_rdoc.html - # - def sql(connection_string, query) - begin - db = Sequel.connect connection_string - db.fetch(query) - rescue => e - helper_error "#{e.class} #{e}\n#{e.backtrace.join "\n"}" + '' end end # http rest def rest_get(url)