Add ability to filter asshattery from stats

This commit is contained in:
Ciaran Gultnieks 2014-08-22 21:18:55 +01:00
parent 58a88acd92
commit b43f7bea1a
3 changed files with 25 additions and 14 deletions

View file

@ -165,6 +165,10 @@ wiki_password = "1234"
# machine. # machine.
update_stats = False update_stats = False
# When used with stats, this is a list of IP addresses that are ignored for
# calculation purposes.
stats_ignore = []
# Use the following to push stats to a Carbon instance: # Use the following to push stats to a Carbon instance:
stats_to_carbon = False stats_to_carbon = False
carbon_host = '0.0.0.0' carbon_host = '0.0.0.0'

View file

@ -49,6 +49,7 @@ def get_default_config():
'gradle': 'gradle', 'gradle': 'gradle',
'sync_from_local_copy_dir': False, 'sync_from_local_copy_dir': False,
'update_stats': False, 'update_stats': False,
'stats_ignore': [],
'stats_to_carbon': False, 'stats_to_carbon': False,
'repo_maxage': 0, 'repo_maxage': 0,
'build_server_always': False, 'build_server_always': False,

View file

@ -154,9 +154,15 @@ def main():
p = subprocess.Popen(["zcat", logfile], stdout=subprocess.PIPE) p = subprocess.Popen(["zcat", logfile], stdout=subprocess.PIPE)
matches = (logsearch(line) for line in p.stdout) matches = (logsearch(line) for line in p.stdout)
for match in matches: for match in matches:
if match and match.group('statuscode') == '200': if not match:
continue
if match.group('statuscode') != '200':
continue
if match.group('ip') in config['stats_ignore']:
continue
uri = match.group('uri') uri = match.group('uri')
if uri.endswith('.apk'): if not uri.endswith('.apk'):
continue
_, apkname = os.path.split(uri) _, apkname = os.path.split(uri)
app = knownapks.getapp(apkname) app = knownapks.getapp(apkname)
if app: if app: