diff options
| author | erdgeist <> | 2007-10-31 15:39:41 +0000 |
|---|---|---|
| committer | erdgeist <> | 2007-10-31 15:39:41 +0000 |
| commit | dc8e88979777a662c76e010a3f90df1c382aae9a (patch) | |
| tree | b3aaf437a942f8310deda475ea6f625eed7641e7 | |
| parent | 31eada6168f9c2433b0b7cd3ef21861f76d21784 (diff) | |
Add more full scrape stats
| -rw-r--r-- | opentracker.c | 17 | ||||
| -rw-r--r-- | trackerlogic.h | 2 |
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; | |||
| 35 | static unsigned long long ot_overall_udp_connections = 0; | 35 | static unsigned long long ot_overall_udp_connections = 0; |
| 36 | static unsigned long long ot_overall_tcp_successfulannounces = 0; | 36 | static unsigned long long ot_overall_tcp_successfulannounces = 0; |
| 37 | static unsigned long long ot_overall_udp_successfulannounces = 0; | 37 | static unsigned long long ot_overall_udp_successfulannounces = 0; |
| 38 | static unsigned long long ot_full_scrape_count = 0; | ||
| 39 | static unsigned long long ot_full_scrape_size = 0; | ||
| 38 | static time_t ot_start_time; | 40 | static time_t ot_start_time; |
| 39 | static const size_t SUCCESS_HTTP_HEADER_LENGTH = 80; | 41 | static const size_t SUCCESS_HTTP_HEADER_LENGTH = 80; |
| 40 | static const size_t SUCCESS_HTTP_SIZE_OFF = 17; | 42 | static 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 | { |
| 372 | LOG_TO_STDERR( "stats: %d.%d.%d.%d - mode: s24s\n", h->ip[0], h->ip[1], h->ip[2], h->ip[3] ); | 384 | LOG_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 | |||
| 405 | write( 2, debug_request, l ); | 417 | write( 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 { | |||
| 98 | int init_logic( const char * const serverdir ); | 98 | int init_logic( const char * const serverdir ); |
| 99 | void deinit_logic( void ); | 99 | void deinit_logic( void ); |
| 100 | 100 | ||
| 101 | enum { STATS_MRTG, STATS_TOP5, STATS_DMEM, STATS_TCP, STATS_UDP, STATS_SLASH24S, STATS_SLASH24S_OLD, SYNC_IN, SYNC_OUT }; | 101 | enum { 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 |
| 104 | ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer, int from_changeset ); | 104 | ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer, int from_changeset ); |
