Add bytesToStr()

Automatically convert list into strings in appendRow()
Add package information
This commit is contained in:
Gregory Soutade
2014-11-24 13:44:04 +01:00
parent 38c041126d
commit 670f024905
8 changed files with 48 additions and 14 deletions

2
plugins/__init__.py Normal file
View File

@@ -0,0 +1,2 @@
__all__ = ['pre_analysis', 'post_analysis', 'display']

View File

@@ -0,0 +1 @@
#

View File

@@ -18,15 +18,20 @@ def load():
def hook(iwla):
stats = iwla.getMonthStats()
if not 'top_visitors' in stats.keys():
top_visitors = stats.get('top_visitors', None)
if not top_visitors:
print 'Top visitors post analysis plugin not installed'
return
index = iwla.getDisplayIndex()
table = DisplayHTMLBlockTable('Top visitors', ['Host', 'Pages', 'Hits', 'Bandwidth', 'Last seen'])
for super_hit in stats['top_visitors']:
row = [super_hit['remote_addr'], super_hit['viewed_pages'], super_hit['viewed_hits'], super_hit['bandwidth'], 0]
row = map(lambda(v): str(v), row)
row[4] = time.asctime(super_hit['last_access'])
for super_hit in top_visitors:
row = [
super_hit['remote_addr'],
super_hit['viewed_pages'],
super_hit['viewed_hits'],
bytesToStr(super_hit['bandwidth']),
time.asctime(super_hit['last_access'])
]
table.appendRow(row)
index.appendBlock(table)

View File

@@ -0,0 +1 @@
#

View File

@@ -19,9 +19,12 @@ def load():
def hook(iwla):
hits = iwla.getValidVisitors()
for (k, hit) in hits.items():
if hit.get('dns_analysed', False): continue
try:
name, _, _ = socket.gethostbyaddr(k)
hit['remote_addr'] = name
except:
pass
finally:
hit['dns_analysed'] = True

View File

@@ -0,0 +1 @@
#