Skip to content

Commit

Permalink
Implemented endpoint to fetch Dispersy statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
devos50 committed Jun 11, 2016
1 parent bf6329f commit cdbd3b0
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion Tribler/Core/Modules/restapi/debug_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ def __init__(self, session):
resource.Resource.__init__(self)
self.session = session

child_handler_dict = {"communities": DebugCommunitiesEndpoint, "statistics": DebugStatisticsEndpoint}
child_handler_dict = {"communities": DebugCommunitiesEndpoint, "statistics": DebugStatisticsEndpoint,
"dispersy": DebugDispersyEndpoint}

for path, child_cls in child_handler_dict.iteritems():
self.putChild(path, child_cls(self.session))
Expand Down Expand Up @@ -71,3 +72,19 @@ def render_GET(self, request):
"torrent_queue_size_stats": torrent_queue_size_stats,
"torrent_queue_bandwidth_stats": torrent_queue_bandwidth_stats,
"num_channels": channel_db_handler.getNrChannels()})


class DebugDispersyEndpoint(resource.Resource):

def __init__(self, session):
resource.Resource.__init__(self)
self.session = session

def render_GET(self, request):
dispersy_stats = self.session.get_dispersy_instance().statistics
dispersy_stats.update(database=True)

return json.dumps({"summary": {"wan_address": "%s:%s" % dispersy_stats.wan_address,
"lan_address": "%s:%s" % dispersy_stats.lan_address,
"connection": unicode(dispersy_stats.connection_type),
"runtime": (dispersy_stats.timestamp - dispersy_stats.start)}})

0 comments on commit cdbd3b0

Please sign in to comment.