Sha256: afb148d9c3a878c3d6494292d6c10e530f1e1e259e7c2b22624d658a197734a6
Contents?: true
Size: 455 Bytes
Versions: 6
Compression:
Stored size: 455 Bytes
Contents
require 'rethtool' require 'rethtool/ethtool_value' # Retrieve the current link status of an interface. # # Usage is very simple: # # LinkStatus.new("eth0").up? # # or # # LinkStatus.new("eth0").down? # class Rethtool::LinkStatus def initialize(interface) cmd = Rethtool::EthtoolValue.new cmd.cmd = Rethtool::ETHTOOL_CMD_GSET @status = Rethtool.ioctl(interface, cmd).value end def down? @status == 0 end def up? !down? end end
Version data entries
6 entries across 6 versions & 1 rubygems