<commit_before># Encoding utf-8
Ohai.plugin(:Sophos) do
  provides 'sophos'

  def sophos_bin()
    if File.exist?('/opt/sophos-av/bin/savdstatus')
      return true
    end
  end

  def get_sophos_data()
    sophos Mash.new
    so = shell_out("/opt/sophos-av/bin/savdstatus --version")
    so.stdout.lines do |line|
      version = /Sophos Anti-Virus[[:space:]]+=[[:space:]]([[[:digit:]].]+)/.match(line)
        if version
          sophos['version'] = version[1]
          next
        end
      last_update = /Last update[[:space:]]+=[[:space:]](.*)/.match(line)
      if last_update
        sophos['update'] = Date.strptime(last_update[1], format='%a %d %b %Y %r %Z')
      end
    end

    return sophos<commit_msg>finished work on sophos plugin, to return last update date and version<commit_after># Encoding utf-8
Ohai.plugin(:Sophos) do
  require 'date'
  provides 'sophos'

  def sophos_bin()
    if File.exist?('/opt/sophos-av/bin/savdstatus')
      return true
    end
  end

  def get_sophos_data()
    sophos Mash.new
    so = shell_out("/opt/sophos-av/bin/savdstatus --version")
    so.stdout.lines do |line|
      version = /Sophos Anti-Virus[[:space:]]+=[[:space:]]+([0-9.]+)/.match(line)
        if version
          sophos[:version] = version[1]
          next
        end
      last_update = /Last update[[:space:]]+=[[:space:]]+(.*)/.match(line)
      if last_update

        datetime = /[[:alpha:]]{3} ([[:alpha:]]{3})[[:space:]]{1,2}([[:digit:]]{1,2}) ([[:digit:]]{2}):([[:digit:]]{2}):([[:digit:]]{2}) ([[:digit:]]{4})/.match(last_update[1])

        month = Date::ABBR_MONTHNAMES.index(datetime[1])
        day = datetime[2].to_i
        hour = datetime[3].to_i
        minute = datetime[4].to_i
        second = datetime[5].to_i
        year = datetime[6].to_i
        update_date = Mash.new
        update_date[:time] = "%2d:%2d:%2d" % [ hour, minute, second ]
        update_date[:date] = {
          'day' => "%2d" % day,
          'month' => "%2d" % month,
          'year' => "%4d" % year
        }
        sophos[:last_update] = update_date
      end
    end

    return sophos
{'fraction_non_alphanumeric': 0.19108582266477003, 'fraction_numerical': 0.01422475106685633, 'mean_word_length': 2.594548551959114, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '5785944', 'n_tokens_mistral': 797, 'n_tokens_neox': 774, 'n_words': 142}