Sha256: 104306cc803eabc93d2363f307da57bc50dc521076476330c00965a11db41e2a

Contents?: true

Size: 604 Bytes

Versions: 1

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_i - unixnow).abs
    }
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
riemann-babbler-2.0.7 lib/riemann/babbler/plugins/ntp.rb