From 04eb09d26a0371c0a5123dfe7ae5ddbdee26f185 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Mon, 13 Oct 2014 01:17:49 +0200 Subject: aggregated stats work now --- src/daq/accesslog/sfive-accesslog.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/daq/accesslog/sfive-accesslog.py b/src/daq/accesslog/sfive-accesslog.py index 0e68497..3d45d61 100755 --- a/src/daq/accesslog/sfive-accesslog.py +++ b/src/daq/accesslog/sfive-accesslog.py @@ -211,15 +211,19 @@ class AccessLog(): return linedata def _updateClients(self, clients, linedata): - if linedata['status'] != 200 or linedata['req']['cmd'] != 'GET': + if linedata['status'] != 200 and linedata['status'] != 206: + return + if linedata['req']['cmd'] != 'GET': return - # TODO: this currently counts all data downloaded from 'client' - - if linedata['client'] in clients.keys(): - clients[linedata['client']] += linedata['size'] - else: - clients[linedata['client']] = linedata['size'] + try: + if re.match(self._file_re, linedata['req']['url']): + if linedata['client'] in clients.keys(): + clients[linedata['client']] += linedata['size'] + else: + clients[linedata['client']] = linedata['size'] + except re.error as e: + print 'SFive: regex error: %s' % (e) def _sendLogData(self, data, lastts): cnt = 0 @@ -232,7 +236,8 @@ class AccessLog(): if not lastts: lastts = linedata['ts'] nextts = lastts + datetime.timedelta(seconds=self._duration) - clients = { linedata['client'] : linedata['size'] } + clients = { } + self._updateClients(clients, linedata) else: while linedata['ts'] > nextts: self._sendDataset(nextts, self._duration, len(clients), sum(clients.itervalues())) -- cgit v1.2.3