Skip to content

Instantly share code, notes, and snippets.

Created May 2, 2015 19:10
Show Gist options
  • Save anonymous/b733dd99a49f7036a6f6 to your computer and use it in GitHub Desktop.
Save anonymous/b733dd99a49f7036a6f6 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
require 'date'
session = Hash.new
time = Array.new
parseapache = /.*\[(.*) .*\].* ([a-zA-Z0-9]+)$/
File.open("test1000").each do |line|
matches = parseapache.match(line)
if matches
if !(session[matches[2]])
session[matches[2]] = Array.new
session[matches[2]] << DateTime.strptime(matches[1], "%d/%b/%Y:%H:%M:%S")
else
session[matches[2]] << DateTime.strptime(matches[1], "%d/%b/%Y:%H:%M:%S")
end
end
end
session.map { |k, v| [k, v.sort] }.to_h
session.each do |key, value|
all_duration = value[-1] - value[0]
if all_duration > 1800
value.each do |x, y|
if y - x > 1800
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment