Class: Macklog::Cli

Inherits:
Thor
  • Object
show all
Defined in:
lib/macklog/cli.rb

Instance Method Summary collapse

Instance Method Details

#checkObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/macklog/cli.rb', line 9

def check
  # exit code
  # 0:OK
  # 1:WARNING
  # 2:CRITICAL
  # 3:UNKNOWN
 
  file_path = File.expand_path(options[:file])

  unless File.exist?(file_path)
    puts "#{file_path} not found!"
    exit_status 3
  end
  
  result = log_search(file_path, options[:word] , options[:ignorecase])
  
  if result && !notified?(file_path, result)
    exit_status 2
  end
end