add scrape stats and small correction to udp stats

dynamic-accesslists
denis 17 years ago
parent ae1863f232
commit 0a1cc18358

@ -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; mode = TASK_STATS_PEERS;
else if( !byte_diff(data,4,"conn")) else if( !byte_diff(data,4,"conn"))
mode = TASK_STATS_CONNS; mode = TASK_STATS_CONNS;
else if( !byte_diff(data,4,"scrp"))
mode = TASK_STATS_SCRAPE;
else if( !byte_diff(data,4,"top5")) else if( !byte_diff(data,4,"top5"))
mode = TASK_STATS_TOP5; mode = TASK_STATS_TOP5;
else if( !byte_diff(data,4,"fscr")) else if( !byte_diff(data,4,"fscr"))

@ -24,6 +24,7 @@ typedef enum {
TASK_STATS_UDP = 0x0004, TASK_STATS_UDP = 0x0004,
TASK_STATS_FULLSCRAPE = 0x0005, TASK_STATS_FULLSCRAPE = 0x0005,
TASK_STATS_TPB = 0x0006, TASK_STATS_TPB = 0x0006,
TASK_STATS_SCRAPE = 0x0007,
TASK_STATS_SLASH24S = 0x0100, TASK_STATS_SLASH24S = 0x0100,

@ -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_udp_successfulannounces = 0;
static unsigned long long ot_overall_tcp_successfulscrapes = 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_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_count = 0;
static unsigned long long ot_full_scrape_size = 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, return sprintf( reply,
"%llu\n%llu\n%i seconds (%i hours)\nopentracker connections, %lu conns/s :: %lu success/s.", "%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_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,
(int)(t / 3600), (int)(t / 3600),
events_per_time( ot_overall_tcp_connections+ot_overall_udp_connections, t ), 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, return sprintf( reply,
"%llu\n%llu\n%i seconds (%i hours)\nopentracker udp4 stats, %lu conns/s :: %lu success/s.", "%llu\n%llu\n%i seconds (%i hours)\nopentracker udp4 stats, %lu conns/s :: %lu success/s.",
ot_overall_udp_connections, ot_overall_udp_connections,
ot_overall_udp_successfulannounces, ot_overall_udp_successfulannounces+ot_overall_udp_connects,
(int)t, (int)t,
(int)(t / 3600), (int)(t / 3600),
events_per_time( ot_overall_udp_connections, t ), 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 ) { static size_t stats_fullscrapes_mrtg( char * reply ) {
ot_time t = time( NULL ) - ot_start_time; 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 ) { switch( mode ) {
case TASK_STATS_CONNS: case TASK_STATS_CONNS:
return stats_connections_mrtg( reply ); return stats_connections_mrtg( reply );
case TASK_STATS_SCRAPE:
return stats_scrape_mrtg( reply );
case TASK_STATS_UDP: case TASK_STATS_UDP:
return stats_udpconnections_mrtg( reply ); return stats_udpconnections_mrtg( reply );
case TASK_STATS_TCP: case TASK_STATS_TCP:
@ -271,6 +286,8 @@ void stats_issue_event( ot_status_event event, int is_tcp, size_t event_data ) {
break; break;
case EVENT_SCRAPE: case EVENT_SCRAPE:
if( is_tcp ) ot_overall_tcp_successfulscrapes++; else ot_overall_udp_successfulscrapes++; 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: case EVENT_FULLSCRAPE:
ot_full_scrape_count++; ot_full_scrape_count++;
ot_full_scrape_size += event_data; ot_full_scrape_size += event_data;

Loading…
Cancel
Save