Skip to content

Instantly share code, notes, and snippets.

@lukebigum
Created December 23, 2015 09:15
Show Gist options
  • Save lukebigum/029874b48048010c841b to your computer and use it in GitHub Desktop.
Save lukebigum/029874b48048010c841b to your computer and use it in GitHub Desktop.
Facter Fact for PTP Hardware Clocks
#Look for networking interfaces that have ptp devices
module PhcFact
def self.add_facts
phc = {}
Dir.glob("/sys/class/net/*/device/ptp/*") do |dir|
m = /\/sys\/class\/net\/(\S+)\/device\/ptp\/(\S+)/.match(dir)
phc[m[1]] = m[2]
end
Facter.add("phc") do
setcode do
phc
end
end
end
end
PhcFact.add_facts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment