<commit_before>require 'rubygems'
require 'net/ping'

include Net

Ping::TCP.service_check = true

#add several hosts you want to ping
hosts = ['192.168.2.109', '192.168.2.5']
threads = []
ping_objects = []

hosts.each do |ip|
   ping_objects << Net::Ping::TCP.new(ip)
   threads << Thread.new(ip, ping_objects.last) do |ip, p|
     loop do
      if p.ping == true
        puts "#{ip}"
        # execute commands
        else
        # sleeptime if no host is available
        sleep 240
      end

       sleep 2
     end
   end
end
threads.each { |th| th.join }
<commit_msg>changed sleep time and added a status variable<commit_after>require 'rubygems'
require 'net/ping'

include Net

Ping::TCP.service_check = true

#add several hosts you want to ping
hosts = ['192.168.2.109', '192.168.2.5']
threads = []
ping_objects = []
status = false
hosts.each do |ip|
   ping_objects << Net::Ping::TCP.new(ip)
   threads << Thread.new(ip, ping_objects.last) do |ip, p|
     loop do
      if p.ping == true
        status = true
        else
        # sleeptime if no host is available
        sleep 240
      end
      #execute commands
      sleep 180
     end
   end
end
threads.each { |th| th.join }

{'fraction_non_alphanumeric': 0.1161236424394319, 'fraction_numerical': 0.03842940685045948, 'mean_word_length': 2.4825581395348837, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, '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': '1402148', 'n_tokens_mistral': 444, 'n_tokens_neox': 401, 'n_words': 125}