Class: Ytstat::Host

Inherits:
Object
  • Object
show all
Defined in:
lib/ytstat/host.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, domain = 'vpndidu.com') ⇒ Host

Returns a new instance of Host.



5
6
7
8
# File 'lib/ytstat/host.rb', line 5

def initialize(name, domain='vpndidu.com')
  @url = [name, domain].join('.')
  @min = @max = @avg = @stddev = Float::MAX
end

Instance Attribute Details

#avgObject

Returns the value of attribute avg.



3
4
5
# File 'lib/ytstat/host.rb', line 3

def avg
  @avg
end

#maxObject

Returns the value of attribute max.



3
4
5
# File 'lib/ytstat/host.rb', line 3

def max
  @max
end

#minObject

Returns the value of attribute min.



3
4
5
# File 'lib/ytstat/host.rb', line 3

def min
  @min
end

#stddevObject

Returns the value of attribute stddev.



3
4
5
# File 'lib/ytstat/host.rb', line 3

def stddev
  @stddev
end

#urlObject

Returns the value of attribute url.



3
4
5
# File 'lib/ytstat/host.rb', line 3

def url
  @url
end

Instance Method Details

#pingObject



10
11
12
13
14
# File 'lib/ytstat/host.rb', line 10

def ping
  s = `ping -q -c 3 #{@url}`
  s.lines[-1] =~ /= (.*) ms/
    @min, @avg, @max, @stddev = $1.split('/').map {|x| x.to_f } if $1
end