diff options
-rw-r--r-- | doc/protocol.md | 2 | ||||
-rwxr-xr-x | src/daq/accesslog/sfive-accesslog.py | 11 |
2 files changed, 9 insertions, 4 deletions
diff --git a/doc/protocol.md b/doc/protocol.md index 73641b8..9c81ecd 100644 --- a/doc/protocol.md +++ b/doc/protocol.md @@ -19,7 +19,7 @@ data-update "duration-ms": 5000, "data": { "clients": [ - { "ip": "127.0.0.1:2345", "bytes-transferred": 12094, "user-agent": "Mozilla Version 28", .... }, + { "ip": "127.0.0.1", "bytes-sent": 12094, "user-agent": "Mozilla Version 28", .... }, ..... ], "client-count": 12, diff --git a/src/daq/accesslog/sfive-accesslog.py b/src/daq/accesslog/sfive-accesslog.py index 4d4315f..a98cee1 100755 --- a/src/daq/accesslog/sfive-accesslog.py +++ b/src/daq/accesslog/sfive-accesslog.py @@ -107,7 +107,11 @@ class ClientList: return len(self._clients) def getBytesSent(self): - return sum(self._clients.itervalues()) + sum = 0 + for val in self._clients.itervalues(): + sum += val['bytes-sent'] + + return sum def update(self, linedata): if linedata['status'] != 200 and linedata['status'] != 206: @@ -118,9 +122,10 @@ class ClientList: try: if re.match(self._file_re, linedata['req']['url']): if linedata['client'] in self._clients.keys(): - self._clients[linedata['client']] += linedata['size'] + self._clients[linedata['client']]['bytes-sent'] += linedata['size'] else: - self._clients[linedata['client']] = linedata['size'] + self._clients[linedata['client']] = { 'ip': linedata['client'], + 'bytes-sent': linedata['size'] } except re.error as e: print 'SFive: regex error: %s' % (e) |