File: lasthit.rb

package info (click to toggle)
qtwebkit-opensource-src 5.7.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 291,692 kB
  • ctags: 268,122
  • sloc: cpp: 1,360,420; python: 70,286; ansic: 42,986; perl: 35,476; ruby: 12,236; objc: 9,465; xml: 8,396; asm: 3,873; yacc: 2,397; sh: 1,647; makefile: 650; lex: 644; java: 110
file content (53 lines) | stat: -rwxr-xr-x 1,426 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/ruby
# 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.


hostHash = Hash.new

if (ARGV[0])
	file = File.open(ARGV[0])
else
	file = $stdin
end
 
file.readlines.each { |line|
	if (line =~ /^(.*?) .*iexploder.*?test=(\d+).* HTTP.* \"(.*?)\"$/)
		host = $1
		testnum = $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'] = testnum
		if line =~ /subtest=(\d+)/
			hostHash[host][agent]['subtest'] = $1
		else
			hostHash[host][agent]['subtest'] = ''
		end
		hostHash[host][agent]['total'] = hostHash[host][agent]['total'] + 1
	end
}

printf("%14.14s | %8.8s | %3.3s | %8.8s | %s\n", 
	 "IP",    "Test", "SubTest", "Total", "Agent")
puts "---------------------------------------------------------------------------"
hostHash.each_key { |host|

	hostHash[host].each_key { |agent|
		printf("%14.14s | %8.8s | %3.3s | %8.8s | %s\n", 
			host, hostHash[host][agent]['last'],  hostHash[host][agent]['subtest'], hostHash[host][agent]['total'], agent);
	}
}