41: def self.get_interface_value(interface, label)
42:
43: tmp1 = []
44:
45: case Facter.value(:kernel)
46: when 'Linux'
47: addr = /inet addr:([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/
48: mac = /(?:ether|HWaddr)\s+(\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2})/
49: mask = /Mask:([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/
50: when 'OpenBSD', 'NetBSD', 'FreeBSD'
51: addr = /inet\s+([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/
52: mac = /(?:ether|lladdr)\s+(\w\w:\w\w:\w\w:\w\w:\w\w:\w\w)/
53: mask = /netmask\s+(\w{10})/
54: when 'SunOS'
55: addr = /inet\s+([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/
56: mac = /(?:ether|lladdr)\s+(\w?\w:\w?\w:\w?\w:\w?\w:\w?\w:\w?\w)/
57: mask = /netmask\s+(\w{8})/
58: end
59:
60: case label
61: when 'ipaddress'
62: regex = addr
63: when 'macaddress'
64: regex = mac
65: when 'netmask'
66: regex = mask
67: end
68:
69: output_int = get_single_interface_output(interface)
70:
71: if interface != "lo" && interface != "lo0"
72: output_int.each { |s|
73: if s =~ regex
74: value = $1
75: if label == 'netmask' && Facter.value(:kernel) == "SunOS"
76: value = value.scan(/../).collect do |byte| byte.to_i(16) end.join('.')
77: end
78: tmp1.push(value)
79: end
80: }
81: end
82:
83: if tmp1
84: value = tmp1.shift
85: end
86:
87: end