Class: Rethtool::LinkStatus

Inherits:
Object
  • Object
show all
Defined in:
lib/rethtool/link_status.rb

Overview

Retrieve the current link status of an interface.

Usage is very simple:

LinkStatus.new("eth0").up?

or

LinkStatus.new("eth0").down?

Instance Method Summary collapse

Constructor Details

#initialize(interface) ⇒ LinkStatus

Returns a new instance of LinkStatus.



15
16
17
18
19
20
# 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

Instance Method Details

#down?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/rethtool/link_status.rb', line 22

def down?
	@status == 0
end

#up?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/rethtool/link_status.rb', line 26

def up?
	!down?
end