Module: Net::NTP::Check
- Defined in:
- lib/net/ntp/check.rb,
lib/net/ntp/check/offset.rb,
lib/net/ntp/check/statsd.rb,
lib/net/ntp/check/version.rb
Overview
Overview
Contains Net::NTP::Check version number
Defined Under Namespace
Classes: AutoBandPass, StatsdClient
Constant Summary collapse
- DEFAULT_SERVERS =
Default servers to check against
[ '0.pool.ntp.org', '1.pool.ntp.org', '2.pool.ntp.org', '3.pool.ntp.org' ]
- TIMEOUT =
Default timeout for the NTP requests
Net::NTP::TIMEOUT
- VERSION =
'0.0.1'
Class Method Summary collapse
-
.get_offset(host = , timeout = TIMEOUT) ⇒ Object
Get the time offset against the given host.
-
.get_offsets(hosts = DEFAULT_SERVERS, timeout = TIMEOUT) ⇒ Object
Get the time offsets against the given host list.
-
.get_offsets_filtered(hosts = DEFAULT_SERVERS, timeout = TIMEOUT) ⇒ Object
Get the time offsets against the given host list with a bandpass filter applied.
- .logger ⇒ Object
Class Method Details
.get_offset(host = , timeout = TIMEOUT) ⇒ Object
Get the time offset against the given host
48 49 50 |
# File 'lib/net/ntp/check/offset.rb', line 48 def self.get_offset(host = DEFAULT_SERVERS[0], timeout = TIMEOUT) get_host_data(host, timeout)[0].offset end |
.get_offsets(hosts = DEFAULT_SERVERS, timeout = TIMEOUT) ⇒ Object
Get the time offsets against the given host list
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/net/ntp/check/offset.rb', line 36 def self.get_offsets(hosts = DEFAULT_SERVERS, timeout = TIMEOUT) offsets = [] Net::NTP::Check.logger.debug("Host list: #{hosts}") hosts.each do |host| offsets.push(get_offset(host, timeout)) end offsets end |
.get_offsets_filtered(hosts = DEFAULT_SERVERS, timeout = TIMEOUT) ⇒ Object
Get the time offsets against the given host list with a bandpass filter applied
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/net/ntp/check/offset.rb', line 23 def self.get_offsets_filtered(hosts = DEFAULT_SERVERS, timeout = TIMEOUT) offsets = [] hosts_multiplier = (9.0 / hosts.length).ceil Net::NTP::Check.logger.debug("Hosts given: #{hosts}") Net::NTP::Check.logger.debug("Hosts multiplier: #{hosts_multiplier}") hosts_multiplier.times do offsets.push(get_offsets(hosts, timeout)) sleep(0.01) # sleep to keep from getting rate limted end AutoBandPass.filter(offsets.flatten.shuffle[0...9]) end |
.logger ⇒ Object
14 15 16 17 18 |
# File 'lib/net/ntp/check.rb', line 14 def self.logger @logger ||= Logger.new(STDOUT).tap do |l| l.level = Logger::INFO end end |