summaryrefslogtreecommitdiff
path: root/ot_stats.c
diff options
context:
space:
mode:
authordenis <>2007-12-14 22:01:14 +0000
committerdenis <>2007-12-14 22:01:14 +0000
commit65c3b2404560b976bfeff0db190c97d4b9487644 (patch)
tree1c26a7981f8a05c031e38ab8f941cbc34b696340 /ot_stats.c
parentc2cbe1dc273984c689c97f5eca8798195d5a35a0 (diff)
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
Diffstat (limited to 'ot_stats.c')
-rw-r--r--ot_stats.c46
1 files changed, 46 insertions, 0 deletions
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 ) {
264 ); 264 );
265} 265}
266 266
267static size_t stats_startstop_mrtg( char * reply )
268{
269 size_t torrent_count = 0;
270 int bucket;
271
272 for( bucket=0; bucket<OT_BUCKET_COUNT; ++bucket )
273 {
274 ot_vector *torrents_list = mutex_bucket_lock( bucket );
275 torrent_count += torrents_list->size;
276 mutex_bucket_unlock( bucket );
277 }
278
279 return sprintf( reply, "%zd\n%zd\nopentracker handling %zd torrents\nopentracker",
280 (size_t)0,
281 (size_t)0,
282 torrent_count
283 );
284}
285
286static size_t stats_toraddrem_mrtg( char * reply )
287{
288 size_t peer_count = 0, j;
289 int bucket;
290
291 for( bucket=0; bucket<OT_BUCKET_COUNT; ++bucket )
292 {
293 ot_vector *torrents_list = mutex_bucket_lock( bucket );
294 for( j=0; j<torrents_list->size; ++j )
295 {
296 ot_peerlist *peer_list = ( ((ot_torrent*)(torrents_list->data))[j] ).peer_list;
297 peer_count += peer_list->peer_count;
298 }
299 mutex_bucket_unlock( bucket );
300 }
301
302 return sprintf( reply, "%zd\n%zd\nopentracker handling %zd peers\nopentracker",
303 (size_t)0,
304 (size_t)0,
305 peer_count
306 );
307}
308
267static size_t stats_torrents_mrtg( char * reply ) 309static size_t stats_torrents_mrtg( char * reply )
268{ 310{
269 size_t torrent_count = 0; 311 size_t torrent_count = 0;
@@ -305,6 +347,10 @@ size_t return_stats_for_tracker( char *reply, int mode, int format ) {
305 return stats_peers_mrtg( reply ); 347 return stats_peers_mrtg( reply );
306 case TASK_STATS_TORRENTS: 348 case TASK_STATS_TORRENTS:
307 return stats_torrents_mrtg( reply ); 349 return stats_torrents_mrtg( reply );
350 case TASK_STATS_TORADDREM:
351 return stats_toraddrem_mrtg( reply );
352 case TASK_STATS_STARTSTOP:
353 return stats_startstop_mrtg( reply );
308 case TASK_STATS_SLASH24S: 354 case TASK_STATS_SLASH24S:
309 return stats_slash24s_txt( reply, 25, 16 ); 355 return stats_slash24s_txt( reply, 25, 16 );
310 case TASK_STATS_TOP5: 356 case TASK_STATS_TOP5: