]> git.ipfire.org Git - thirdparty/opentracker.git/commitdiff
add scrape stats and small correction to udp stats
authordenis <>
Sun, 2 Dec 2007 03:58:36 +0000 (03:58 +0000)
committerdenis <>
Sun, 2 Dec 2007 03:58:36 +0000 (03:58 +0000)
opentracker.c
ot_mutex.h
ot_stats.c

index 46f3bebd8fd9c1deb77d0b42643f01d2258e7b94..debb868ac16cb205530566939cde6d1717d8aeda 100644 (file)
@@ -351,6 +351,8 @@ LOG_TO_STDERR( "sync: %d.%d.%d.%d\n", h->ip[0], h->ip[1], h->ip[2], h->ip[3] );
           mode = TASK_STATS_PEERS;
         else if( !byte_diff(data,4,"conn"))
           mode = TASK_STATS_CONNS;
+        else if( !byte_diff(data,4,"scrp"))
+          mode = TASK_STATS_SCRAPE;
         else if( !byte_diff(data,4,"top5"))
           mode = TASK_STATS_TOP5;
         else if( !byte_diff(data,4,"fscr"))
index e2106be9d188eb8840befe341f0f17d3d7953d63..5cee3f53d0dbf279755380f9e368de49b59179f8 100644 (file)
@@ -24,6 +24,7 @@ typedef enum {
   TASK_STATS_UDP                   = 0x0004,
   TASK_STATS_FULLSCRAPE            = 0x0005,
   TASK_STATS_TPB                   = 0x0006,
+  TASK_STATS_SCRAPE                = 0x0007,
 
   TASK_STATS_SLASH24S              = 0x0100,
 
index 51b2985c60fc0d358240dc70f248e027b1ec4acd..44e24fd8658ec0496c420517b9ef19b8db98bce3 100644 (file)
@@ -24,6 +24,8 @@ static unsigned long long ot_overall_tcp_successfulannounces = 0;
 static unsigned long long ot_overall_udp_successfulannounces = 0;
 static unsigned long long ot_overall_tcp_successfulscrapes = 0;
 static unsigned long long ot_overall_udp_successfulscrapes = 0;
+static unsigned long long ot_overall_tcp_connects = 0;
+static unsigned long long ot_overall_udp_connects = 0;
 static unsigned long long ot_full_scrape_count = 0;
 static unsigned long long ot_full_scrape_size = 0;
 
@@ -171,11 +173,11 @@ static size_t stats_connections_mrtg( char * reply ) {
   return sprintf( reply,
     "%llu\n%llu\n%i seconds (%i hours)\nopentracker connections, %lu conns/s :: %lu success/s.",
     ot_overall_tcp_connections+ot_overall_udp_connections,
-    ot_overall_tcp_successfulannounces+ot_overall_udp_successfulannounces,
+    ot_overall_tcp_successfulannounces+ot_overall_udp_successfulannounces+ot_overall_udp_connects,
     (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, t )
+    events_per_time( ot_overall_tcp_successfulannounces+ot_overall_udp_successfulannounces+ot_overall_udp_connects, t )
   );
 }
 
@@ -184,11 +186,11 @@ static size_t stats_udpconnections_mrtg( char * reply ) {
   return sprintf( reply,
     "%llu\n%llu\n%i seconds (%i hours)\nopentracker udp4 stats, %lu conns/s :: %lu success/s.",
     ot_overall_udp_connections,
-    ot_overall_udp_successfulannounces,
+    ot_overall_udp_successfulannounces+ot_overall_udp_connects,
     (int)t,
     (int)(t / 3600),
     events_per_time( ot_overall_udp_connections, t ),
-    events_per_time( ot_overall_udp_successfulannounces, t )
+    events_per_time( ot_overall_udp_successfulannounces+ot_overall_udp_connects, t )
   );
 }
 
@@ -205,6 +207,17 @@ static size_t stats_tcpconnections_mrtg( char * reply ) {
   );
 }
 
+static size_t stats_scrape_mrtg( char * reply ) {
+  time_t t = time( NULL ) - ot_start_time;
+  return sprintf( reply,
+    "%llu\n%llu\n%i seconds (%i hours)\nopentracker scrape stats, %lu scrape/s (tcp and udp)",
+    ot_overall_tcp_successfulscrapes,
+    ot_overall_udp_successfulscrapes,
+    (int)t,
+    (int)(t / 3600),
+    events_per_time( (ot_overall_tcp_successfulscrapes+ot_overall_udp_successfulscrapes), t )
+  );
+}
 
 static size_t stats_fullscrapes_mrtg( char * reply ) {
   ot_time t = time( NULL ) - ot_start_time;
@@ -244,6 +257,8 @@ size_t return_stats_for_tracker( char *reply, int mode, int format ) {
   switch( mode ) {
     case TASK_STATS_CONNS:
       return stats_connections_mrtg( reply );
+    case TASK_STATS_SCRAPE:
+      return stats_scrape_mrtg( reply );
     case TASK_STATS_UDP:
       return stats_udpconnections_mrtg( reply );
     case TASK_STATS_TCP:
@@ -271,6 +286,8 @@ void stats_issue_event( ot_status_event event, int is_tcp, size_t event_data ) {
       break;
     case EVENT_SCRAPE:
       if( is_tcp ) ot_overall_tcp_successfulscrapes++; else ot_overall_udp_successfulscrapes++;
+    case EVENT_CONNECT:
+      if( is_tcp ) ot_overall_tcp_connects++; else ot_overall_udp_connects++;
     case EVENT_FULLSCRAPE:
       ot_full_scrape_count++;
       ot_full_scrape_size += event_data;