<commit_before>require 'memcached'
class MemcachedClient < Memcached
end

module CoppereggAgents

  class Plugin::Memcached < Plugin

    def metrics_schema
      [
          {:type => 'ce_counter', :name => 'cmd_get', :position => 0, :label => 'cmd_get'},
          {:type => 'ce_counter', :name => 'cmd_set', :position => 1, :label => 'cmd_set'},
          {:type => 'ce_counter', :name => 'get_misses', :position => 2, :label => 'get_misses'},
          {:type => 'ce_gauge', :name => 'limit_maxbytes', :position => 3, :label => 'limit_maxbytes', :unit => 'b'},
          {:type => 'ce_gauge', :name => 'bytes', :position => 4, :label => 'bytes', :unit => 'b'},
      ]
    end

    def monitor(server)
      cache = MemcachedClient.new(server['hostname'] + ':' + server['port'].to_s)
      stats = cache.stats

      data = {}
      metrics_names.each do |key|
        data[key] = stats[key.to_sym].shift.to_s
      end
      data
    end
  end
end<commit_msg>Memcache plugin should return INTs<commit_after>require 'memcached'
class MemcachedClient < Memcached
end

module CoppereggAgents

  class Plugin::Memcached < Plugin

    def metrics_schema
      [
          {:type => 'ce_counter', :name => 'cmd_get', :position => 0, :label => 'cmd_get'},
          {:type => 'ce_counter', :name => 'cmd_set', :position => 1, :label => 'cmd_set'},
          {:type => 'ce_counter', :name => 'get_misses', :position => 2, :label => 'get_misses'},
          {:type => 'ce_gauge', :name => 'limit_maxbytes', :position => 3, :label => 'limit_maxbytes', :unit => 'b'},
          {:type => 'ce_gauge', :name => 'bytes', :position => 4, :label => 'bytes', :unit => 'b'},
      ]
    end

    def monitor(server)
      cache = MemcachedClient.new(server['hostname'] + ':' + server['port'].to_s)
      stats = cache.stats

      data = {}
      metrics_names.each do |key|
        data[key] = stats[key.to_sym].shift.to_i
      end
      data
    end
  end
end
{'fraction_non_alphanumeric': 0.1836839404822986, 'fraction_numerical': 0.00513083632632119, 'mean_word_length': 2.907815631262525, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 47, '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': '7473907', 'n_tokens_mistral': 669, 'n_tokens_neox': 642, 'n_words': 155}