summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordenis <>2008-12-03 20:36:16 +0000
committerdenis <>2008-12-03 20:36:16 +0000
commitbfbb5ecb447c46b2b10248ab47f980dd968cae68 (patch)
tree56f2db008cdc9b301f2cb24ff56fd0e24359dcca
parent566e8267e15032dfd9f12320c83deee4d74d13cb (diff)
stats fuer sync
-rw-r--r--ot_http.c2
-rw-r--r--ot_livesync.c3
-rw-r--r--ot_mutex.h1
-rw-r--r--ot_stats.c22
-rw-r--r--ot_stats.h1
5 files changed, 28 insertions, 1 deletions
diff --git a/ot_http.c b/ot_http.c
index d8ab0a2..5bcc725 100644
--- a/ot_http.c
+++ b/ot_http.c
@@ -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;
diff --git a/ot_mutex.h b/ot_mutex.h
index ae295be..7038332 100644
--- a/ot_mutex.h
+++ b/ot_mutex.h
@@ -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,
diff --git a/ot_stats.c b/ot_stats.c
index 2428adf..f31324c 100644
--- a/ot_stats.c
+++ b/ot_stats.c
@@ -47,6 +47,7 @@ static unsigned long long ot_full_scrape_request_count = 0;
47static unsigned long long ot_full_scrape_size = 0; 47static unsigned long long ot_full_scrape_size = 0;
48static unsigned long long ot_failed_request_counts[CODE_HTTPERROR_COUNT]; 48static unsigned long long ot_failed_request_counts[CODE_HTTPERROR_COUNT];
49static unsigned long long ot_renewed[OT_PEER_TIMEOUT]; 49static unsigned long long ot_renewed[OT_PEER_TIMEOUT];
50static unsigned long long ot_overall_sync_count;
50 51
51static time_t ot_start_time; 52static 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
469static 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
468extern const char 483extern 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 }
diff --git a/ot_stats.h b/ot_stats.h
index f930a3f..287382f 100644
--- a/ot_stats.h
+++ b/ot_stats.h
@@ -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,