module Facter::Util::Macaddress::Darwin
Public Class Methods
default_interface()
click to toggle source
# File lib/facter/util/macaddress.rb, line 19 def self.default_interface %x`#{netstat_command} | /usr/bin/awk '/^default/{print $6;exit}'`.chomp end
macaddress()
click to toggle source
# File lib/facter/util/macaddress.rb, line 11 def self.macaddress iface = default_interface Facter.warn "Could not find a default route. Using first non-loopback interface" if iface.empty? macaddress = %x`#{ifconfig_command} #{iface} | /usr/bin/awk '/ether/{print $2;exit}'`.chomp macaddress.empty? ? nil : macaddress end
Private Class Methods
ifconfig_command()
click to toggle source
# File lib/facter/util/macaddress.rb, line 29 def self.ifconfig_command '/sbin/ifconfig' end
netstat_command()
click to toggle source
# File lib/facter/util/macaddress.rb, line 25 def self.netstat_command '/usr/sbin/netstat -rn' end