diff options
| -rw-r--r-- | ot_http.c | 2 | ||||
| -rw-r--r-- | ot_livesync.c | 3 | ||||
| -rw-r--r-- | ot_mutex.h | 1 | ||||
| -rw-r--r-- | ot_stats.c | 22 | ||||
| -rw-r--r-- | ot_stats.h | 1 |
5 files changed, 28 insertions, 1 deletions
| @@ -215,6 +215,8 @@ static ssize_t http_handle_stats( const int64 client_socket, char *data, char *d | |||
| 215 | mode = TASK_STATS_TOP10; | 215 | mode = TASK_STATS_TOP10; |
| 216 | else if( !byte_diff(data,5,"renew")) | 216 | else if( !byte_diff(data,5,"renew")) |
| 217 | mode = TASK_STATS_RENEW; | 217 | mode = TASK_STATS_RENEW; |
| 218 | else if( !byte_diff(data,5,"syncs")) | ||
| 219 | mode = TASK_STATS_SYNCS; | ||
| 218 | else | 220 | else |
| 219 | HTTPERROR_400_PARAM; | 221 | HTTPERROR_400_PARAM; |
| 220 | break; | 222 | break; |
diff --git a/ot_livesync.c b/ot_livesync.c index f6e4e51..1b1efe0 100644 --- a/ot_livesync.c +++ b/ot_livesync.c | |||
| @@ -17,6 +17,7 @@ | |||
| 17 | #include "trackerlogic.h" | 17 | #include "trackerlogic.h" |
| 18 | #include "ot_livesync.h" | 18 | #include "ot_livesync.h" |
| 19 | #include "ot_accesslist.h" | 19 | #include "ot_accesslist.h" |
| 20 | #include "ot_stats.h" | ||
| 20 | 21 | ||
| 21 | #ifdef WANT_SYNC_LIVE | 22 | #ifdef WANT_SYNC_LIVE |
| 22 | 23 | ||
| @@ -152,6 +153,8 @@ static void * livesync_worker( void * args ) { | |||
| 152 | 153 | ||
| 153 | off += sizeof( ot_hash ) + sizeof( ot_peer ); | 154 | off += sizeof( ot_hash ) + sizeof( ot_peer ); |
| 154 | } | 155 | } |
| 156 | |||
| 157 | stats_issue_event(EVENT_SYNC, 0, datalen / ((ssize_t)sizeof( ot_hash ) + (ssize_t)sizeof( ot_peer ))); | ||
| 155 | } | 158 | } |
| 156 | /* Never returns. */ | 159 | /* Never returns. */ |
| 157 | return NULL; | 160 | return NULL; |
| @@ -30,6 +30,7 @@ typedef enum { | |||
| 30 | TASK_STATS_VERSION = 0x000a, | 30 | TASK_STATS_VERSION = 0x000a, |
| 31 | TASK_STATS_BUSY_NETWORKS = 0x000b, | 31 | TASK_STATS_BUSY_NETWORKS = 0x000b, |
| 32 | TASK_STATS_RENEW = 0x000c, | 32 | TASK_STATS_RENEW = 0x000c, |
| 33 | TASK_STATS_SYNCS = 0x000d, | ||
| 33 | 34 | ||
| 34 | TASK_STATS = 0x0100, /* Mask */ | 35 | TASK_STATS = 0x0100, /* Mask */ |
| 35 | TASK_STATS_TORRENTS = 0x0101, | 36 | TASK_STATS_TORRENTS = 0x0101, |
| @@ -47,6 +47,7 @@ static unsigned long long ot_full_scrape_request_count = 0; | |||
| 47 | static unsigned long long ot_full_scrape_size = 0; | 47 | static unsigned long long ot_full_scrape_size = 0; |
| 48 | static unsigned long long ot_failed_request_counts[CODE_HTTPERROR_COUNT]; | 48 | static unsigned long long ot_failed_request_counts[CODE_HTTPERROR_COUNT]; |
| 49 | static unsigned long long ot_renewed[OT_PEER_TIMEOUT]; | 49 | static unsigned long long ot_renewed[OT_PEER_TIMEOUT]; |
| 50 | static unsigned long long ot_overall_sync_count; | ||
| 50 | 51 | ||
| 51 | static time_t ot_start_time; | 52 | static time_t ot_start_time; |
| 52 | 53 | ||
| @@ -465,6 +466,20 @@ static size_t stats_return_renew_bucket( char * reply ) { | |||
| 465 | return r - reply; | 466 | return r - reply; |
| 466 | } | 467 | } |
| 467 | 468 | ||
| 469 | static size_t stats_return_sync_mrtg( char * reply ) | ||
| 470 | { | ||
| 471 | ot_time t = time( NULL ) - ot_start_time; | ||
| 472 | return sprintf( reply, | ||
| 473 | "%llu\n%llu\n%i seconds (%i hours)\nopentracker connections, %lu conns/s :: %lu success/s.", | ||
| 474 | ot_overall_sync_count, | ||
| 475 | 0, | ||
| 476 | (int)t, | ||
| 477 | (int)(t / 3600), | ||
| 478 | events_per_time( ot_overall_tcp_connections+ot_overall_udp_connections, t ), | ||
| 479 | events_per_time( ot_overall_tcp_successfulannounces+ot_overall_udp_successfulannounces+ot_overall_udp_connects, t ) | ||
| 480 | ); | ||
| 481 | } | ||
| 482 | |||
| 468 | extern const char | 483 | extern const char |
| 469 | *g_version_opentracker_c, *g_version_accesslist_c, *g_version_clean_c, *g_version_fullscrape_c, *g_version_http_c, | 484 | *g_version_opentracker_c, *g_version_accesslist_c, *g_version_clean_c, *g_version_fullscrape_c, *g_version_http_c, |
| 470 | *g_version_iovec_c, *g_version_mutex_c, *g_version_stats_c, *g_version_udp_c, *g_version_vector_c, | 485 | *g_version_iovec_c, *g_version_mutex_c, *g_version_stats_c, *g_version_udp_c, *g_version_vector_c, |
| @@ -500,6 +515,8 @@ size_t return_stats_for_tracker( char *reply, int mode, int format ) { | |||
| 500 | return stats_return_tracker_version( reply ); | 515 | return stats_return_tracker_version( reply ); |
| 501 | case TASK_STATS_RENEW: | 516 | case TASK_STATS_RENEW: |
| 502 | return stats_return_renew_bucket( reply ); | 517 | return stats_return_renew_bucket( reply ); |
| 518 | case TASK_STATS_SYNCS: | ||
| 519 | return stats_return_sync_mrtg( reply ); | ||
| 503 | #ifdef WANT_LOG_NETWORKS | 520 | #ifdef WANT_LOG_NETWORKS |
| 504 | case TASK_STATS_BUSY_NETWORKS: | 521 | case TASK_STATS_BUSY_NETWORKS: |
| 505 | return stats_return_busy_networks( reply ); | 522 | return stats_return_busy_networks( reply ); |
| @@ -566,9 +583,12 @@ void stats_issue_event( ot_status_event event, PROTO_FLAG proto, uint32_t event_ | |||
| 566 | case EVENT_FAILED: | 583 | case EVENT_FAILED: |
| 567 | ot_failed_request_counts[event_data]++; | 584 | ot_failed_request_counts[event_data]++; |
| 568 | break; | 585 | break; |
| 569 | case EVENT_RENEW: | 586 | case EVENT_RENEW: |
| 570 | ot_renewed[event_data]++; | 587 | ot_renewed[event_data]++; |
| 571 | break; | 588 | break; |
| 589 | case EVENT_SYNC: | ||
| 590 | ot_overall_sync_count+=event_data; | ||
| 591 | break; | ||
| 572 | default: | 592 | default: |
| 573 | break; | 593 | break; |
| 574 | } | 594 | } |
| @@ -12,6 +12,7 @@ typedef enum { | |||
| 12 | EVENT_CONNECT, /* UDP only */ | 12 | EVENT_CONNECT, /* UDP only */ |
| 13 | EVENT_ANNOUNCE, | 13 | EVENT_ANNOUNCE, |
| 14 | EVENT_RENEW, | 14 | EVENT_RENEW, |
| 15 | EVENT_SYNC, | ||
| 15 | EVENT_SCRAPE, | 16 | EVENT_SCRAPE, |
| 16 | EVENT_FULLSCRAPE_REQUEST, | 17 | EVENT_FULLSCRAPE_REQUEST, |
| 17 | EVENT_FULLSCRAPE_REQUEST_GZIP, | 18 | EVENT_FULLSCRAPE_REQUEST_GZIP, |
