Module: JvmwatcherUtil
- Defined in:
- lib/fluent/plugin/jvmwatcher_util.rb
Overview
A Java VM status Watcher for Fluent
Copyright © 2013 Masayuki Miyake
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing and
limitations under the License.
Constant Summary collapse
- SetEnvFileName =
"setEnvWatcher.sh"- Log4JFileName =
"log4j.xml"- SetEnvTemplateFileName =
"setEnv.sh.template"- Log4JTemplateFileName =
"log4j.xml.template"- BinDirName =
"bin"- LibDirName =
"lib"- ConfigDirName =
"config"- LogDirName =
"log"
Class Method Summary collapse
- .find_filter_config_path(config_path) ⇒ Object
- .find_watcher_java_path(dir_name, file_name = nil) ⇒ Object
- .make_log4j_file ⇒ Object
- .make_setenv_file ⇒ Object
Class Method Details
.find_filter_config_path(config_path) ⇒ Object
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/fluent/plugin/jvmwatcher_util.rb', line 125 def find_filter_config_path (config_path) # check nil return "NO_CONFIG" unless config_path unless File.file?(config_path) path = find_watcher_java_path(ConfigDirName) config_path = File.join(path, config_path) config_path = "NO_CONFIG" unless File.file?(config_path) end return config_path end |
.find_watcher_java_path(dir_name, file_name = nil) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/fluent/plugin/jvmwatcher_util.rb', line 30 def find_watcher_java_path (dir_name, file_name = nil) java_path = nil # find java command path $LOAD_PATH.map do |load_path| path = File.join(load_path, "fluent/plugin") # make fluentd plugin path if File.directory?(path) # find target java directory path_name = "#{path}/jvmwatcher/#{dir_name}" next unless File.directory?(path_name) # chech directory if file_name # check file java_path = File.join(path_name, file_name) java_path = nil unless File.file?(java_path) else java_path = path_name end break if java_path end end return java_path end |
.make_log4j_file ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/fluent/plugin/jvmwatcher_util.rb', line 94 def make_log4j_file template_path = find_watcher_java_path(ConfigDirName, Log4JTemplateFileName) output_path = find_watcher_java_path(ConfigDirName) log_path = find_watcher_java_path(LogDirName) # path nil check return nil unless template_path return nil unless output_path return nil unless log_path output_path = File.join(output_path, Log4JFileName) # make setEnvWatcher.sh temp_io = File.open(template_path, "r") env_io = File.open(output_path, "w") temp_io.each do |line| line.chomp! line = line.gsub(/\[LOG_PATH\]/, log_path) env_io.puts(line) end temp_io.close env_io.close return output_path end |
.make_setenv_file ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/fluent/plugin/jvmwatcher_util.rb', line 60 def make_setenv_file template_path = find_watcher_java_path(BinDirName, SetEnvTemplateFileName) output_path = find_watcher_java_path(BinDirName) lib_path = find_watcher_java_path(LibDirName) config_path = find_watcher_java_path(ConfigDirName) # path nil check return nil unless template_path return nil unless output_path return nil unless lib_path return nil unless config_path output_path = File.join(output_path, SetEnvFileName) # make setEnvWatcher.sh temp_io = File.open(template_path, "r") env_io = File.open(output_path, "w") temp_io.each do |line| line.chomp! line = line.gsub(/\[LIB_PATH\]/, lib_path) line = line.gsub(/\[CONFIG_PATH\]/, config_path) env_io.puts(line) end temp_io.close env_io.close return output_path end |