diff options
author | Christian Pointner <equinox@spreadspace.org> | 2014-10-14 02:15:53 +0200 |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2014-10-14 02:16:02 +0200 |
commit | 919e5bb130afd0be1c8f717520d4e109d256b6e4 (patch) | |
tree | 9dfa8980436db8b0ebb4a074a8d8573551c3a8ff /src/daq/accesslog/sfive-accesslog.py | |
parent | cmd vs method (diff) |
moved to dict for client data
Diffstat (limited to 'src/daq/accesslog/sfive-accesslog.py')
-rwxr-xr-x | src/daq/accesslog/sfive-accesslog.py | 11 |
1 files changed, 8 insertions, 3 deletions
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) |