Class: GroongaQueryLog::Command::CheckCrash::Checker
- Inherits:
-
Object
- Object
- GroongaQueryLog::Command::CheckCrash::Checker
- Defined in:
- lib/groonga-query-log/command/check-crash.rb
Instance Method Summary collapse
- #check ⇒ Object
-
#initialize(log_paths, options) ⇒ Checker
constructor
A new instance of Checker.
Constructor Details
#initialize(log_paths, options) ⇒ Checker
Returns a new instance of Checker.
143 144 145 146 |
# File 'lib/groonga-query-log/command/check-crash.rb', line 143 def initialize(log_paths, ) split_log_paths(log_paths) @options = end |
Instance Method Details
#check ⇒ Object
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
# File 'lib/groonga-query-log/command/check-crash.rb', line 148 def check summary = { crashed: false, unflushed: false, unfinished: false, leak: false, } processes = ProcessEnumerator.new(@general_log_paths) processes.each do |process| need_query_log_parsing = true if process.successfully_finished? need_query_log_parsing = false debug([:process, :success, process.version, process.start_time.iso8601, process.end_time.iso8601, process.pid, process.start_log_path, process.end_log_path].inspect) elsif process.crashed? debug([:process, :crashed, process.version, process.start_time.iso8601, process.end_time.iso8601, process.pid, process.start_log_path, process.end_log_path].inspect) summary[:crashed] = true else debug([:process, :unfinished, process.version, process.start_time.iso8601, process.pid, process.start_log_path].inspect) end unless process.n_leaks.zero? debug([:leak, process.version, process.n_leaks, process.end_time.iso8601, process.pid, process.end_log_path].inspect) summary[:leak] = true end unless process.important_entries.empty? output_important_entries_info(process.important_entries) end next unless need_query_log_parsing start_time = process.start_time end_time = process.end_time @flushed = true @unflushed_statistics = [] query_log_parser = Parser.new query_log_parser.parse_paths(@query_log_paths) do |statistic| next if statistic.start_time < start_time break if statistic.start_time > end_time check_query_log_statistic(query_log_parser.current_path, statistic) end parsing_statistics = query_log_parser.parsing_statistics target_parsing_statistics = parsing_statistics.reject do |statistic| statistic.start_time < start_time end unless target_parsing_statistics.empty? summary[:unfinished] = true output_unfinished_info(target_parsing_statistics) end unless @unflushed_statistics.empty? summary[:unflushed] = true output_unflushed_info(start_time, end_time) end end info("", "Summary:", summary.map {|k, v| "#{k}:#{v ? "yes" : "no"}" }.join(", ")) if summary.value?(true) info("NG: Please check the display and logs.") else info("OK: no problems.") end end |