glutenfree
Version:
A profiler/loganalyzer for nginx/Cetrea Aw.
37 lines (34 loc) • 1.34 kB
text/coffeescript
class AwNginxLineParser
parse: (line) ->
#'10.43.232.58 - - [14/Nov/2012:13:01:31 +0100] "GET /anywhere-horapp110-akut/json/flowmaster/listbyid/fm.paavej HTTP/1.1" 500 192 "http://horapp114.it.rm.dk:8912/anywhere-horapp110-akut/view/flowmaster" "Mozilla/5.0 (Windows NT 5.1; chromeframe/23.0.1271.64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11"'
re = /((\d+\.*)+).*\[(.*)\]\s\"(.*)\"\s(\d+)\s(\d+)\s\"(.*)\"\s\"(.*)\"/i
m = line.match(re)
if m
[__, ip, __, time, request, __, referer, __, useragent, __] = m
[__, method, path, protocol, __] = request.match(/(.*)\s(.*)\s(.*)/)
r = path.split("/")
if r then [__, instance, action, endpoint, fun, args...] = r
else return false
# return
url = [action, component, componentVersion, endpoint, fun].filter((c) -> c?).concat(args).join("/")
{
variables:
ip: ip
time: time
referer: referer
useragent: useragent
method: method
protocol: protocol
instance: instance
component: null
componentVersion: null
action: action
endpoint: endpoint
fun: fun
args: args
url: url
id: method + " " + url
}
else
false
exports.parser = new AwNginxLineParser()