2 Simple statistics plugin
4 To use it, go to http://127.0.0.1:8000/stat
6 from modules.PluginInterface import VPProxyPlugin
9 class Stat(VPProxyPlugin):
12 def __init__(self, VPConfig, VPStuff):
13 self.config = VPConfig
16 def handle(self, connection):
17 connection.send_response(200)
18 connection.send_header('Content-type', 'text/html')
19 connection.end_headers()
20 connection.wfile.write(
21 '<html><body><h4>Connected clients: ' + str(self.stuff.clientcounter.total) + '</h4>')
22 connection.wfile.write(
23 '<h5>Concurrent connections limit: ' + str(self.config.maxconns) + '</h5>')
24 connection.wfile.write('<table border="1"><tr><th>url</th><th>count</th><th>clients</th></tr>')
25 for i in self.stuff.clientcounter.clients:
26 connection.wfile.write('<tr>')
27 connection.wfile.write('<td>' + str(i) + ' </td><td> ' + str(self.stuff.clientcounter.clients[i][0]) + '</td><td>')
28 for client in self.stuff.clientcounter.clients[i][1]:
29 connection.wfile.write(str(client) + '<br>')
30 connection.wfile.write('</td></tr>')
31 connection.wfile.write('</table>')
32 connection.wfile.write('</body></html>')