Class: Ytstat::Host
- Inherits:
-
Object
- Object
- Ytstat::Host
- Defined in:
- lib/ytstat/host.rb
Instance Attribute Summary collapse
-
#avg ⇒ Object
Returns the value of attribute avg.
-
#max ⇒ Object
Returns the value of attribute max.
-
#min ⇒ Object
Returns the value of attribute min.
-
#stddev ⇒ Object
Returns the value of attribute stddev.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(name, domain = 'vpndidu.com') ⇒ Host
constructor
A new instance of Host.
- #ping ⇒ Object
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
#avg ⇒ Object
Returns the value of attribute avg.
3 4 5 |
# File 'lib/ytstat/host.rb', line 3 def avg @avg end |
#max ⇒ Object
Returns the value of attribute max.
3 4 5 |
# File 'lib/ytstat/host.rb', line 3 def max @max end |
#min ⇒ Object
Returns the value of attribute min.
3 4 5 |
# File 'lib/ytstat/host.rb', line 3 def min @min end |
#stddev ⇒ Object
Returns the value of attribute stddev.
3 4 5 |
# File 'lib/ytstat/host.rb', line 3 def stddev @stddev end |
#url ⇒ Object
Returns the value of attribute url.
3 4 5 |
# File 'lib/ytstat/host.rb', line 3 def url @url end |
Instance Method Details
#ping ⇒ Object
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 |