]> git.ipfire.org Git - thirdparty/opentracker.git/commitdiff
stats fuer sync
authordenis <>
Wed, 3 Dec 2008 20:36:16 +0000 (20:36 +0000)
committerdenis <>
Wed, 3 Dec 2008 20:36:16 +0000 (20:36 +0000)
ot_http.c
ot_livesync.c
ot_mutex.h
ot_stats.c
ot_stats.h

index d8ab0a28e58ad7e1659c1ce7d5f4f058a2ce9207..5bcc725f3f43d19e9eaff6b80fcd355b89029acf 100644 (file)
--- 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
             mode = TASK_STATS_TOP10;
           else if( !byte_diff(data,5,"renew"))
             mode = TASK_STATS_RENEW;
+          else if( !byte_diff(data,5,"syncs"))
+            mode = TASK_STATS_SYNCS;
           else
             HTTPERROR_400_PARAM;
           break;
index f6e4e5134b04016e6b6e5345f6ee1f4432c52f91..1b1efe08f34e799a1fb78cb3b79a28848a1cb92a 100644 (file)
@@ -17,6 +17,7 @@
 #include "trackerlogic.h"
 #include "ot_livesync.h"
 #include "ot_accesslist.h"
+#include "ot_stats.h"
 
 #ifdef WANT_SYNC_LIVE
 
@@ -152,6 +153,8 @@ static void * livesync_worker( void * args ) {
 
       off += sizeof( ot_hash ) + sizeof( ot_peer );
     }
+
+    stats_issue_event(EVENT_SYNC, 0, datalen / ((ssize_t)sizeof( ot_hash ) + (ssize_t)sizeof( ot_peer )));
   }
   /* Never returns. */
   return NULL;
index ae295beaf1aded80509d717fb24119933821f841..70383329181e7417c4e03700044dafab58581e8e 100644 (file)
@@ -30,6 +30,7 @@ typedef enum {
   TASK_STATS_VERSION               = 0x000a,
   TASK_STATS_BUSY_NETWORKS         = 0x000b,
   TASK_STATS_RENEW                 = 0x000c,
+  TASK_STATS_SYNCS                 = 0x000d,
 
   TASK_STATS                       = 0x0100, /* Mask */
   TASK_STATS_TORRENTS              = 0x0101,
index 2428adf47cec7fa1015f05ac892021dd97ffe30f..f31324c7cae012855073da9daec28aa80b453f0b 100644 (file)
@@ -47,6 +47,7 @@ static unsigned long long ot_full_scrape_request_count = 0;
 static unsigned long long ot_full_scrape_size = 0;
 static unsigned long long ot_failed_request_counts[CODE_HTTPERROR_COUNT];
 static unsigned long long ot_renewed[OT_PEER_TIMEOUT];
+static unsigned long long ot_overall_sync_count;
 
 static time_t ot_start_time;
 
@@ -465,6 +466,20 @@ static size_t stats_return_renew_bucket( char * reply ) {
   return r - reply;
 }
 
+static size_t stats_return_sync_mrtg( char * reply )
+{
+       ot_time t = time( NULL ) - ot_start_time;
+       return sprintf( reply,
+                                  "%llu\n%llu\n%i seconds (%i hours)\nopentracker connections, %lu conns/s :: %lu success/s.",
+                                  ot_overall_sync_count,
+                                  0,
+                                  (int)t,
+                                  (int)(t / 3600),
+                                  events_per_time( ot_overall_tcp_connections+ot_overall_udp_connections, t ),
+                                  events_per_time( ot_overall_tcp_successfulannounces+ot_overall_udp_successfulannounces+ot_overall_udp_connects, t )
+                                  );
+}
+
 extern const char
 *g_version_opentracker_c, *g_version_accesslist_c, *g_version_clean_c, *g_version_fullscrape_c, *g_version_http_c,
 *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 ) {
       return stats_return_tracker_version( reply );
     case TASK_STATS_RENEW:
       return stats_return_renew_bucket( reply );
+    case TASK_STATS_SYNCS:
+         return stats_return_sync_mrtg( reply );
 #ifdef WANT_LOG_NETWORKS
     case TASK_STATS_BUSY_NETWORKS:
       return stats_return_busy_networks( reply );
@@ -566,9 +583,12 @@ void stats_issue_event( ot_status_event event, PROTO_FLAG proto, uint32_t event_
     case EVENT_FAILED:
       ot_failed_request_counts[event_data]++;
       break;
-    case EVENT_RENEW:
+       case EVENT_RENEW:
       ot_renewed[event_data]++;
       break;
+    case EVENT_SYNC:
+      ot_overall_sync_count+=event_data;
+         break;
     default:
       break;
   }
index f930a3feaac61fb57a4b9b23e59fa5a474124906..287382f2dff08b3d03c9fd1260ebac54fa160f11 100644 (file)
@@ -12,6 +12,7 @@ typedef enum {
   EVENT_CONNECT,      /* UDP only */
   EVENT_ANNOUNCE,
   EVENT_RENEW,
+  EVENT_SYNC,
   EVENT_SCRAPE,
   EVENT_FULLSCRAPE_REQUEST,
   EVENT_FULLSCRAPE_REQUEST_GZIP,