iwla

iwla Git Source Tree

Root/plugins/display/top_visitors.py

1import time
2from display import *
3
4PLUGIN_CLASS = 'HTTP'
5API_VERSION = 1
6
7def get_plugins_infos():
8 infos = {
9 'class' : PLUGIN_CLASS,
10 'min_version' : API_VERSION,
11 'max_version' : -1
12 }
13 return infos
14
15def load():
16 return True
17
18def hook(iwla):
19 stats = iwla.getMonthStats()
20
21 if not 'top_visitors' in stats.keys():
22 print 'Top visitors post analysis plugin not installed'
23 return
24
25 index = iwla.getDisplayIndex()
26 table = DisplayHTMLBlockTable('Top visitors', ['Host', 'Pages', 'Hits', 'Bandwidth', 'Last seen'])
27 for super_hit in stats['top_visitors']:
28 row = [super_hit['remote_addr'], super_hit['viewed_pages'], super_hit['viewed_hits'], super_hit['bandwidth'], 0]
29 row = map(lambda(v): str(v), row)
30 row[4] = time.asctime(super_hit['last_access'])
31 table.appendRow(row)
32 index.appendBlock(table)

Archive Download this file

Branches

Tags