diff options
Diffstat (limited to 'opentracker.c')
-rw-r--r-- | opentracker.c | 17 |
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; | |||
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 | ||