Commit 80244895 authored by Vincent Pelletier's avatar Vincent Pelletier

Add support for (canonical) server name matching.

parent 33679833
......@@ -630,6 +630,11 @@ class ERP5SiteStats(GenericSiteStats):
DURATION_US_FORMAT = '%D'
DURATION_S_FORMAT = '%T'
server_name_group_dict = {
'%v': lambda x: x.group('servername') + '/',
'%V': lambda x: x.group('canonical_servername') + '/',
}
logformat_dict = {
'%h': r'(?P<host>[^ ]*)',
'%l': r'(?P<ident>[^ ]*)',
......@@ -643,6 +648,8 @@ logformat_dict = {
DURATION_US_FORMAT: r'(?P<duration>[0-9]*)',
DURATION_S_FORMAT: r'(?P<duration_s>[0-9]*)',
'%%': r'%',
'%v': r'(?P<servername>[^ ]*)',
'%V': r'(?P<canonical_servername>[^ ]*)',
# TODO: add more formats
}
......@@ -975,6 +982,8 @@ def main():
group.add_argument('--skip-base', dest='path', nargs='+',
action=AggregateSiteUrl,
help='Absolute base url(s) to ignore.')
group.add_argument('--match-servername', choices=server_name_group_dict,
help='Prefix URL with (canonical) server name.')
group = parser.add_argument_group('filtering')
group.add_argument('--skip-user-agent', nargs='+', default=[],
......@@ -991,6 +1000,13 @@ def main():
print >> sys.stderr, 'Neither %D nor %T are present in logformat, apdex ' \
'cannot be computed.'
sys.exit(1)
if args.match_servername is not None and \
args.match_servername not in args.logformat:
print >> sys.stderr, '--match-servername %s requested, but missing ' \
'from logformat.' % args.match_servername
sys.exit(1)
get_url_prefix = server_name_group_dict.get(args.match_servername,
lambda _: '')
line_regex = ''
expensive_line_regex = ''
try:
......@@ -1125,6 +1141,7 @@ def main():
url = url_match.group('url')
if url.startswith('http'):
url = splithost(splittype(url)[1])[1]
url = get_url_prefix(match) + url
for site, prefix_match, action in site_list:
if prefix_match(url) is not None:
break
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment