Class: Fritz::Ping

Inherits:
Thor
  • Object
show all
Defined in:
lib/fritz/ping.rb

Constant Summary collapse

@@logger =
Logger.new($stdout, shift_age = 'weekly')

Instance Method Summary collapse

Instance Method Details

#host(address) ⇒ Object



13
14
15
16
17
# File 'lib/fritz/ping.rb', line 13

def host(address)
  p = Net::Ping::External.new(address)
  puts "#{address} #{p.ping?}" if options.out?
  p.ping?
end

#hosts(file) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/fritz/ping.rb', line 21

def hosts(file)
  @@logger = Logger.new(options[:logfile], shift_age = 'weekly') unless options[:logfile].nil?
  hosts = YAML.load(File.open(file))
  hosts.each do |label, addresses|
    addresses.each do |address|
      @@logger.add Logger::Severity::INFO, "#{label}\t#{address}\t#{self.host(address)}"
    end
  end
end