diff options
-rw-r--r-- | ot_http.c | 2 | ||||
-rw-r--r-- | ot_mutex.h | 1 | ||||
-rw-r--r-- | ot_stats.c | 20 | ||||
-rw-r--r-- | ot_stats.h | 1 | ||||
-rw-r--r-- | trackerlogic.c | 8 |
5 files changed, 29 insertions, 3 deletions
@@ -163,7 +163,7 @@ static const ot_keywords keywords_main[] = | |||
163 | static const ot_keywords keywords_mode[] = | 163 | static const ot_keywords keywords_mode[] = |
164 | { { "peer", TASK_STATS_PEERS }, { "conn", TASK_STATS_CONNS }, { "scrp", TASK_STATS_SCRAPE }, { "udp4", TASK_STATS_UDP }, { "tcp4", TASK_STATS_TCP }, | 164 | { { "peer", TASK_STATS_PEERS }, { "conn", TASK_STATS_CONNS }, { "scrp", TASK_STATS_SCRAPE }, { "udp4", TASK_STATS_UDP }, { "tcp4", TASK_STATS_TCP }, |
165 | { "busy", TASK_STATS_BUSY_NETWORKS }, { "torr", TASK_STATS_TORRENTS }, { "fscr", TASK_STATS_FULLSCRAPE }, | 165 | { "busy", TASK_STATS_BUSY_NETWORKS }, { "torr", TASK_STATS_TORRENTS }, { "fscr", TASK_STATS_FULLSCRAPE }, |
166 | { "s24s", TASK_STATS_SLASH24S }, { "tpbs", TASK_STATS_TPB }, { "herr", TASK_STATS_HTTPERRORS }, | 166 | { "s24s", TASK_STATS_SLASH24S }, { "tpbs", TASK_STATS_TPB }, { "herr", TASK_STATS_HTTPERRORS }, { "completed", TASK_STATS_COMPLETED }, |
167 | { "top10", TASK_STATS_TOP10 }, { "renew", TASK_STATS_RENEW }, { "syncs", TASK_STATS_SYNCS }, { "version", TASK_STATS_VERSION }, | 167 | { "top10", TASK_STATS_TOP10 }, { "renew", TASK_STATS_RENEW }, { "syncs", TASK_STATS_SYNCS }, { "version", TASK_STATS_VERSION }, |
168 | { "everything", TASK_STATS_EVERYTHING }, { "statedump", TASK_FULLSCRAPE_TPB_URLENCODED }, { NULL, -3 } }; | 168 | { "everything", TASK_STATS_EVERYTHING }, { "statedump", TASK_FULLSCRAPE_TPB_URLENCODED }, { NULL, -3 } }; |
169 | static const ot_keywords keywords_format[] = | 169 | static const ot_keywords keywords_format[] = |
@@ -31,6 +31,7 @@ typedef enum { | |||
31 | TASK_STATS_BUSY_NETWORKS = 0x0009, | 31 | TASK_STATS_BUSY_NETWORKS = 0x0009, |
32 | TASK_STATS_RENEW = 0x000a, | 32 | TASK_STATS_RENEW = 0x000a, |
33 | TASK_STATS_SYNCS = 0x000b, | 33 | TASK_STATS_SYNCS = 0x000b, |
34 | TASK_STATS_COMPLETED = 0x000c, | ||
34 | 35 | ||
35 | TASK_STATS = 0x0100, /* Mask */ | 36 | TASK_STATS = 0x0100, /* Mask */ |
36 | TASK_STATS_TORRENTS = 0x0101, | 37 | TASK_STATS_TORRENTS = 0x0101, |
@@ -44,6 +44,7 @@ static unsigned long long ot_overall_tcp_successfulscrapes = 0; | |||
44 | static unsigned long long ot_overall_udp_successfulscrapes = 0; | 44 | static unsigned long long ot_overall_udp_successfulscrapes = 0; |
45 | static unsigned long long ot_overall_tcp_connects = 0; | 45 | static unsigned long long ot_overall_tcp_connects = 0; |
46 | static unsigned long long ot_overall_udp_connects = 0; | 46 | static unsigned long long ot_overall_udp_connects = 0; |
47 | static unsigned long long ot_overall_completed = 0; | ||
47 | static unsigned long long ot_full_scrape_count = 0; | 48 | static unsigned long long ot_full_scrape_count = 0; |
48 | static unsigned long long ot_full_scrape_request_count = 0; | 49 | static unsigned long long ot_full_scrape_request_count = 0; |
49 | static unsigned long long ot_full_scrape_size = 0; | 50 | static 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 | ||
449 | static 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 | |||
448 | static size_t stats_return_everything( char * reply ) { | 462 | static 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: |
@@ -11,6 +11,7 @@ typedef enum { | |||
11 | EVENT_READ, | 11 | EVENT_READ, |
12 | EVENT_CONNECT, /* UDP only */ | 12 | EVENT_CONNECT, /* UDP only */ |
13 | EVENT_ANNOUNCE, | 13 | EVENT_ANNOUNCE, |
14 | EVENT_COMPLETED, | ||
14 | EVENT_RENEW, | 15 | EVENT_RENEW, |
15 | EVENT_SYNC, | 16 | EVENT_SYNC, |
16 | EVENT_SCRAPE, | 17 | EVENT_SCRAPE, |
diff --git a/trackerlogic.c b/trackerlogic.c index 1bd8ac7..d1ef063 100644 --- a/trackerlogic.c +++ b/trackerlogic.c | |||
@@ -128,8 +128,10 @@ size_t add_peer_to_torrent_and_return_peers( ot_hash hash, ot_peer *peer, PROTO_ | |||
128 | #endif | 128 | #endif |
129 | 129 | ||
130 | torrent->peer_list->peer_count++; | 130 | torrent->peer_list->peer_count++; |
131 | if( OT_PEERFLAG(peer) & PEER_FLAG_COMPLETED ) | 131 | if( OT_PEERFLAG(peer) & PEER_FLAG_COMPLETED ) { |
132 | torrent->peer_list->down_count++; | 132 | torrent->peer_list->down_count++; |
133 | stats_issue_event( EVENT_COMPLETED, 0, 0 ); | ||
134 | } | ||
133 | if( OT_PEERFLAG(peer) & PEER_FLAG_SEEDING ) | 135 | if( OT_PEERFLAG(peer) & PEER_FLAG_SEEDING ) |
134 | torrent->peer_list->seed_count++; | 136 | torrent->peer_list->seed_count++; |
135 | 137 | ||
@@ -150,8 +152,10 @@ size_t add_peer_to_torrent_and_return_peers( ot_hash hash, ot_peer *peer, PROTO_ | |||
150 | torrent->peer_list->seed_count--; | 152 | torrent->peer_list->seed_count--; |
151 | if( !(OT_PEERFLAG(peer_dest) & PEER_FLAG_SEEDING ) && (OT_PEERFLAG(peer) & PEER_FLAG_SEEDING ) ) | 153 | if( !(OT_PEERFLAG(peer_dest) & PEER_FLAG_SEEDING ) && (OT_PEERFLAG(peer) & PEER_FLAG_SEEDING ) ) |
152 | torrent->peer_list->seed_count++; | 154 | torrent->peer_list->seed_count++; |
153 | if( !(OT_PEERFLAG(peer_dest) & PEER_FLAG_COMPLETED ) && (OT_PEERFLAG(peer) & PEER_FLAG_COMPLETED ) ) | 155 | if( !(OT_PEERFLAG(peer_dest) & PEER_FLAG_COMPLETED ) && (OT_PEERFLAG(peer) & PEER_FLAG_COMPLETED ) ) { |
154 | torrent->peer_list->down_count++; | 156 | torrent->peer_list->down_count++; |
157 | stats_issue_event( EVENT_COMPLETED, 0, 0 ); | ||
158 | } | ||
155 | if( OT_PEERFLAG(peer_dest) & PEER_FLAG_COMPLETED ) | 159 | if( OT_PEERFLAG(peer_dest) & PEER_FLAG_COMPLETED ) |
156 | OT_PEERFLAG( peer ) |= PEER_FLAG_COMPLETED; | 160 | OT_PEERFLAG( peer ) |= PEER_FLAG_COMPLETED; |
157 | } | 161 | } |