<commit_before>require 'riemann/tools'
require 'riemann/tools/utils'

class Riemann::Tools::Health
  include Riemann::Tools
  include Riemann::Tools::Utils

  opt :cpu_warning, "CPU warning threshold (fraction of total jiffies)", :default => 0.9
  opt :cpu_critical, "CPU critical threshold (fraction of total jiffies)", :default => 0.95
  opt :disk_warning, "Disk warning threshold (fraction of space used)", :default => 0.9
  opt :disk_critical, "Disk critical threshold (fraction of space used)", :default => 0.95
  opt :disk_ignorefs, "A list of filesystem types to ignore", :default => ['iso9660', 'nfs']
  opt :load_warning, "Load warning threshold (load average / core)", :default => 3
  opt :load_critical, "Load critical threshold (load average / core)", :default => 8
  opt :memory_warning, "Memory warning threshold (fraction of RAM)", :default => 0.85
  opt :memory_critical, "Memory critical threshold (fraction of RAM)", :default => 0.95
  opt :checks, "A list of checks to run.", :type => :strings, :default => ['cpu', 'load', 'memory', 'disk']

  def initialize
    @limits = {
      :cpu => {:critical => opts[:cpu_critical], :warning => opts[:cpu_warning]},
      :disk => {:critical => opts[:disk_critical], :warning => opts[:disk_warning]},
      :load => {:critical => opts[:load_critical], :warning => opts[:load_warning]},
      :memory => {:critical => opts[:memory_critical], :warning => opts[:memory_warning]}
    }
    case (@ostype = `uname -s`.chomp.downcase)
    when 'darwin'
      @cores = `sysctl -n hw.ncpu`.to_i
      @cpu = method :darwin_cpu
      @disk = method :disk
      @load = method :darwin_load
      @memory = method :darwin_memory
      darwin_top
    when 'freebsd'
      @cores = `sysctl -n hw.ncpu`.to_i
      @cpu = method :freebsd_cpu
      @disk = method :disk
      @load = method :bsd_load
      @memory = method :freebsd_memory
    when 'openbsd'<commit_msg>Update the list of ignored filesystems<commit_after>require 'riemann/tools'
require 'riemann/tools/utils'

class Riemann::Tools::Health
  include Riemann::Tools
  include Riemann::Tools::Utils

  opt :cpu_warning, "CPU warning threshold (fraction of total jiffies)", :default => 0.9
  opt :cpu_critical, "CPU critical threshold (fraction of total jiffies)", :default => 0.95
  opt :disk_warning, "Disk warning threshold (fraction of space used)", :default => 0.9
  opt :disk_critical, "Disk critical threshold (fraction of space used)", :default => 0.95
  opt :disk_ignorefs, "A list of filesystem types to ignore", :default => ['anon_inodefs', 'autofs', 'cd9660', 'devfs', 'devtmpfs', 'fdescfs', 'iso9660', 'linprocfs', 'linsysfs', 'nfs', 'procfs']
  opt :load_warning, "Load warning threshold (load average / core)", :default => 3
  opt :load_critical, "Load critical threshold (load average / core)", :default => 8
  opt :memory_warning, "Memory warning threshold (fraction of RAM)", :default => 0.85
  opt :memory_critical, "Memory critical threshold (fraction of RAM)", :default => 0.95
  opt :checks, "A list of checks to run.", :type => :strings, :default => ['cpu', 'load', 'memory', 'disk']

  def initialize
    @limits = {
      :cpu => {:critical => opts[:cpu_critical], :warning => opts[:cpu_warning]},
      :disk => {:critical => opts[:disk_critical], :warning => opts[:disk_warning]},
      :load => {:critical => opts[:load_critical], :warning => opts[:load_warning]},
      :memory => {:critical => opts[:memory_critical], :warning => opts[:memory_warning]}
    }
    case (@ostype = `uname -s`.chomp.downcase)
    when 'darwin'
      @cores = `sysctl -n hw.ncpu`.to_i
      @cpu = method :darwin_cpu
      @disk = method :disk
      @load = method :darwin_load
      @memory = method :darwin_memory
      darwin_top
    when 'freebsd'
      @cores = `sysctl -n hw.ncpu`.to_i
      @cpu = method :freebsd_cpu
      @disk = method :disk
      @load = method :bsd_load
      @memory = method :freebsd_memory
    when 'openbsd'
{'fraction_non_alphanumeric': 0.1493933265925177, 'fraction_numerical': 0.012133468149646108, 'mean_word_length': 3.989911727616646, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 49, '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': '2945216', 'n_tokens_mistral': 1310, 'n_tokens_neox': 1197, 'n_words': 387}