summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--opentracker.c17
-rw-r--r--trackerlogic.h2
2 files changed, 18 insertions, 1 deletions
diff --git a/opentracker.c b/opentracker.c
index bf9db89..9c36361 100644
--- a/opentracker.c
+++ b/opentracker.c
@@ -35,6 +35,8 @@ static unsigned long long ot_overall_tcp_connections = 0;
35static unsigned long long ot_overall_udp_connections = 0; 35static unsigned long long ot_overall_udp_connections = 0;
36static unsigned long long ot_overall_tcp_successfulannounces = 0; 36static unsigned long long ot_overall_tcp_successfulannounces = 0;
37static unsigned long long ot_overall_udp_successfulannounces = 0; 37static unsigned long long ot_overall_udp_successfulannounces = 0;
38static unsigned long long ot_full_scrape_count = 0;
39static unsigned long long ot_full_scrape_size = 0;
38static time_t ot_start_time; 40static time_t ot_start_time;
39static const size_t SUCCESS_HTTP_HEADER_LENGTH = 80; 41static const size_t SUCCESS_HTTP_HEADER_LENGTH = 80;
40static const size_t SUCCESS_HTTP_SIZE_OFF = 17; 42static const size_t SUCCESS_HTTP_SIZE_OFF = 17;
@@ -325,6 +327,8 @@ LOG_TO_STDERR( "sync: %d.%d.%d.%d\n", h->ip[0], h->ip[1], h->ip[2], h->ip[3] );
325 mode = STATS_MRTG; 327 mode = STATS_MRTG;
326 else if( !byte_diff(data,4,"top5")) 328 else if( !byte_diff(data,4,"top5"))
327 mode = STATS_TOP5; 329 mode = STATS_TOP5;
330 else if( !byte_diff(data,4,"fscr"))
331 mode = STATS_FULLSCRAPE;
328 else if( !byte_diff(data,4,"dmem")) 332 else if( !byte_diff(data,4,"dmem"))
329 mode = STATS_DMEM; 333 mode = STATS_DMEM;
330 else if( !byte_diff(data,4,"tcp4")) 334 else if( !byte_diff(data,4,"tcp4"))
@@ -367,6 +371,14 @@ LOG_TO_STDERR( "stats: %d.%d.%d.%d - mode: dmem\n", h->ip[0], h->ip[1], h->ip[2]
367 /* Enough for http header + whole scrape string */ 371 /* Enough for http header + whole scrape string */
368 if( !( reply_size = return_stats_for_tracker( SUCCESS_HTTP_HEADER_LENGTH + static_outbuf, mode ) ) ) HTTPERROR_500; 372 if( !( reply_size = return_stats_for_tracker( SUCCESS_HTTP_HEADER_LENGTH + static_outbuf, mode ) ) ) HTTPERROR_500;
369 break; 373 break;
374
375 case STATS_FULLSCRAPE:
376 t = time( NULL ) - ot_start_time;
377 reply_size = sprintf( static_outbuf + SUCCESS_HTTP_HEADER_LENGTH,
378 "%llu\n%llu\n%i seconds (%i hours)\nopentracker full scrape stats.",
379 ot_full_scrape_count * 1000, ot_full_scrape_size, (int)t, (int)(t / 3600) );
380 break;
381
370 case STATS_SLASH24S: 382 case STATS_SLASH24S:
371{ 383{
372LOG_TO_STDERR( "stats: %d.%d.%d.%d - mode: s24s\n", h->ip[0], h->ip[1], h->ip[2], h->ip[3] ); 384LOG_TO_STDERR( "stats: %d.%d.%d.%d - mode: s24s\n", h->ip[0], h->ip[1], h->ip[2], h->ip[3] );
@@ -405,7 +417,12 @@ LOG_TO_STDERR( "[%08d] scrp: %d.%d.%d.%d - FULL SCRAPE\n", (unsigned int)(g_now
405write( 2, debug_request, l ); 417write( 2, debug_request, l );
406#endif 418#endif
407 if( !( reply_size = return_fullscrape_for_tracker( &reply ) ) ) HTTPERROR_500; 419 if( !( reply_size = return_fullscrape_for_tracker( &reply ) ) ) HTTPERROR_500;
420
421 /* Stat keeping */
408 ot_overall_tcp_successfulannounces++; 422 ot_overall_tcp_successfulannounces++;
423 ot_full_scrape_count++;
424 ot_full_scrape_size += reply_size;
425
409 return sendmmapdata( s, reply, reply_size ); 426 return sendmmapdata( s, reply, reply_size );
410 } 427 }
411 428
diff --git a/trackerlogic.h b/trackerlogic.h
index fc6c884..ccd3465 100644
--- a/trackerlogic.h
+++ b/trackerlogic.h
@@ -98,7 +98,7 @@ typedef struct {
98int init_logic( const char * const serverdir ); 98int init_logic( const char * const serverdir );
99void deinit_logic( void ); 99void deinit_logic( void );
100 100
101enum { STATS_MRTG, STATS_TOP5, STATS_DMEM, STATS_TCP, STATS_UDP, STATS_SLASH24S, STATS_SLASH24S_OLD, SYNC_IN, SYNC_OUT }; 101enum { STATS_MRTG, STATS_TOP5, STATS_DMEM, STATS_TCP, STATS_UDP, STATS_SLASH24S, STATS_SLASH24S_OLD, SYNC_IN, SYNC_OUT, STATS_FULLSCRAPE };
102 102
103#ifdef WANT_TRACKER_SYNC 103#ifdef WANT_TRACKER_SYNC
104ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer, int from_changeset ); 104ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer, int from_changeset );