class Rethtool::LinkStatus

Retrieve the current link status of an interface.

Usage is very simple:

LinkStatus.new("eth0").up?

or

LinkStatus.new("eth0").down?

Public Class Methods

new(interface) click to toggle source
# File lib/rethtool/link_status.rb, line 15
def initialize(interface)
        cmd = Rethtool::EthtoolValue.new
        cmd.cmd = Rethtool::ETHTOOL_CMD_GSET
        
        @status = Rethtool.ioctl(interface, cmd).value
end

Public Instance Methods

down?() click to toggle source
# File lib/rethtool/link_status.rb, line 22
def down?
        @status == 0
end
up?() click to toggle source
# File lib/rethtool/link_status.rb, line 26
def up?
        !down?
end