Sha256: fd89eed1bc977109d042fdf16cb8565403e812acda62033f44cb23c6ebd7b7f8

Contents?: true

Size: 666 Bytes

Versions: 2

Compression:

Stored size: 666 Bytes

Contents

# A module to gather macaddress facts
#
module Facter::Util::Macaddress

  module Darwin
    def self.macaddress
      iface = default_interface
      Facter.warn "Could not find a default route. Using first non-loopback interface" if iface.empty?

      macaddress = `#{ifconfig_command} #{iface} | /usr/bin/awk '/ether/{print $2;exit}'`.chomp
      macaddress.empty? ? nil : macaddress
    end

    def self.default_interface
      `#{netstat_command} | /usr/bin/awk  '/^default/{print $6;exit}'`.chomp
    end

    private

    def self.netstat_command
      '/usr/sbin/netstat -rn'
    end

    def self.ifconfig_command
      '/sbin/ifconfig'
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
facter-1.6.0 lib/facter/util/macaddress.rb
facter-1.5.9 lib/facter/util/macaddress.rb