Skip to content

Instantly share code, notes, and snippets.

View trilom's full-sized avatar
🏠
always...Working from Home

Bryan Killian trilom

🏠
always...Working from Home
View GitHub Profile
@trilom
trilom / network_addr_Ohai7.rb
Last active December 9, 2018 19:01 — forked from jtimberman/network_addr.rb
Ohai plugin to provide semantically nice attributes for network interfaces
Ohai.plugin(:NetworkAddrs) do
provides "networkAddrs"
depends "network/interfaces", "hostname"
collect_data(:default) do
networkAddrs(Mash.new)
network[:interfaces].each do |iface, addrs|
addrs[:addresses].each do |ip, params|
networkAddrs["ipaddress_#{iface}"] = ip if params[:family].eql?('inet')
networkAddrs["ipaddress6_#{iface}"] = ip if params[:family].eql?('inet6')
networkAddrs["macaddress_#{iface}"] = ip if params[:family].eql?('lladdr')