diff options
author | Ben Murdoch <benm@google.com> | 2011-05-05 14:36:32 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2011-05-10 15:38:30 +0100 |
commit | f05b935882198ccf7d81675736e3aeb089c5113a (patch) | |
tree | 4ea0ca838d9ef1b15cf17ddb3928efb427c7e5a1 /Tools/iExploder/iexploder-1.7.2/tools/lasthit.rb | |
parent | 60fbdcc62bced8db2cb1fd233cc4d1e4ea17db1b (diff) | |
download | external_webkit-f05b935882198ccf7d81675736e3aeb089c5113a.zip external_webkit-f05b935882198ccf7d81675736e3aeb089c5113a.tar.gz external_webkit-f05b935882198ccf7d81675736e3aeb089c5113a.tar.bz2 |
Merge WebKit at r74534: Initial merge by git.
Change-Id: I6ccd1154fa1b19c2ec2a66878eb675738735f1eb
Diffstat (limited to 'Tools/iExploder/iexploder-1.7.2/tools/lasthit.rb')
-rwxr-xr-x | Tools/iExploder/iexploder-1.7.2/tools/lasthit.rb | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/Tools/iExploder/iexploder-1.7.2/tools/lasthit.rb b/Tools/iExploder/iexploder-1.7.2/tools/lasthit.rb new file mode 100755 index 0000000..d792d1b --- /dev/null +++ b/Tools/iExploder/iexploder-1.7.2/tools/lasthit.rb @@ -0,0 +1,74 @@ +#!/usr/bin/ruby +# Copyright 2010 Thomas Stromberg - All Rights Reserved. +# +# 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 permissions and +# limitations under the License. +# +# +# +# lasthit, part of iExploder +# +# Shows statistics about recent agents that have tested with iExploder. +# It takes all or part of an apache logfile via stdin, and outputs a list +# of all the agents who tested within that section, what their last test +# was, and how many tests they have done. + +# The usefulness is finding out where a browser crashed. + +require 'cgi' + +hostHash = Hash.new + +if (ARGV[0]) + file = File.open(ARGV[0]) +else + puts "No filename specified, waiting for data via stdin..." + file = $stdin +end + +last_index = nil +file.readlines.each_with_index { |line, index| + # filter out mime hits as they produce a lot of odd user agents + next if line =~ /&m=/ + if (line =~ /([\w\.]+) - - .*iexploder.cgi\?(.*?)&b=([\w\%-\.+]+)/) + host = $1 + test_url = $2 + agent = $3 + if (! hostHash[host]) + hostHash[host] = Hash.new + end + if (! hostHash[host][agent]) + hostHash[host][agent] = Hash.new + hostHash[host][agent]['total'] = 0 + end + hostHash[host][agent]['last'] = test_url + hostHash[host][agent]['total'] = hostHash[host][agent]['total'] + 1 + hostHash[host][agent]['last_line'] = index + end + last_index = index +} + +printf("%-14.14s | %-25.25s | %6.6s | %7.7s | %s\n", + "Host", "Test URL", "Total", "LineAgo", "Agent") +puts "-" * 78 +hostHash.each_key { |host| + hostHash[host].each_key { |agent| + next if agent.length < 8 + display_agent = CGI::unescape(agent).sub('U; ', '') + printf("%-14.14s | %-25.25s | %6.6s | %7.7s | %s\n", + host, hostHash[host][agent]['last'], + hostHash[host][agent]['total'], + hostHash[host][agent]['last_line'] - last_index, + display_agent); + } +} + |