Module: QmailLog

Defined in:
lib/qmail_log.rb,
lib/qmail_log/version.rb,
lib/qmail_log/analyzer.rb,
lib/qmail_log/formatter.rb,
lib/qmail_log/format/json.rb,
lib/qmail_log/format/ltsv.rb,
lib/qmail_log/format/yaml.rb,
lib/qmail_log/ssh/configure.rb,
lib/qmail_log/analyze/helper.rb

Defined Under Namespace

Modules: Analyze, Format, SSH Classes: Analyzer, Formatter

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.analyze(path, host = 'localhost', ssh_options = {}) ⇒ Object

Raises:

  • (Errno::ENOENT)


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/qmail_log.rb', line 17

def analyze path, host = 'localhost', ssh_options = {}
  QmailLog::SSH::Configure.backend(host, ssh_options)
  @runner = Specinfra::Runner

  raise Errno::ENOENT unless @runner.check_file_is_file(path) or @runner.check_file_is_directory(path)

  data, qid_from_did, memory = [], {}, {}

  files(path).each do |file|
    @runner.get_file_content(file).stdout.split("\n").each do |log|
      QmailLog::Analyzer.analyze(log, data, qid_from_did, memory)
    end
  end
  data
end

.files(path) ⇒ Object



37
38
39
# File 'lib/qmail_log.rb', line 37

def files path
  @runner.run_command("find #{path} -type f -exec ls -rt '{}' +").stdout.split("\n")
end

.parse(data, format = :json) ⇒ Object



33
34
35
# File 'lib/qmail_log.rb', line 33

def parse data, format = :json
  QmailLog::Formatter.run(format, data)
end