Sha256: cac4f939ab4c12a0d9640f2297af3178b25d0fc5606e2f10e135b0b15196c97b

Contents?: true

Size: 707 Bytes

Versions: 1

Compression:

Stored size: 707 Bytes

Contents

require "net/http"

module SoaDoctor
  module Commands
    class StatusCheck < ::Escort::ActionCommand::Base
      def execute
        rows = []
        file = ::YAML.load_file(command_options[:file])
        file["services"].each_pair do |k, v|
          begin
            req = Thread.new(v) { |page|
              ::Net::HTTP.get_response(URI(page))
            }
            req = ::Net::HTTP.get_response(URI(v))
            rows << [k, req.code, req.message]

          rescue Exception => e
            rows << [k, { :value => e.inspect, :colspan => 2 }]
          end
        end

        ::Terminal::Table.new :headings => ['Service', 'Status', 'Message'], :rows => rows
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
soa_doctor-0.0.2 lib/soa_doctor/commands/status_check.rb