iwla/plugins/display/top_visitors.py

28 lines
908 B
Python
Raw Normal View History

import time
2014-11-24 17:13:59 +01:00
from iwla import IWLA
from iplugin import IPlugin
from display import *
2014-11-24 17:13:59 +01:00
class IWLADisplayTopVisitors(IPlugin):
2014-11-24 21:37:37 +01:00
def __init__(self, iwla, conf):
super(IWLADisplayTopVisitors, self).__init__(iwla, conf)
2014-11-24 17:13:59 +01:00
self.API_VERSION = 1
self.requires = ['IWLAPostAnalysisTopVisitors']
2014-11-22 19:23:56 +01:00
2014-11-24 17:13:59 +01:00
def hook(self, iwla):
stats = iwla.getMonthStats()
2014-11-22 19:23:56 +01:00
2014-11-24 17:13:59 +01:00
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'],
bytesToStr(super_hit['bandwidth']),
time.asctime(super_hit['last_access'])
]
table.appendRow(row)
index.appendBlock(table)