From 65c3b2404560b976bfeff0db190c97d4b9487644 Mon Sep 17 00:00:00 2001 From: denis <> Date: Fri, 14 Dec 2007 22:01:14 +0000 Subject: add support for more stats: 1. stats for added and removed torrents 2. stats for start and stopped events from peers this should help to detect DoS attacks and is useful for profiling --- ot_stats.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'ot_stats.c') diff --git a/ot_stats.c b/ot_stats.c index 77910f5..d2b02fa 100644 --- a/ot_stats.c +++ b/ot_stats.c @@ -264,6 +264,48 @@ static size_t stats_peers_mrtg( char * reply ) { ); } +static size_t stats_startstop_mrtg( char * reply ) +{ + size_t torrent_count = 0; + int bucket; + + for( bucket=0; bucketsize; + mutex_bucket_unlock( bucket ); + } + + return sprintf( reply, "%zd\n%zd\nopentracker handling %zd torrents\nopentracker", + (size_t)0, + (size_t)0, + torrent_count + ); +} + +static size_t stats_toraddrem_mrtg( char * reply ) +{ + size_t peer_count = 0, j; + int bucket; + + for( bucket=0; bucketsize; ++j ) + { + ot_peerlist *peer_list = ( ((ot_torrent*)(torrents_list->data))[j] ).peer_list; + peer_count += peer_list->peer_count; + } + mutex_bucket_unlock( bucket ); + } + + return sprintf( reply, "%zd\n%zd\nopentracker handling %zd peers\nopentracker", + (size_t)0, + (size_t)0, + peer_count + ); +} + static size_t stats_torrents_mrtg( char * reply ) { size_t torrent_count = 0; @@ -305,6 +347,10 @@ size_t return_stats_for_tracker( char *reply, int mode, int format ) { return stats_peers_mrtg( reply ); case TASK_STATS_TORRENTS: return stats_torrents_mrtg( reply ); + case TASK_STATS_TORADDREM: + return stats_toraddrem_mrtg( reply ); + case TASK_STATS_STARTSTOP: + return stats_startstop_mrtg( reply ); case TASK_STATS_SLASH24S: return stats_slash24s_txt( reply, 25, 16 ); case TASK_STATS_TOP5: -- cgit v1.2.3