summaryrefslogtreecommitdiff
path: root/opentracker.c
diff options
context:
space:
mode:
authorerdgeist <>2007-10-31 15:39:41 +0000
committererdgeist <>2007-10-31 15:39:41 +0000
commitdc8e88979777a662c76e010a3f90df1c382aae9a (patch)
treeb3aaf437a942f8310deda475ea6f625eed7641e7 /opentracker.c
parent31eada6168f9c2433b0b7cd3ef21861f76d21784 (diff)
Add more full scrape stats
Diffstat (limited to 'opentracker.c')
-rw-r--r--opentracker.c17
1 files changed, 17 insertions, 0 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