Skip to content

Instantly share code, notes, and snippets.

@apsoto
Forked from jtimberman/gist:1040853
Created December 20, 2011 23:18
Show Gist options
  • Save apsoto/1503758 to your computer and use it in GitHub Desktop.
Save apsoto/1503758 to your computer and use it in GitHub Desktop.
Ohai plugin to return semantic reference attributes for network addresses
require 'rubygems'
require 'ohai'
o = Ohai::System.new()
o.all_plugins
# And retrieve some useful semantic reference attributes for network interfaces
o['network']['interfaces'].each do |iface, addrs|
addrs['addresses'].each do |ip, params|
o["ipaddress_#{iface}"] = ip if params['family'].eql?('inet')
o["ipaddress6_#{iface}"] = ip if params['family'].eql?('inet6')
o["macaddress_#{iface}"] = ip if params['family'].eql?('lladdr')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment