<commit_before>#!/usr/bin/env ruby
#
#  metrics-ipvs
#
# DESCRIPTION:
#   This plugin get metrics for ipvs
#
# OUTPUT:
#   plain text
#
# PLATFORMS:
#   Linux
#
# DEPENDENCIES:
#   gem: sensu-plugin
#
# USAGE:
#   metrics-ipvs
#
# NOTES:
#
# LICENSE:
#   <NAME>    <https://github.com/mag009>
#   Released under the same terms as Sensu (the MIT license); see LICENSE
#   for details.
#
require 'sensu-plugin/metric/cli'
require 'socket'

class Graphite < Sensu::Plugin::Metric::CLI::Graphite
  option :scheme,
    description: 'Metric naming scheme, text to prepend to metric',
    short: '-s SCHEME',
    long: '--scheme SCHEME',
    default: "#{Socket.gethostbyname("#{Socket.gethostname}").first}.ipvs.stats"

  def run
    if !ipvs_output.nil?
      ipvs = metrics_hash(ipvs_output)
      metrics = [ "TotalConn", "IncomingPkts", "OutgoingPkts", "IncomingBytes", "OutgoingBytes", "Conns_per_sec", "Pkts_per_sec", "IncomingBytes_per_sec", "OutgoingBytes_per_sec" ]
      c = 0
      metrics.each do |parent|
        output [config[:scheme], parent].join('.'), ipvs[c].hex
        c += 1
      end
    end
    ok
  end

  def metrics_hash(output)
    ipvs = Array.new
    output.each_line do |line|
      line.chomp!
      next if line.empty? || !(line.split & ipvs).empty?
      ipvs.push(line.gsub(/\s+/, ' ').rstrip.split(' '))
    end
    ipvs.join('.').split('.')
  end

  def ipvs_output
    if File.exists?('/proc/net/ip_vs_stats')
      output=`cat /proc/net/ip_vs_stats | egrep -v "Total|Conns"`
    end
  end
end<commit_msg>fixing syntax for Travis CI<commit_after>#!/usr/bin/env ruby
#
#  metrics-ipvs
#
# DESCRIPTION:
#   This plugin get metrics for ipvs
#
# OUTPUT:
#   plain text
#
# PLATFORMS:
#   Linux
#
# DEPENDENCIES:
#   gem: sensu-plugin
#
# USAGE:
#   metrics-ipvs
#
# NOTES:
#
# LICENSE:
#   <NAME>    <https://github.com/mag009>
#   Released under the same terms as Sensu (the MIT license); see LICENSE
#   for details.
#
require 'sensu-plugin/metric/cli'
require 'socket'

#
#
#
class Graphite < Sensu::Plugin::Metric::CLI::Graphite
  option :scheme,
         description: 'Metric naming scheme, text to prepend to metric',
         short: '-s SCHEME',
         long: '--scheme SCHEME',
         default: "#{Socket.gethostbyname("#{Socket.gethostname}").first}.ipvs.stats"

  def run
    unless ipvs_output.nil?
      ipvs = metrics_hash(ipvs_output)
      metrics = ['TotalConn','IncomingPkts','OutgoingPkts','IncomingBytes','OutgoingBytes','Conns_per_sec','Pkts_per_sec','IncomingBytes_per_sec','OutgoingBytes_per_sec']
      c = 0
      metrics.each do |parent|
        output [config[:scheme], parent].join('.'), ipvs[c].hex
        c += 1
      end
    end
    ok
  end

  def metrics_hash(output)
    ipvs = []
    output.each_line do |line|
      line.chomp!
      next if line.empty? || !(line.split & ipvs).empty?
      ipvs.push(line.gsub(/\s+/, ' ').rstrip.split(' '))
    end
    ipvs.join('.').split('.')
  end

  def ipvs_output
    if File.exists?('/proc/net/ip_vs_stats')
      output = `cat /proc/net/ip_vs_stats | egrep -v "Total|Conns"`
    end
  end
end
{'fraction_non_alphanumeric': 0.15387096774193548, 'fraction_numerical': 0.0032258064516129032, 'mean_word_length': 3.043024771838331, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 2, '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': '3349890', 'n_tokens_mistral': 1169, 'n_tokens_neox': 1153, 'n_words': 245}