summaryrefslogtreecommitdiff
path: root/ot_stats.c
diff options
context:
space:
mode:
Diffstat (limited to 'ot_stats.c')
-rw-r--r--ot_stats.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/ot_stats.c b/ot_stats.c
index a3cce63..e4c607a 100644
--- a/ot_stats.c
+++ b/ot_stats.c
@@ -44,6 +44,7 @@ static unsigned long long ot_overall_tcp_successfulscrapes = 0;
44static unsigned long long ot_overall_udp_successfulscrapes = 0; 44static unsigned long long ot_overall_udp_successfulscrapes = 0;
45static unsigned long long ot_overall_tcp_connects = 0; 45static unsigned long long ot_overall_tcp_connects = 0;
46static unsigned long long ot_overall_udp_connects = 0; 46static unsigned long long ot_overall_udp_connects = 0;
47static unsigned long long ot_overall_completed = 0;
47static unsigned long long ot_full_scrape_count = 0; 48static unsigned long long ot_full_scrape_count = 0;
48static unsigned long long ot_full_scrape_request_count = 0; 49static unsigned long long ot_full_scrape_request_count = 0;
49static unsigned long long ot_full_scrape_size = 0; 50static unsigned long long ot_full_scrape_size = 0;
@@ -445,6 +446,19 @@ static size_t stats_return_sync_mrtg( char * reply ) {
445 ); 446 );
446} 447}
447 448
449static size_t stats_return_completed_mrtg( char * reply ) {
450 ot_time t = time( NULL ) - ot_start_time;
451
452 return sprintf( reply,
453 "%llu\n%llu\n%i seconds (%i hours)\nopentracker, %lu completed/h.",
454 ot_overall_completed,
455 0LL,
456 (int)t,
457 (int)(t / 3600),
458 events_per_time( ot_overall_completed, t / 3600 )
459 );
460}
461
448static size_t stats_return_everything( char * reply ) { 462static size_t stats_return_everything( char * reply ) {
449 torrent_stats stats = {0,0,0}; 463 torrent_stats stats = {0,0,0};
450 int i; 464 int i;
@@ -462,6 +476,7 @@ static size_t stats_return_everything( char * reply ) {
462 r += sprintf( r, " </torrents>\n" ); 476 r += sprintf( r, " </torrents>\n" );
463 r += sprintf( r, " <peers>\n <count>%llu</count>\n </peers>\n", stats.peer_count ); 477 r += sprintf( r, " <peers>\n <count>%llu</count>\n </peers>\n", stats.peer_count );
464 r += sprintf( r, " <seeds>\n <count>%llu</count>\n </seeds>\n", stats.seed_count ); 478 r += sprintf( r, " <seeds>\n <count>%llu</count>\n </seeds>\n", stats.seed_count );
479 r += sprintf( r, " <completed>\n <count>%llu</count>\n </completed", ot_overall_completed );
465 r += sprintf( r, " <connections>\n" ); 480 r += sprintf( r, " <connections>\n" );
466 r += sprintf( r, " <tcp>\n <accept>%llu</accept>\n <announce>%llu</announce>\n <scrape>%llu</scrape>\n </tcp>\n", ot_overall_tcp_connections, ot_overall_tcp_successfulannounces, ot_overall_udp_successfulscrapes ); 481 r += sprintf( r, " <tcp>\n <accept>%llu</accept>\n <announce>%llu</announce>\n <scrape>%llu</scrape>\n </tcp>\n", ot_overall_tcp_connections, ot_overall_tcp_successfulannounces, ot_overall_udp_successfulscrapes );
467 r += sprintf( r, " <udp>\n <overall>%llu</overall>\n <connect>%llu</connect>\n <announce>%llu</announce>\n <scrape>%llu</scrape>\n </udp>\n", ot_overall_udp_connections, ot_overall_udp_connects, ot_overall_udp_successfulannounces, ot_overall_udp_successfulscrapes ); 482 r += sprintf( r, " <udp>\n <overall>%llu</overall>\n <connect>%llu</connect>\n <announce>%llu</announce>\n <scrape>%llu</scrape>\n </udp>\n", ot_overall_udp_connections, ot_overall_udp_connects, ot_overall_udp_successfulannounces, ot_overall_udp_successfulscrapes );
@@ -507,6 +522,8 @@ size_t return_stats_for_tracker( char *reply, int mode, int format ) {
507 return stats_tcpconnections_mrtg( reply ); 522 return stats_tcpconnections_mrtg( reply );
508 case TASK_STATS_FULLSCRAPE: 523 case TASK_STATS_FULLSCRAPE:
509 return stats_fullscrapes_mrtg( reply ); 524 return stats_fullscrapes_mrtg( reply );
525 case TASK_STATS_COMPLETED:
526 return stats_return_completed_mrtg( reply );
510 case TASK_STATS_HTTPERRORS: 527 case TASK_STATS_HTTPERRORS:
511 return stats_httperrors_txt( reply ); 528 return stats_httperrors_txt( reply );
512 case TASK_STATS_VERSION: 529 case TASK_STATS_VERSION:
@@ -559,6 +576,9 @@ void stats_issue_event( ot_status_event event, PROTO_FLAG proto, uintptr_t event
559 case EVENT_CONNECT: 576 case EVENT_CONNECT:
560 if( proto == FLAG_TCP ) ot_overall_tcp_connects++; else ot_overall_udp_connects++; 577 if( proto == FLAG_TCP ) ot_overall_tcp_connects++; else ot_overall_udp_connects++;
561 break; 578 break;
579 case EVENT_COMPLETED:
580 ot_overall_completed++;
581 break;
562 case EVENT_SCRAPE: 582 case EVENT_SCRAPE:
563 if( proto == FLAG_TCP ) ot_overall_tcp_successfulscrapes++; else ot_overall_udp_successfulscrapes++; 583 if( proto == FLAG_TCP ) ot_overall_tcp_successfulscrapes++; else ot_overall_udp_successfulscrapes++;
564 case EVENT_FULLSCRAPE: 584 case EVENT_FULLSCRAPE: