<commit_before>
require 'em-sflow'
require 'socket'
require 'uri'


EM.run do

  # connect to remote carbon socket
  begin
    carbon_url = URI.parse(ENV['CARBON_URL'])
  rescue
    raise "missing CARBON_URL, e.g. carbon://localhost:2003"
  end
  begin
    carbon = TCPSocket.new(carbon_url.host, carbon_url.port)
  rescue
    raise "unable to connect to CARBON_URL at #{carbon_url}"
  end

  # see if we have a custom metrics prefix
  carbon_prefix = ENV['CARBON_PREFIX'] || nil

  # prep our DNS in-memory cache and resolver
  dns_cache = {}
  resolver = Resolv::DNS.new

  # listen for sflow datagrams
  collector = EventMachine::SFlow::Collector.new(:host => '0.0.0.0')

  # start our internal metrics timer
  total_metrics = 0
  EM::add_periodic_timer 5.0 do
    puts "number of metrics: #{total_metrics}"
    total_metrics = 0
  end

  wanted_metrics = {
    :if_in_ucast_pkts => true,
    :if_in_mcast_pkts => true,
    :if_in_bcast_pkts => true,
    :if_in_discards => true,
    :if_in_errors => true,
    :if_in_octets => true,
    :if_in_unknown_protocols => true,
    :if_out_ucast_pkts => true,
    :if_out_mcast_pkts => true,
    :if_out_bcast_pkts => true,
    :if_out_discards => true,
    :if_out_errors => true,
    :if_out_octets => true,
    :if_index => false,
    :if_type => false,
    :if_direction => false,
    :if_admin_status => false,
    :if_oper_status => false,
    :if_promiscuous => false,
  }<commit_msg>bump reporting interval; send to carbon socket 4 realz<commit_after>
require 'em-sflow'
require 'socket'
require 'uri'


EM.run do

  # connect to remote carbon socket
  begin
    carbon_url = URI.parse(ENV['CARBON_URL'])
  rescue
    raise "missing CARBON_URL, e.g. carbon://localhost:2003"
  end
  begin
    carbon = TCPSocket.new(carbon_url.host, carbon_url.port)
  rescue
    raise "unable to connect to CARBON_URL at #{carbon_url}"
  end

  # see if we have a custom metrics prefix
  carbon_prefix = ENV['CARBON_PREFIX'] || nil

  # prep our DNS in-memory cache and resolver
  dns_cache = {}
  resolver = Resolv::DNS.new

  # listen for sflow datagrams
  collector = EventMachine::SFlow::Collector.new(:host => '0.0.0.0')

  # start our internal metrics timer
  total_metrics = 0
  EM::add_periodic_timer 10.0 do
    carbon.puts "evenflow.metrics #{total_metrics} #{Time.now.to_i"
    total_metrics = 0
  end

  wanted_metrics = {
    :if_in_ucast_pkts => true,
    :if_in_mcast_pkts => true,
    :if_in_bcast_pkts => true,
    :if_in_discards => true,
    :if_in_errors => true,
    :if_in_octets => true,
    :if_in_unknown_protocols => true,
    :if_out_ucast_pkts => true,
    :if_out_mcast_pkts => true,
    :if_out_bcast_pkts => true,
    :if_out_discards => true,
    :if_out_errors => true,
    :if_out_octets => true,
    :if_index => false,
    :if_type => false,
    :if_direction => false,
    :if_admin_status => false,
    :if_oper_status => false,
    :if_promiscuous => false,
  }
{'fraction_non_alphanumeric': 0.11500510377679483, 'fraction_numerical': 0.008846546444368834, 'mean_word_length': 3.4410876132930515, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '44929', 'n_tokens_mistral': 1124, 'n_tokens_neox': 1093, 'n_words': 253}