From 0a6edebe277914a68e90ac72bbc74d15bcd1ab05 Mon Sep 17 00:00:00 2001 From: Michel Barbosa Date: Thu, 7 Jan 2010 18:01:39 +0100 Subject: [PATCH] made sure we skip non HODEL 3000 compliant lines from the log --- lib/oink/memory_usage_reporter.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/oink/memory_usage_reporter.rb b/lib/oink/memory_usage_reporter.rb index 8a39403..c11f7a2 100644 --- a/lib/oink/memory_usage_reporter.rb +++ b/lib/oink/memory_usage_reporter.rb @@ -6,6 +6,7 @@ module Oink class MemoryUsageReporter < Base + HODEL_LOG_FORMAT_REGEX = /^(\w+ \d{2} \d{2}:\d{2}:\d{2})/ def print(output) output.puts "---- MEMORY THRESHOLD ----" @@ -15,6 +16,9 @@ def print(output) @inputs.each do |input| input.each_line do |line| + # Skip this line since we're only interested in the Hodel 3000 compliant lines + next unless line =~ HODEL_LOG_FORMAT_REGEX + line = line.strip if line =~ /rails\[(\d+)\]/ @@ -44,7 +48,7 @@ def print(output) if memory_diff > @threshold @bad_actions[@pids[pid][:action]] ||= 0 @bad_actions[@pids[pid][:action]] = @bad_actions[@pids[pid][:action]] + 1 - date = /^(\w+ \d{2} \d{2}:\d{2}:\d{2})/.match(line).captures[0] + date = HODEL_LOG_FORMAT_REGEX.match(line).captures[0] @bad_requests.push(OinkedMemoryRequest.new(@pids[pid][:action], date, @pids[pid][:buffer], memory_diff)) if @format == :verbose @pids[pid][:buffer].each { |b| output.puts b }