lib/riemann/babbler/plugin.rb in riemann-babbler-0.4.9 vs lib/riemann/babbler/plugin.rb in riemann-babbler-0.5.0

- old
+ new

@@ -1,7 +1,9 @@ #encoding: utf-8 +require File.expand_path('../plugin_helpers', __FILE__) + # Базовое описание плагина module Riemann class Babbler def self.registered_plugins @@ -121,46 +123,9 @@ else 'ok' end else my_state >= plugin.states.critical ? 'critical' : 'ok' - end - end - - # хэлпер для парса stdout+stderr и exit status - def shell(*cmd) - exit_status=nil - err=nil - out=nil - Timeout::timeout(5) { - 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 - } - if exit_status.to_i > 0 - err = err.chomp if err - raise err - elsif out - return out.chomp - else - # статус 0, вывода stdout нет - return "" - end - end - - # http rest - def rest_get(url) - begin - RestClient.get url - rescue - report({ - :service => plugin.service, - :state => 'critical', - :description => "Response from #{url}" - }) end end end end