Add bytesToStr()
Automatically convert list into strings in appendRow() Add package information
This commit is contained in:
2
plugins/__init__.py
Normal file
2
plugins/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
|
||||
__all__ = ['pre_analysis', 'post_analysis', 'display']
|
1
plugins/display/__init__.py
Normal file
1
plugins/display/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
#
|
@@ -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)
|
||||
|
1
plugins/post_analysis/__init__.py
Normal file
1
plugins/post_analysis/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
#
|
@@ -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
|
||||
|
||||
|
1
plugins/pre_analysis/__init__.py
Normal file
1
plugins/pre_analysis/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
#
|
Reference in New Issue
Block a user