Class: Takuhai::Core

Inherits:
Object
  • Object
show all
Defined in:
lib/takuhai_core.rb

Constant Summary collapse

TAKUHAI_FILE =
"Takuhaifile"
TAKUHAI_TEMPLATE =
<<-EOS
# encoding: utf-8

# write your ssh login user name. this attribute is required.
# ex:user "app"
user "TODO: user"

# write your ssh login server_name name or ip. this attribute is required.
# ex1:server "some_server"
# ex2:user "192.168.10.11"
server "TODO: server"

# write your targets. this attribute is required.
# ex1:targets "app.log-2011-10-*"
# ex2:targets "app.log-2011-10-01 app.log-2011-10-02 app.log-2011-10-05"
targets "TODO: targets"

# write your log directory. this attribute is required.
# ex:target_dir "/home/app/some_system/log/production"
target_dir "TODO: target_dir"

# write your output_base_name.this value is using in tarball file name and output file name. this attribute is required.
# ex:output_base_name "server_log"
output_base_name "output"

# write output file's extension.this attribute is required.
# ex:output_extension "tsv"
output_extension "txt"

# if you want to execute some logic for line data, edit following code. this attribute is option.
# ex: if line have "ERROR", append !!ERROR!! to line String.
# block do |file, line|
#   line = "!!ERROR!!" + line if line.include?("ERROR")
#   line
# end
block do |file, line|
  line
end
EOS

Instance Method Summary collapse

Instance Method Details

#collectObject



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/takuhai_core.rb', line 53

def collect
  src = read_collect_define
  @dsl = Takuhai::Dsl.new
  @dsl.instance_eval src

  @outtime = DateTime.now.strftime("%Y%m%d%H%M%S")
  @target_dir_name = "#{@dsl._output_base_name}#{@outtime}"
  @tar_gz_name = "#{@dsl._output_base_name}.#{@outtime}.tar.gz"

  tar_compress_log
  down_load_tar
  create_target_dir
  move_tar
  move_to_target_dir
  extract_tar
  
end

#initObject



49
50
51
# File 'lib/takuhai_core.rb', line 49

def init
  File.open(TAKUHAI_FILE, "w") {|f|f.puts TAKUHAI_TEMPLATE}
end