Sha256: 5f19ff192f5c5a3f9f7206c176ecc2e93bc49c0348ecf037dabec0c071cbc6e4

Contents?: true

Size: 604 Bytes

Versions: 2

Compression:

Stored size: 604 Bytes

Contents

require 'net/ntp'

class Riemann::Babbler::Plugin::Ntp < Riemann::Babbler::Plugin

  def init
    plugin.set_default(:service, 'ntp')
    plugin.set_default(:host, 'pool.ntp.org')
    plugin.states.set_default(:warning, 5)
    plugin.states.set_default(:critical, 10)
  end

  def diff
    Net::NTP.get(plugin.host, 'ntp', 5).time.to_i - Time.now.to_i
  end

  def collect
    {
      :service     => plugin.service + " #{plugin.host}",
      :description => "Ntp lag with host #{plugin.host}",
      :metric      => (::Net::NTP.get(plugin.host, 'ntp', 5).time.to_f - Time.now.to_f).abs
    }
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
riemann-babbler-2.1.3.2 lib/riemann/babbler/plugins/ntp.rb
riemann-babbler-2.1.3.1 lib/riemann/babbler/plugins/ntp.rb