<commit_before>class LoadAverages < Scout::Plugin
  TEST_USAGE = "#{File.basename($0)} max_load MAX_LOAD"
  
   def run
    data = {}
    data[:alerts] = []
    if `uptime` =~ /load average(s*): ([\d.]+)(,*) ([\d.]+)(,*) ([\d.]+)\Z/
      data[:report] = { :last_minute          => $2,
                        :last_five_minutes    => $4,
                        :last_fifteen_minutes => $6 }
    else
      raise "Unexpected output format"  
    end
    if @options['max_load'] and data[:report][:last_minute].to_f > @options['max_load'].to_f
      data[:alerts] << {:subject => "Maximum Load Exceeded (#{data[:report][:last_minute]})"}
    end
    data
  rescue
    {:error => {:subject => "Couldn't use `uptime` as expected.", :body => $!.message} }
  end
end<commit_msg>Updating load averages to use new agent interface<commit_after># 
# This is a real plugin updated to use our newer interface:
# 
#   http://scoutapp.com/plugin_urls/static/creating_a_plugin
# 
class LoadAverages < ScoutAgent::Plugin
  TEST_USAGE = "#{File.basename($0)} max_load MAX_LOAD"

   def build_report
     if `uptime` =~ /load average(s*): ([\d.]+)(,*) ([\d.]+)(,*) ([\d.]+)\Z/
       report :last_minute          => $2,
              :last_five_minutes    => $4,
              :last_fifteen_minutes => $6
     else
       raise "Unexpected output format"  
     end
     if option(:max_load) and
        reports.last[:last_minute].to_f > option(:max_load).to_f
       alert "Maximum Load Exceeded (#{reports.last[:last_minute]})", ""
     end
  rescue Exception
    error "Couldn't use `uptime` as expected.", $!.message
  end
end
{'fraction_non_alphanumeric': 0.1697645600991326, 'fraction_numerical': 0.004956629491945477, 'mean_word_length': 2.6956521739130435, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, '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': '4203286', 'n_tokens_mistral': 563, 'n_tokens_neox': 542, 'n_words': 126}