summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordenis <>2007-12-02 03:58:36 +0000
committerdenis <>2007-12-02 03:58:36 +0000
commit0a1cc183588dfd3f02c8ff6519c3214355404b8b (patch)
tree7e8ac3d1ee0fb3e30ce137695c07e84800e973bf
parentae1863f232c2a2e741f88e8d946103052cd0583a (diff)
add scrape stats and small correction to udp stats
-rw-r--r--opentracker.c2
-rw-r--r--ot_mutex.h1
-rw-r--r--ot_stats.c25
3 files changed, 24 insertions, 4 deletions
diff --git a/opentracker.c b/opentracker.c
index 46f3beb..debb868 100644
--- a/opentracker.c
+++ b/opentracker.c
@@ -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] );
351 mode = TASK_STATS_PEERS; 351 mode = TASK_STATS_PEERS;
352 else if( !byte_diff(data,4,"conn")) 352 else if( !byte_diff(data,4,"conn"))
353 mode = TASK_STATS_CONNS; 353 mode = TASK_STATS_CONNS;
354 else if( !byte_diff(data,4,"scrp"))
355 mode = TASK_STATS_SCRAPE;
354 else if( !byte_diff(data,4,"top5")) 356 else if( !byte_diff(data,4,"top5"))
355 mode = TASK_STATS_TOP5; 357 mode = TASK_STATS_TOP5;
356 else if( !byte_diff(data,4,"fscr")) 358 else if( !byte_diff(data,4,"fscr"))
diff --git a/ot_mutex.h b/ot_mutex.h
index e2106be..5cee3f5 100644
--- a/ot_mutex.h
+++ b/ot_mutex.h
@@ -24,6 +24,7 @@ typedef enum {
24 TASK_STATS_UDP = 0x0004, 24 TASK_STATS_UDP = 0x0004,
25 TASK_STATS_FULLSCRAPE = 0x0005, 25 TASK_STATS_FULLSCRAPE = 0x0005,
26 TASK_STATS_TPB = 0x0006, 26 TASK_STATS_TPB = 0x0006,
27 TASK_STATS_SCRAPE = 0x0007,
27 28
28 TASK_STATS_SLASH24S = 0x0100, 29 TASK_STATS_SLASH24S = 0x0100,
29 30
diff --git a/ot_stats.c b/ot_stats.c
index 51b2985..44e24fd 100644
--- a/ot_stats.c
+++ b/ot_stats.c
@@ -24,6 +24,8 @@ static unsigned long long ot_overall_tcp_successfulannounces = 0;
24static unsigned long long ot_overall_udp_successfulannounces = 0; 24static unsigned long long ot_overall_udp_successfulannounces = 0;
25static unsigned long long ot_overall_tcp_successfulscrapes = 0; 25static unsigned long long ot_overall_tcp_successfulscrapes = 0;
26static unsigned long long ot_overall_udp_successfulscrapes = 0; 26static unsigned long long ot_overall_udp_successfulscrapes = 0;
27static unsigned long long ot_overall_tcp_connects = 0;
28static unsigned long long ot_overall_udp_connects = 0;
27static unsigned long long ot_full_scrape_count = 0; 29static unsigned long long ot_full_scrape_count = 0;
28static unsigned long long ot_full_scrape_size = 0; 30static unsigned long long ot_full_scrape_size = 0;
29 31
@@ -171,11 +173,11 @@ static size_t stats_connections_mrtg( char * reply ) {
171 return sprintf( reply, 173 return sprintf( reply,
172 "%llu\n%llu\n%i seconds (%i hours)\nopentracker connections, %lu conns/s :: %lu success/s.", 174 "%llu\n%llu\n%i seconds (%i hours)\nopentracker connections, %lu conns/s :: %lu success/s.",
173 ot_overall_tcp_connections+ot_overall_udp_connections, 175 ot_overall_tcp_connections+ot_overall_udp_connections,
174 ot_overall_tcp_successfulannounces+ot_overall_udp_successfulannounces, 176 ot_overall_tcp_successfulannounces+ot_overall_udp_successfulannounces+ot_overall_udp_connects,
175 (int)t, 177 (int)t,
176 (int)(t / 3600), 178 (int)(t / 3600),
177 events_per_time( ot_overall_tcp_connections+ot_overall_udp_connections, t ), 179 events_per_time( ot_overall_tcp_connections+ot_overall_udp_connections, t ),
178 events_per_time( ot_overall_tcp_successfulannounces+ot_overall_udp_successfulannounces, t ) 180 events_per_time( ot_overall_tcp_successfulannounces+ot_overall_udp_successfulannounces+ot_overall_udp_connects, t )
179 ); 181 );
180} 182}
181 183
@@ -184,11 +186,11 @@ static size_t stats_udpconnections_mrtg( char * reply ) {
184 return sprintf( reply, 186 return sprintf( reply,
185 "%llu\n%llu\n%i seconds (%i hours)\nopentracker udp4 stats, %lu conns/s :: %lu success/s.", 187 "%llu\n%llu\n%i seconds (%i hours)\nopentracker udp4 stats, %lu conns/s :: %lu success/s.",
186 ot_overall_udp_connections, 188 ot_overall_udp_connections,
187 ot_overall_udp_successfulannounces, 189 ot_overall_udp_successfulannounces+ot_overall_udp_connects,
188 (int)t, 190 (int)t,
189 (int)(t / 3600), 191 (int)(t / 3600),
190 events_per_time( ot_overall_udp_connections, t ), 192 events_per_time( ot_overall_udp_connections, t ),
191 events_per_time( ot_overall_udp_successfulannounces, t ) 193 events_per_time( ot_overall_udp_successfulannounces+ot_overall_udp_connects, t )
192 ); 194 );
193} 195}
194 196
@@ -205,6 +207,17 @@ static size_t stats_tcpconnections_mrtg( char * reply ) {
205 ); 207 );
206} 208}
207 209
210static size_t stats_scrape_mrtg( char * reply ) {
211 time_t t = time( NULL ) - ot_start_time;
212 return sprintf( reply,
213 "%llu\n%llu\n%i seconds (%i hours)\nopentracker scrape stats, %lu scrape/s (tcp and udp)",
214 ot_overall_tcp_successfulscrapes,
215 ot_overall_udp_successfulscrapes,
216 (int)t,
217 (int)(t / 3600),
218 events_per_time( (ot_overall_tcp_successfulscrapes+ot_overall_udp_successfulscrapes), t )
219 );
220}
208 221
209static size_t stats_fullscrapes_mrtg( char * reply ) { 222static size_t stats_fullscrapes_mrtg( char * reply ) {
210 ot_time t = time( NULL ) - ot_start_time; 223 ot_time t = time( NULL ) - ot_start_time;
@@ -244,6 +257,8 @@ size_t return_stats_for_tracker( char *reply, int mode, int format ) {
244 switch( mode ) { 257 switch( mode ) {
245 case TASK_STATS_CONNS: 258 case TASK_STATS_CONNS:
246 return stats_connections_mrtg( reply ); 259 return stats_connections_mrtg( reply );
260 case TASK_STATS_SCRAPE:
261 return stats_scrape_mrtg( reply );
247 case TASK_STATS_UDP: 262 case TASK_STATS_UDP:
248 return stats_udpconnections_mrtg( reply ); 263 return stats_udpconnections_mrtg( reply );
249 case TASK_STATS_TCP: 264 case TASK_STATS_TCP:
@@ -271,6 +286,8 @@ void stats_issue_event( ot_status_event event, int is_tcp, size_t event_data ) {
271 break; 286 break;
272 case EVENT_SCRAPE: 287 case EVENT_SCRAPE:
273 if( is_tcp ) ot_overall_tcp_successfulscrapes++; else ot_overall_udp_successfulscrapes++; 288 if( is_tcp ) ot_overall_tcp_successfulscrapes++; else ot_overall_udp_successfulscrapes++;
289 case EVENT_CONNECT:
290 if( is_tcp ) ot_overall_tcp_connects++; else ot_overall_udp_connects++;
274 case EVENT_FULLSCRAPE: 291 case EVENT_FULLSCRAPE:
275 ot_full_scrape_count++; 292 ot_full_scrape_count++;
276 ot_full_scrape_size += event_data; 293 ot_full_scrape_size += event_data;