Sha256: 85abeee19b946ee754fe662091365164c9f245e80dde5d11086f8cef4ffac8ce
Contents?: true
Size: 712 Bytes
Versions: 2
Compression:
Stored size: 712 Bytes
Contents
require 'open3' require 'timeout' module Ring class SQA class MTR BIN = 'mtr' def self.run host MTR.new.run host end def run host, args=nil Timeout::timeout(@timeout) do args ||= CFG.mtr.args.split(' ') mtr host, args end rescue Timeout::Error "MTR runtime exceeded #{@timeout}s" end private def initialize timeout=CFG.mtr.timeout @timeout = timeout end def mtr host, *args out = '' args = [*args, host].flatten Open3.popen3(BIN, *args) do |stdin, stdout, stderr, wait_thr| out << stdout.read until stdout.eof? end out.each_line.to_a[1..-1].join rescue '' end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ring-sqa-0.0.16 | lib/ring/sqa/mtr.rb |
ring-sqa-0.0.15 | lib/ring/sqa/mtr.rb |