<commit_before># system_poller.rb - real implementation on linux shell commands. Acts as a wrapper, which can be overriden.

require 'logger'

class SystemPoller
  def initialize
    @logger = Logger.new(STDOUT)
    @logger.level = Logger::INFO
  end

  def get_devices
    cmd = 'hdparm /dev/sd? | grep "/dev/"'

    @logger.info("[SystemPoller][get_devices] Executing #{cmd}...")
    out = `#{cmd}`

    # Command failures
    if $?.to_i != 0
      @logger.error("[SystemPoller][get_devices] Command terminated abnormally: #{$?}")
      raise('Unable to get disk devices properly')
    end

    @logger.info("[SystemPoller][get_devices] Command ended. Output: #{out}")
    out
  end

  def get_model_numbers
    # hdparm -I /dev/sd? | grep "Model Number:"

  end

  def get_sizes_megabytes
    # hdparm -I /dev/sd? | grep "1024:"

  end

  def get_temperature_celsius(device)
    # smartctl -A | grep "Temperature_Celsius"

  end
end<commit_msg>[SMRT-10.1] Real polling of disk list<commit_after># system_poller.rb - real implementation on linux shell commands. Acts as a wrapper, which can be overriden.

require 'logger'

class SystemPoller
  def initialize
    @logger = Logger.new(STDOUT)
    @logger.level = Logger::INFO
  end

  def get_devices
    cmd = 'hdparm /dev/sd? | grep "/dev/"'

    @logger.info("[SystemPoller][get_devices] Executing #{cmd}...")
    out = `#{cmd}`

    # Command failures
    if $?.to_i != 0
      @logger.error("[SystemPoller][get_devices] Command terminated abnormally: #{$?}")
      raise('Unable to get disk devices properly')
    end

    @logger.info("[SystemPoller][get_devices] Command ended. Output: #{out}")
    out
  end

  def get_model_numbers
    cmd = 'hdparm -I /dev/sd? | grep "Model Number:"'

    @logger.info("[SystemPoller][get_model_numbers] Executing #{cmd}...")
    out = `#{cmd}`

    # Command failures
    if $?.to_i != 0
      @logger.error("[SystemPoller][get_model_numbers] Command terminated abnormally: #{$?}")
      raise('Unable to get disk model numbers properly')
    end

    @logger.info("[SystemPoller][get_model_numbers] Command ended. Output: #{out}")
    out
  end

  def get_sizes_megabytes
    cmd = 'hdparm -I /dev/sd? | grep "1024:"'

    @logger.info("[SystemPoller][get_sizes_megabytes] Executing #{cmd}...")
    out = `#{cmd}`

    # Command failures
    if $?.to_i != 0
      @logger.error("[SystemPoller][get_sizes_megabytes] Command terminated abnormally: #{$?}")
      raise('Unable to get disk sizes properly')
    end

    @logger.info("[SystemPoller][get_sizes_megabytes] Command ended. Output: #{out}")
    out
  end

  def get_temperature_celsius(device)
    cmd = 'smartctl -A | grep "Temperature_Celsius"'

    @logger.info("[SystemPoller][get_temperature_celsius] Executing #{cmd}...")
    out = `#{cmd}`

    # Command failures
    if $?.to_i != 0
      @logger.error("[SystemPoller][get_temperature_celsius] Command terminated abnormally: #{$?}")
      raise('Unable to get disk temperatures properly')
    end

    @logger.info("[SystemPoller][get_temperature_celsius] Command ended. Output: #{out}")
    out
  end
end
{'fraction_non_alphanumeric': 0.140795381654907, 'fraction_numerical': 0.005131494547787043, 'mean_word_length': 3.4620886981402004, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5920375', 'n_tokens_mistral': 1100, 'n_tokens_neox': 1032, 'n_words': 263}