Class: IISAccessLogParser::Entry
- Inherits:
-
Struct
- Object
- Struct
- IISAccessLogParser::Entry
- Defined in:
- lib/iis-access-log-parser.rb,
lib/iis-access-log-parser.rb
Overview
Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) sc-status sc-substatus sc-win32-status time-taken
Instance Attribute Summary collapse
-
#client_ip ⇒ Object
Returns the value of attribute client_ip.
-
#date ⇒ Object
Returns the value of attribute date.
-
#method ⇒ Object
Returns the value of attribute method.
-
#other ⇒ Object
Returns the value of attribute other.
-
#port ⇒ Object
Returns the value of attribute port.
-
#query ⇒ Object
Returns the value of attribute query.
-
#server_ip ⇒ Object
Returns the value of attribute server_ip.
-
#status ⇒ Object
Returns the value of attribute status.
-
#substatus ⇒ Object
Returns the value of attribute substatus.
-
#time_taken ⇒ Object
Returns the value of attribute time_taken.
-
#url ⇒ Object
Returns the value of attribute url.
-
#user_agent ⇒ Object
Returns the value of attribute user_agent.
-
#username ⇒ Object
Returns the value of attribute username.
-
#win32_status ⇒ Object
Returns the value of attribute win32_status.
Class Method Summary collapse
Instance Attribute Details
#client_ip ⇒ Object
Returns the value of attribute client_ip
6 7 8 |
# File 'lib/iis-access-log-parser.rb', line 6 def client_ip @client_ip end |
#date ⇒ Object
Returns the value of attribute date
6 7 8 |
# File 'lib/iis-access-log-parser.rb', line 6 def date @date end |
#method ⇒ Object
Returns the value of attribute method
6 7 8 |
# File 'lib/iis-access-log-parser.rb', line 6 def method @method end |
#other ⇒ Object
Returns the value of attribute other
6 7 8 |
# File 'lib/iis-access-log-parser.rb', line 6 def other @other end |
#port ⇒ Object
Returns the value of attribute port
6 7 8 |
# File 'lib/iis-access-log-parser.rb', line 6 def port @port end |
#query ⇒ Object
Returns the value of attribute query
6 7 8 |
# File 'lib/iis-access-log-parser.rb', line 6 def query @query end |
#server_ip ⇒ Object
Returns the value of attribute server_ip
6 7 8 |
# File 'lib/iis-access-log-parser.rb', line 6 def server_ip @server_ip end |
#status ⇒ Object
Returns the value of attribute status
6 7 8 |
# File 'lib/iis-access-log-parser.rb', line 6 def status @status end |
#substatus ⇒ Object
Returns the value of attribute substatus
6 7 8 |
# File 'lib/iis-access-log-parser.rb', line 6 def substatus @substatus end |
#time_taken ⇒ Object
Returns the value of attribute time_taken
6 7 8 |
# File 'lib/iis-access-log-parser.rb', line 6 def time_taken @time_taken end |
#url ⇒ Object
Returns the value of attribute url
6 7 8 |
# File 'lib/iis-access-log-parser.rb', line 6 def url @url end |
#user_agent ⇒ Object
Returns the value of attribute user_agent
6 7 8 |
# File 'lib/iis-access-log-parser.rb', line 6 def user_agent @user_agent end |
#username ⇒ Object
Returns the value of attribute username
6 7 8 |
# File 'lib/iis-access-log-parser.rb', line 6 def username @username end |
#win32_status ⇒ Object
Returns the value of attribute win32_status
6 7 8 |
# File 'lib/iis-access-log-parser.rb', line 6 def win32_status @win32_status end |
Class Method Details
.from_string(line) ⇒ Object
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 |
# File 'lib/iis-access-log-parser.rb', line 8 def self.from_string(line) # 2011-06-20 00:00:00 83.222.242.43 GET /SharedControls/getListingThumbs.aspx img=48,13045,27801,25692,35,21568,21477,21477,10,18,46,8&premium=0|1|0|0|0|0|0|0|0|0|0|0&h=100&w=125&pos=175&scale=true 80 - 92.20.10.104 Mozilla/4.0+(compatible;+MSIE+8.0;+Windows+NT+6.1;+Trident/4.0;+GTB6.6;+SLCC2;+.NET+CLR+2.0.50727;+.NET+CLR+3.5.30729;+.NET+CLR+3.0.30729;+Media+Center+PC+6.0;+aff-kingsoft-ciba;+.NET4.0C;+MASN;+AskTbSTC/5.8.0.12304) 200 0 0 609 x, date, server_ip, method, url, query, port, username, client_ip, user_agent, status, substatus, win32_status, time_taken, y, other = *line.match(/^([^ ]* [^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*)($| )(.*)/) raise ArgumentError, "bad format: '#{line}'" unless x date = Time.parse(date + ' UTC') server_ip = IP.new(server_ip) client_ip = IP.new(client_ip) port = port.to_i status = status.to_i substatus = substatus.to_i win32_status = win32_status.to_i time_taken = time_taken.to_f / 1000 query = nil if query == '-' username = nil if username == '-' user_agent = nil if user_agent == '-' user_agent.tr!('+', ' ') unless user_agent.nil? self.new(date, server_ip, method, url, query, port, username, client_ip, user_agent, status, substatus, win32_status, time_taken, other) end |