2014-11-21 16:57:37 +01:00
|
|
|
import time
|
|
|
|
from display import *
|
|
|
|
|
|
|
|
PLUGIN_CLASS = 'HTTP'
|
|
|
|
API_VERSION = 1
|
|
|
|
|
|
|
|
def get_plugins_infos():
|
|
|
|
infos = {
|
|
|
|
'class' : PLUGIN_CLASS,
|
|
|
|
'min_version' : API_VERSION,
|
|
|
|
'max_version' : -1
|
|
|
|
}
|
|
|
|
return infos
|
|
|
|
|
|
|
|
def load():
|
|
|
|
return True
|
|
|
|
|
|
|
|
def hook(iwla):
|
|
|
|
stats = iwla.getMonthStats()
|
2014-11-22 19:23:56 +01:00
|
|
|
|
2014-11-24 13:44:04 +01:00
|
|
|
top_visitors = stats.get('top_visitors', None)
|
|
|
|
if not top_visitors:
|
2014-11-22 19:23:56 +01:00
|
|
|
print 'Top visitors post analysis plugin not installed'
|
|
|
|
return
|
|
|
|
|
2014-11-21 16:57:37 +01:00
|
|
|
index = iwla.getDisplayIndex()
|
|
|
|
table = DisplayHTMLBlockTable('Top visitors', ['Host', 'Pages', 'Hits', 'Bandwidth', 'Last seen'])
|
2014-11-24 13:44:04 +01:00
|
|
|
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'])
|
|
|
|
]
|
2014-11-21 16:57:37 +01:00
|
|
|
table.appendRow(row)
|
|
|
|
index.appendBlock(table)
|