<file_sep>class NtpPlugin < Scout::Plugin
  def build_report
    if `ntpq -p` =~ /\A\*(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s?\z/
      peer = $1.to_s
      delay = $8.to_f
      offset = $9.to_f
      report("peer0_name" => peer)
      report("peer0_delay" => delay)
      report("peer0_offset" => offset)
     else
       raise "Couldn't use `ntpq` as expected."
     end
  rescue Exception
    error "Error determining peer", $!.message
  end
end
