<commit_before># frozen_string_literal: true

require 'riemann/tools'

module Riemann
    module Tools
      class Ntp
        include Riemann::Tools
  
        def initialize
          @hostname = `hostname`.chomp
          @ostype = `uname -s`.chomp.downcase
          if @ostype = 'darwin'
            puts "WARNING: macOS not explicitly supported. Exiting."
            exit 1        
          end
        end
  
        def tick
          stats = `ntpq -p -n`
          stats.each_line do |stat|
            m = stat.split
            next if m.grep(/^===/).any? || m.grep(/^remote/).any?
  
            @ntp_host = m[0].gsub('*', '').gsub('-', '').gsub('+', '')
            send('delay', m[7])
            send('offset', m[8])
            send('jitter', m[9])
          end
        end
  
        def send(type, metric)
          report(
            host: @hostname,
            service: "ntp peer #{@ntp_host} #{type}",
            metric: metric.to_f,
            state: 'ok',
            description: "ntp peer #{@ntp_host} #{type}",
            tags: ['ntp'],
          )
        end
      end
    end
  end<commit_msg>rubocop<commit_after># frozen_string_literal: true

require 'riemann/tools'

module Riemann
  module Tools
    class Ntp
      include Riemann::Tools

      def initialize
        @hostname = `hostname`.chomp
        @ostype = `uname -s`.chomp.downcase
        abort 'WARNING: macOS not explicitly supported. Exiting.' if @ostype == 'darwin'
      end

      def tick
        stats = `ntpq -p -n`
        stats.each_line do |stat|
        m = stat.split
        next if m.grep(/^===/).any? || m.grep(/^remote/).any?
  
        @ntp_host = m[0].gsub('*', '').gsub('-', '').gsub('+', '')
        send('delay', m[7])
        send('offset', m[8])
        send('jitter', m[9])
      end
    end

    def send(type, metric)
      report(
        host: @hostname,
        service: "ntp peer #{@ntp_host} #{type}",
        metric: metric.to_f,
        state: 'ok',
        description: "ntp peer #{@ntp_host} #{type}",
        tags: ['ntp'],
      )
    end
  end
end
{'fraction_non_alphanumeric': 0.15078985160363811, 'fraction_numerical': 0.00430828147438966, 'mean_word_length': 1.6157697121401753, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6505571', 'n_tokens_mistral': 691, 'n_tokens_neox': 682, 'n_words': 169}