summaryrefslogtreecommitdiff
path: root/lib/facter/munin_interfaces.rb
blob: f7a35756ceb2f25dede4120361d3a882cca2b627 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# return the set of active interfaces as an array
Facter.add("munin_interfaces") do
	setcode do
		`ip -o link show`.split(/\n/).collect do |line|
			value = nil
			matches = line.match(/^\d*: ([^:]*): <(.*,)?UP(,.*)?>/)
			if !matches.nil?
				value = matches[1]
				# remove superfluous "underlying interface" specification 
				# for VLAN interfaces
				value.gsub!(/@.*/, '')
			end
			value
		end.compact.sort.join(" ")
	end
end