This file contains 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
# Generated by Puppet | |
<Plugin "tail"> | |
<File "/var/log/sfptpd/stats.log"> | |
Instance "sfptpd_stats" | |
<Match> | |
Regex "->phc6\\(.*offset:[[:space:]]+(-?[[:digit:]]+\\.[[:digit:]]+)" | |
DSType "GaugeLast" | |
Type "precise_time_offset" | |
Instance "offset-phc6" |
This file contains 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
#LB: This custom fact will create Facter facts of the format nic_driver_<driver> | |
#that contain a comma separated string of all the networking interfaces that use this driver. | |
#Facter already knows about interfaces | |
drivers = Hash.new | |
Facter.value(:interfaces).split(',').each do |int| | |
#call ethtool to get the driver for this NIC | |
driver = %x{/sbin/ethtool -i #{int} 2>/dev/null | grep 'driver: '}.chomp.sub("driver: ", "") | |
if driver == '' | |
driver = 'virtual' |
This file contains 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
class profile::statistics::sfptpd( | |
$stats_log = '/var/log/sfptpd/stats.log', | |
$daemon_log = '/var/log/sfptpd/sfptpd.log', | |
) { | |
#LB: take the known SolarFlare cards and the hash of PTP Hardware Clocks, and get a unique list | |
#of phc device names so we know what to look for in the sfptpd log files. | |
if (!is_hash($::phc)) { | |
fail('The $::phc Fact is expected to be a hash, is stringify_facts=true?') | |
} | |
#LB: get Solar Flare NICs as an Array |
This file contains 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
#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 |
This file contains 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
module Puppet::Parser::Functions | |
newfunction(:subs_repl_array, :type => :rvalue, :doc => <<-'ENDHEREDOC' | |
Takes an Array of strings and a hash of strings, then for every element in the array, | |
it goes searching the hash values for the string 'SUBS' and replaces it with the array element. | |
The value returned is itself an array of hashes, where each hash element is a copy of the input hash | |
with the relevant substitution made. The number of hashes returned is the same as the input array. | |
$out_array = subs_repl_array($in_array, $in_hash) |
This file contains 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
class { 'sfptpd': | |
interface => $management_interface, | |
stats_log_enable => true, | |
manage_service => false, | |
daemon => false, | |
message_log => 'stderr', | |
stats_log_file => 'stdout', | |
} | |
class { 'supervisord': |
This file contains 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
class { '::profile::statistics': | |
interval => 1, | |
} | |
class { '::profile::statistics::write_network': | |
server => 'localhost', | |
} | |
class { '::profile::statistics::remote_ntp_offset': | |
ntp_server => 'timesource.example.com', | |
} | |
include ::collectd::plugin::tail |
This file contains 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
class { '::profile::statistics': | |
interval => 1, | |
} | |
class { '::profile::statistics::write_network': | |
server => 'localhost', | |
} | |
class { '::profile::statistics::remote_ntp_offset': | |
ntp_server => 'timesource.example.com', | |
} |
This file contains 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
class profile::statistics::write_network($server = 'localhost') inherits profile { | |
collectd::plugin::network::server { $server: | |
port => 25826, | |
} | |
} |
This file contains 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
define profile::statistics::tail_linuxptp_log($filename) { | |
collectd::plugin::tail::file { $name: | |
filename => $filename, | |
instance => $name, | |
matches => [ | |
{ | |
regex => 'offset[[:space:]]+(-?[[:digit:]]+)', | |
dstype => 'GaugeLast', | |
type => 'precise_time_offset', | |
instance => 'offset', |