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) ⇒ Checker
constructor
A new instance of Checker.
Constructor Details
#initialize(log_paths) ⇒ Checker
Returns a new instance of Checker.
114 115 116 |
# File 'lib/groonga-query-log/command/check-crash.rb', line 114 def initialize(log_paths) split_log_paths(log_paths) end |
Instance Method Details
#check ⇒ Object
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 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 |
# File 'lib/groonga-query-log/command/check-crash.rb', line 118 def check processes = ProcessEnumerator.new(@general_log_paths) processes.each do |process| need_query_log_parsing = true if process.successfully_finished? need_query_log_parsing = false p [:process, :success, process.version, process.start_time.iso8601, process.end_time.iso8601, process.pid, process.start_log_path, process.end_log_path] elsif process.crashed? p [:process, :crashed, process.version, process.start_time.iso8601, process.end_time.iso8601, process.pid, process.start_log_path, process.end_log_path] else p [:process, :unfinished, process.version, process.start_time.iso8601, process.pid, process.start_log_path] end unless process.n_leaks.zero? p [:leak, process.version, process.n_leaks, process.end_time.iso8601, process.pid, process.end_log_path] end unless process.important_entries.empty? puts("Important entries:") process.important_entries.each_with_index do |entry, i| puts("#{entry..iso8601}: " + "#{entry.log_level}: " + "#{entry.}") end 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? puts("Running queries:") target_parsing_statistics.each do |statistic| puts("#{statistic.start_time.iso8601}:") puts(statistic.command.to_command_format(pretty_print: true)) end end unless @unflushed_statistics.empty? puts("Unflushed commands in " + "#{start_time.iso8601}/#{end_time.iso8601}") @unflushed_statistics.each do |statistic| puts("#{statistic.start_time.iso8601}: #{statistic.raw_command}") end end end end |