-
-
Save apsoto/1503758 to your computer and use it in GitHub Desktop.
Ohai plugin to return semantic reference attributes for network addresses
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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