|
|
|
@ -4,16 +4,16 @@
|
|
|
|
|
$id$ */
|
|
|
|
|
|
|
|
|
|
/* System */
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
#include <sys/uio.h>
|
|
|
|
|
#include <sys/mman.h>
|
|
|
|
|
#include <inttypes.h>
|
|
|
|
|
#include <pthread.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <pthread.h>
|
|
|
|
|
#include <sys/mman.h>
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
#include <sys/uio.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <inttypes.h>
|
|
|
|
|
#ifdef WANT_SYSLOGS
|
|
|
|
|
#include <syslog.h>
|
|
|
|
|
#endif
|
|
|
|
@ -25,11 +25,11 @@
|
|
|
|
|
#include "ip6.h"
|
|
|
|
|
|
|
|
|
|
/* Opentracker */
|
|
|
|
|
#include "trackerlogic.h"
|
|
|
|
|
#include "ot_mutex.h"
|
|
|
|
|
#include "ot_accesslist.h"
|
|
|
|
|
#include "ot_iovec.h"
|
|
|
|
|
#include "ot_mutex.h"
|
|
|
|
|
#include "ot_stats.h"
|
|
|
|
|
#include "ot_accesslist.h"
|
|
|
|
|
#include "trackerlogic.h"
|
|
|
|
|
|
|
|
|
|
#ifndef NO_FULLSCRAPE_LOGGING
|
|
|
|
|
#define LOG_TO_STDERR(...) fprintf(stderr, __VA_ARGS__)
|
|
|
|
@ -42,21 +42,23 @@ static void stats_make( int *iovec_entries, struct iovec **iovector, ot_tasktype
|
|
|
|
|
#define OT_STATS_TMPSIZE 8192
|
|
|
|
|
|
|
|
|
|
/* Clumsy counters... to be rethought */
|
|
|
|
|
static unsigned long long ot_overall_tcp_connections = 0;
|
|
|
|
|
static unsigned long long ot_overall_udp_connections = 0;
|
|
|
|
|
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_udp_connectionidmissmatches = 0;
|
|
|
|
|
static unsigned long long ot_overall_tcp_connects = 0;
|
|
|
|
|
static unsigned long long ot_overall_udp_connects = 0;
|
|
|
|
|
static unsigned long long ot_overall_completed = 0;
|
|
|
|
|
static unsigned long long ot_full_scrape_count = 0;
|
|
|
|
|
static unsigned long long ot_full_scrape_request_count = 0;
|
|
|
|
|
static unsigned long long ot_full_scrape_size = 0;
|
|
|
|
|
static unsigned long long ot_overall_tcp_connections;
|
|
|
|
|
static unsigned long long ot_overall_udp_connections;
|
|
|
|
|
static unsigned long long ot_overall_tcp_successfulannounces;
|
|
|
|
|
static unsigned long long ot_overall_udp_successfulannounces;
|
|
|
|
|
static unsigned long long ot_overall_tcp_successfulscrapes;
|
|
|
|
|
static unsigned long long ot_overall_udp_successfulscrapes;
|
|
|
|
|
static unsigned long long ot_overall_udp_connectionidmissmatches;
|
|
|
|
|
static unsigned long long ot_overall_tcp_connects;
|
|
|
|
|
static unsigned long long ot_overall_udp_connects;
|
|
|
|
|
static unsigned long long ot_overall_completed;
|
|
|
|
|
static unsigned long long ot_full_scrape_count;
|
|
|
|
|
static unsigned long long ot_full_scrape_request_count;
|
|
|
|
|
static unsigned long long ot_full_scrape_size;
|
|
|
|
|
static unsigned long long ot_failed_request_counts[CODE_HTTPERROR_COUNT];
|
|
|
|
|
static char * ot_failed_request_names[] = { "302 Redirect", "400 Parse Error", "400 Invalid Parameter", "400 Invalid Parameter (compact=0)", "400 Not Modest", "402 Payment Required", "403 Access Denied", "404 Not found", "500 Internal Server Error" };
|
|
|
|
|
static char *ot_failed_request_names[] = {
|
|
|
|
|
"302 Redirect", "400 Parse Error", "400 Invalid Parameter", "400 Invalid Parameter (compact=0)", "400 Not Modest",
|
|
|
|
|
"402 Payment Required", "403 Access Denied", "404 Not found", "500 Internal Server Error"};
|
|
|
|
|
static unsigned long long ot_renewed[OT_PEER_TIMEOUT];
|
|
|
|
|
static unsigned long long ot_overall_sync_count;
|
|
|
|
|
static unsigned long long ot_overall_stall_count;
|
|
|
|
@ -130,11 +132,13 @@ static int stats_shift_down_network_count( stats_network_node **node, int depth,
|
|
|
|
|
return rest;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static size_t stats_get_highscore_networks( stats_network_node *node, int depth, ot_ip6 node_value, size_t *scores, ot_ip6 *networks, int network_count, int limit ) {
|
|
|
|
|
static size_t stats_get_highscore_networks(stats_network_node *node, int depth, ot_ip6 node_value, size_t *scores, ot_ip6 *networks, int network_count,
|
|
|
|
|
int limit) {
|
|
|
|
|
size_t score = 0;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
if( !node ) return 0;
|
|
|
|
|
if (!node)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
if (depth < limit) {
|
|
|
|
|
for (i = 0; i < STATS_NETWORK_NODE_COUNT; ++i)
|
|
|
|
@ -170,10 +174,12 @@ static size_t stats_get_highscore_networks( stats_network_node *node, int depth,
|
|
|
|
|
|
|
|
|
|
score += node_score;
|
|
|
|
|
|
|
|
|
|
if( node_score <= scores[0] ) continue;
|
|
|
|
|
if (node_score <= scores[0])
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
__STR(node_value, depth, i);
|
|
|
|
|
while( j < network_count && node_score > scores[j] ) ++j;
|
|
|
|
|
while (j < network_count && node_score > scores[j])
|
|
|
|
|
++j;
|
|
|
|
|
--j;
|
|
|
|
|
|
|
|
|
|
memcpy(scores, scores + 1, j * sizeof(*scores));
|
|
|
|
@ -294,9 +300,22 @@ static int torrent_statter( ot_torrent *torrent, uintptr_t data ) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Converter function from memory to human readable hex strings */
|
|
|
|
|
static char*to_hex(char*d,uint8_t*s){char*m="0123456789ABCDEF";char *t=d;char*e=d+40;while(d<e){*d++=m[*s>>4];*d++=m[*s++&15];}*d=0;return t;}
|
|
|
|
|
static char *to_hex(char *d, uint8_t *s) {
|
|
|
|
|
char *m = "0123456789ABCDEF";
|
|
|
|
|
char *t = d;
|
|
|
|
|
char *e = d + 40;
|
|
|
|
|
while (d < e) {
|
|
|
|
|
*d++ = m[*s >> 4];
|
|
|
|
|
*d++ = m[*s++ & 15];
|
|
|
|
|
}
|
|
|
|
|
*d = 0;
|
|
|
|
|
return t;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
typedef struct { size_t val; ot_hash hash; } ot_record;
|
|
|
|
|
typedef struct {
|
|
|
|
|
size_t val;
|
|
|
|
|
ot_hash hash;
|
|
|
|
|
} ot_record;
|
|
|
|
|
|
|
|
|
|
/* Fetches stats from tracker */
|
|
|
|
|
size_t stats_top_txt(char *reply, int amount) {
|
|
|
|
@ -351,72 +370,42 @@ size_t stats_top_txt( char * reply, int amount ) {
|
|
|
|
|
return r - reply;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static unsigned long events_per_time( unsigned long long events, time_t t ) {
|
|
|
|
|
return events / ( (unsigned int)t ? (unsigned int)t : 1 );
|
|
|
|
|
}
|
|
|
|
|
static unsigned long events_per_time(unsigned long long events, time_t t) { return events / ((unsigned int)t ? (unsigned int)t : 1); }
|
|
|
|
|
|
|
|
|
|
static size_t stats_connections_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.",
|
|
|
|
|
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_udp_connects,
|
|
|
|
|
(int)t,
|
|
|
|
|
(int)(t / 3600),
|
|
|
|
|
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+ot_overall_udp_connects, t )
|
|
|
|
|
);
|
|
|
|
|
events_per_time(ot_overall_tcp_successfulannounces + ot_overall_udp_successfulannounces + ot_overall_udp_connects, t));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static size_t stats_udpconnections_mrtg(char *reply) {
|
|
|
|
|
ot_time t = time(NULL) - ot_start_time;
|
|
|
|
|
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_connects,
|
|
|
|
|
(int)t,
|
|
|
|
|
(int)(t / 3600),
|
|
|
|
|
events_per_time( ot_overall_udp_connections, t ),
|
|
|
|
|
events_per_time( ot_overall_udp_successfulannounces+ot_overall_udp_connects, t )
|
|
|
|
|
);
|
|
|
|
|
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_connects, (int)t, (int)(t / 3600), events_per_time(ot_overall_udp_connections, t),
|
|
|
|
|
events_per_time(ot_overall_udp_successfulannounces + ot_overall_udp_connects, t));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static size_t stats_tcpconnections_mrtg(char *reply) {
|
|
|
|
|
time_t t = time(NULL) - ot_start_time;
|
|
|
|
|
return sprintf( reply,
|
|
|
|
|
"%llu\n%llu\n%i seconds (%i hours)\nopentracker tcp4 stats, %lu conns/s :: %lu success/s.",
|
|
|
|
|
ot_overall_tcp_connections,
|
|
|
|
|
ot_overall_tcp_successfulannounces,
|
|
|
|
|
(int)t,
|
|
|
|
|
(int)(t / 3600),
|
|
|
|
|
events_per_time( ot_overall_tcp_connections, t ),
|
|
|
|
|
events_per_time( ot_overall_tcp_successfulannounces, t )
|
|
|
|
|
);
|
|
|
|
|
return sprintf(reply, "%llu\n%llu\n%i seconds (%i hours)\nopentracker tcp4 stats, %lu conns/s :: %lu success/s.", ot_overall_tcp_connections,
|
|
|
|
|
ot_overall_tcp_successfulannounces, (int)t, (int)(t / 3600), events_per_time(ot_overall_tcp_connections, t),
|
|
|
|
|
events_per_time(ot_overall_tcp_successfulannounces, t));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 )
|
|
|
|
|
);
|
|
|
|
|
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;
|
|
|
|
|
return sprintf( reply,
|
|
|
|
|
"%llu\n%llu\n%i seconds (%i hours)\nopentracker full scrape stats, %lu conns/s :: %lu bytes/s.",
|
|
|
|
|
ot_full_scrape_count * 1000,
|
|
|
|
|
ot_full_scrape_size,
|
|
|
|
|
(int)t,
|
|
|
|
|
(int)(t / 3600),
|
|
|
|
|
events_per_time( ot_full_scrape_count, t ),
|
|
|
|
|
events_per_time( ot_full_scrape_size, t )
|
|
|
|
|
);
|
|
|
|
|
return sprintf(reply, "%llu\n%llu\n%i seconds (%i hours)\nopentracker full scrape stats, %lu conns/s :: %lu bytes/s.", ot_full_scrape_count * 1000,
|
|
|
|
|
ot_full_scrape_size, (int)t, (int)(t / 3600), events_per_time(ot_full_scrape_count, t), events_per_time(ot_full_scrape_size, t));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static size_t stats_peers_mrtg(char *reply) {
|
|
|
|
@ -424,29 +413,19 @@ static size_t stats_peers_mrtg( char * reply ) {
|
|
|
|
|
|
|
|
|
|
iterate_all_torrents(torrent_statter, (uintptr_t)&stats);
|
|
|
|
|
|
|
|
|
|
return sprintf( reply, "%llu\n%llu\nopentracker serving %llu torrents\nopentracker",
|
|
|
|
|
stats.peer_count,
|
|
|
|
|
stats.seed_count,
|
|
|
|
|
stats.torrent_count
|
|
|
|
|
);
|
|
|
|
|
return sprintf(reply, "%llu\n%llu\nopentracker serving %llu torrents\nopentracker", stats.peer_count, stats.seed_count, stats.torrent_count);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static size_t stats_torrents_mrtg( char * reply )
|
|
|
|
|
{
|
|
|
|
|
static size_t stats_torrents_mrtg(char *reply) {
|
|
|
|
|
size_t torrent_count = mutex_get_torrent_count();
|
|
|
|
|
|
|
|
|
|
return sprintf( reply, "%zd\n%zd\nopentracker serving %zd torrents\nopentracker",
|
|
|
|
|
torrent_count,
|
|
|
|
|
(size_t)0,
|
|
|
|
|
torrent_count
|
|
|
|
|
);
|
|
|
|
|
return sprintf(reply, "%zd\n%zd\nopentracker serving %zd torrents\nopentracker", torrent_count, (size_t)0, torrent_count);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static size_t stats_httperrors_txt(char *reply) {
|
|
|
|
|
return sprintf( reply, "302 RED %llu\n400 ... %llu\n400 PAR %llu\n400 COM %llu\n403 IP %llu\n404 INV %llu\n500 SRV %llu\n",
|
|
|
|
|
ot_failed_request_counts[0], ot_failed_request_counts[1], ot_failed_request_counts[2],
|
|
|
|
|
ot_failed_request_counts[3], ot_failed_request_counts[4], ot_failed_request_counts[5],
|
|
|
|
|
ot_failed_request_counts[6] );
|
|
|
|
|
return sprintf(reply, "302 RED %llu\n400 ... %llu\n400 PAR %llu\n400 COM %llu\n403 IP %llu\n404 INV %llu\n500 SRV %llu\n", ot_failed_request_counts[0],
|
|
|
|
|
ot_failed_request_counts[1], ot_failed_request_counts[2], ot_failed_request_counts[3], ot_failed_request_counts[4],
|
|
|
|
|
ot_failed_request_counts[5], ot_failed_request_counts[6]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static size_t stats_return_renew_bucket(char *reply) {
|
|
|
|
@ -460,28 +439,16 @@ static size_t stats_return_renew_bucket( char * 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,
|
|
|
|
|
0LL,
|
|
|
|
|
(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 )
|
|
|
|
|
);
|
|
|
|
|
return sprintf(reply, "%llu\n%llu\n%i seconds (%i hours)\nopentracker connections, %lu conns/s :: %lu success/s.", ot_overall_sync_count, 0LL, (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));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static size_t stats_return_completed_mrtg(char *reply) {
|
|
|
|
|
ot_time t = time(NULL) - ot_start_time;
|
|
|
|
|
|
|
|
|
|
return sprintf( reply,
|
|
|
|
|
"%llu\n%llu\n%i seconds (%i hours)\nopentracker, %lu completed/h.",
|
|
|
|
|
ot_overall_completed,
|
|
|
|
|
0LL,
|
|
|
|
|
(int)t,
|
|
|
|
|
(int)(t / 3600),
|
|
|
|
|
events_per_time( ot_overall_completed, t / 3600 )
|
|
|
|
|
);
|
|
|
|
|
return sprintf(reply, "%llu\n%llu\n%i seconds (%i hours)\nopentracker, %lu completed/h.", ot_overall_completed, 0LL, (int)t, (int)(t / 3600),
|
|
|
|
|
events_per_time(ot_overall_completed, t / 3600));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef WANT_LOG_NUMWANT
|
|
|
|
@ -505,7 +472,8 @@ static void stats_return_fulllog( int *iovec_entries, struct iovec **iovector, c
|
|
|
|
|
while (loglist) {
|
|
|
|
|
if (r + (loglist->size + 64) >= re) {
|
|
|
|
|
r = iovec_fix_increase_or_free(iovec_entries, iovector, r, 32 * OT_STATS_TMPSIZE);
|
|
|
|
|
if( !r ) return;
|
|
|
|
|
if (!r)
|
|
|
|
|
return;
|
|
|
|
|
re = r + 32 * OT_STATS_TMPSIZE;
|
|
|
|
|
}
|
|
|
|
|
r += sprintf(r, "%08ld: ", loglist->time);
|
|
|
|
@ -537,7 +505,9 @@ static size_t stats_return_everything( char * reply ) {
|
|
|
|
|
r += sprintf(r, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
|
|
|
|
|
r += sprintf(r, "<stats>\n");
|
|
|
|
|
r += sprintf(r, " <tracker_id>%" PRIu32 "</tracker_id>\n", g_tracker_id);
|
|
|
|
|
r += sprintf( r, " <version>\n" ); r += stats_return_tracker_version( r ); r += sprintf( r, " </version>\n" );
|
|
|
|
|
r += sprintf(r, " <version>\n");
|
|
|
|
|
r += stats_return_tracker_version(r);
|
|
|
|
|
r += sprintf(r, " </version>\n");
|
|
|
|
|
r += sprintf(r, " <uptime>%llu</uptime>\n", (unsigned long long)(time(NULL) - ot_start_time));
|
|
|
|
|
r += sprintf(r, " <torrents>\n");
|
|
|
|
|
r += sprintf(r, " <count_mutex>%zd</count_mutex>\n", mutex_get_torrent_count());
|
|
|
|
@ -547,8 +517,13 @@ static size_t stats_return_everything( char * reply ) {
|
|
|
|
|
r += sprintf(r, " <seeds>\n <count>%llu</count>\n </seeds>\n", stats.seed_count);
|
|
|
|
|
r += sprintf(r, " <completed>\n <count>%llu</count>\n </completed>\n", ot_overall_completed);
|
|
|
|
|
r += sprintf(r, " <connections>\n");
|
|
|
|
|
r += sprintf( r, " <tcp>\n <accept>%llu</accept>\n <announce>%llu</announce>\n <scrape>%llu</scrape>\n </tcp>\n", ot_overall_tcp_connections, ot_overall_tcp_successfulannounces, ot_overall_tcp_successfulscrapes );
|
|
|
|
|
r += sprintf( r, " <udp>\n <overall>%llu</overall>\n <connect>%llu</connect>\n <announce>%llu</announce>\n <scrape>%llu</scrape>\n <missmatch>%llu</missmatch>\n </udp>\n", ot_overall_udp_connections, ot_overall_udp_connects, ot_overall_udp_successfulannounces, ot_overall_udp_successfulscrapes, ot_overall_udp_connectionidmissmatches );
|
|
|
|
|
r += sprintf(r, " <tcp>\n <accept>%llu</accept>\n <announce>%llu</announce>\n <scrape>%llu</scrape>\n </tcp>\n",
|
|
|
|
|
ot_overall_tcp_connections, ot_overall_tcp_successfulannounces, ot_overall_tcp_successfulscrapes);
|
|
|
|
|
r += sprintf(
|
|
|
|
|
r,
|
|
|
|
|
" <udp>\n <overall>%llu</overall>\n <connect>%llu</connect>\n <announce>%llu</announce>\n <scrape>%llu</scrape>\n <missmatch>%llu</missmatch>\n </udp>\n",
|
|
|
|
|
ot_overall_udp_connections, ot_overall_udp_connects, ot_overall_udp_successfulannounces, ot_overall_udp_successfulscrapes,
|
|
|
|
|
ot_overall_udp_connectionidmissmatches);
|
|
|
|
|
r += sprintf(r, " <livesync>\n <count>%llu</count>\n </livesync>\n", ot_overall_sync_count);
|
|
|
|
|
r += sprintf(r, " </connections>\n");
|
|
|
|
|
r += sprintf(r, " <debug>\n");
|
|
|
|
@ -566,15 +541,13 @@ static size_t stats_return_everything( char * reply ) {
|
|
|
|
|
return r - reply;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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,
|
|
|
|
|
*g_version_scan_urlencoded_query_c, *g_version_trackerlogic_c, *g_version_livesync_c, *g_version_rijndael_c;
|
|
|
|
|
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, *g_version_scan_urlencoded_query_c, *g_version_trackerlogic_c,
|
|
|
|
|
*g_version_livesync_c, *g_version_rijndael_c;
|
|
|
|
|
|
|
|
|
|
size_t stats_return_tracker_version(char *reply) {
|
|
|
|
|
return sprintf( reply, "%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
|
|
|
|
|
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,
|
|
|
|
|
return sprintf(reply, "%s%s%s%s%s%s%s%s%s%s%s%s%s%s", 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,
|
|
|
|
|
g_version_scan_urlencoded_query_c, g_version_trackerlogic_c, g_version_livesync_c, g_version_rijndael_c);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -619,22 +592,38 @@ static void stats_make( int *iovec_entries, struct iovec **iovector, ot_tasktype
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
switch (mode & TASK_TASK_MASK) {
|
|
|
|
|
case TASK_STATS_TORRENTS: r += stats_torrents_mrtg( r ); break;
|
|
|
|
|
case TASK_STATS_PEERS: r += stats_peers_mrtg( r ); break;
|
|
|
|
|
case TASK_STATS_SLASH24S: r += stats_slash24s_txt( r, 128 ); break;
|
|
|
|
|
case TASK_STATS_TOP10: r += stats_top_txt( r, 10 ); break;
|
|
|
|
|
case TASK_STATS_TORRENTS:
|
|
|
|
|
r += stats_torrents_mrtg(r);
|
|
|
|
|
break;
|
|
|
|
|
case TASK_STATS_PEERS:
|
|
|
|
|
r += stats_peers_mrtg(r);
|
|
|
|
|
break;
|
|
|
|
|
case TASK_STATS_SLASH24S:
|
|
|
|
|
r += stats_slash24s_txt(r, 128);
|
|
|
|
|
break;
|
|
|
|
|
case TASK_STATS_TOP10:
|
|
|
|
|
r += stats_top_txt(r, 10);
|
|
|
|
|
break;
|
|
|
|
|
case TASK_STATS_TOP100:
|
|
|
|
|
r = iovec_fix_increase_or_free(iovec_entries, iovector, r, 4 * OT_STATS_TMPSIZE);
|
|
|
|
|
if( !r ) return;
|
|
|
|
|
r += stats_top_txt( r, 100 ); break;
|
|
|
|
|
case TASK_STATS_EVERYTHING: r = iovec_fix_increase_or_free( iovec_entries, iovector, r, OT_STATS_TMPSIZE + 64 * OT_PEER_TIMEOUT );
|
|
|
|
|
if( !r ) return;
|
|
|
|
|
r += stats_return_everything( r ); break;
|
|
|
|
|
if (!r)
|
|
|
|
|
return;
|
|
|
|
|
r += stats_top_txt(r, 100);
|
|
|
|
|
break;
|
|
|
|
|
case TASK_STATS_EVERYTHING:
|
|
|
|
|
r = iovec_fix_increase_or_free(iovec_entries, iovector, r, OT_STATS_TMPSIZE + 64 * OT_PEER_TIMEOUT);
|
|
|
|
|
if (!r)
|
|
|
|
|
return;
|
|
|
|
|
r += stats_return_everything(r);
|
|
|
|
|
break;
|
|
|
|
|
#ifdef WANT_SPOT_WOODPECKER
|
|
|
|
|
case TASK_STATS_WOODPECKERS: r += stats_return_woodpeckers( r, 128 ); break;
|
|
|
|
|
case TASK_STATS_WOODPECKERS:
|
|
|
|
|
r += stats_return_woodpeckers(r, 128);
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
#ifdef WANT_FULLLOG_NETWORKS
|
|
|
|
|
case TASK_STATS_FULLLOG: stats_return_fulllog( iovec_entries, iovector, r );
|
|
|
|
|
case TASK_STATS_FULLLOG:
|
|
|
|
|
stats_return_fulllog(iovec_entries, iovector, r);
|
|
|
|
|
return;
|
|
|
|
|
#endif
|
|
|
|
|
default:
|
|
|
|
@ -647,16 +636,25 @@ static void stats_make( int *iovec_entries, struct iovec **iovector, ot_tasktype
|
|
|
|
|
void stats_issue_event(ot_status_event event, PROTO_FLAG proto, uintptr_t event_data) {
|
|
|
|
|
switch (event) {
|
|
|
|
|
case EVENT_ACCEPT:
|
|
|
|
|
if( proto == FLAG_TCP ) ot_overall_tcp_connections++; else ot_overall_udp_connections++;
|
|
|
|
|
if (proto == FLAG_TCP)
|
|
|
|
|
ot_overall_tcp_connections++;
|
|
|
|
|
else
|
|
|
|
|
ot_overall_udp_connections++;
|
|
|
|
|
#ifdef WANT_LOG_NETWORKS
|
|
|
|
|
stat_increase_network_count(&stats_network_counters_root, 0, event_data);
|
|
|
|
|
#endif
|
|
|
|
|
break;
|
|
|
|
|
case EVENT_ANNOUNCE:
|
|
|
|
|
if( proto == FLAG_TCP ) ot_overall_tcp_successfulannounces++; else ot_overall_udp_successfulannounces++;
|
|
|
|
|
if (proto == FLAG_TCP)
|
|
|
|
|
ot_overall_tcp_successfulannounces++;
|
|
|
|
|
else
|
|
|
|
|
ot_overall_udp_successfulannounces++;
|
|
|
|
|
break;
|
|
|
|
|
case EVENT_CONNECT:
|
|
|
|
|
if( proto == FLAG_TCP ) ot_overall_tcp_connects++; else ot_overall_udp_connects++;
|
|
|
|
|
if (proto == FLAG_TCP)
|
|
|
|
|
ot_overall_tcp_connects++;
|
|
|
|
|
else
|
|
|
|
|
ot_overall_udp_connects++;
|
|
|
|
|
break;
|
|
|
|
|
case EVENT_COMPLETED:
|
|
|
|
|
#ifdef WANT_SYSLOGS
|
|
|
|
@ -689,14 +687,16 @@ void stats_issue_event( ot_status_event event, PROTO_FLAG proto, uintptr_t event
|
|
|
|
|
ot_overall_completed++;
|
|
|
|
|
break;
|
|
|
|
|
case EVENT_SCRAPE:
|
|
|
|
|
if( proto == FLAG_TCP ) ot_overall_tcp_successfulscrapes++; else ot_overall_udp_successfulscrapes++;
|
|
|
|
|
if (proto == FLAG_TCP)
|
|
|
|
|
ot_overall_tcp_successfulscrapes++;
|
|
|
|
|
else
|
|
|
|
|
ot_overall_udp_successfulscrapes++;
|
|
|
|
|
break;
|
|
|
|
|
case EVENT_FULLSCRAPE:
|
|
|
|
|
ot_full_scrape_count++;
|
|
|
|
|
ot_full_scrape_size += event_data;
|
|
|
|
|
break;
|
|
|
|
|
case EVENT_FULLSCRAPE_REQUEST:
|
|
|
|
|
{
|
|
|
|
|
case EVENT_FULLSCRAPE_REQUEST: {
|
|
|
|
|
ot_ip6 *ip = (ot_ip6 *)event_data; /* ugly hack to transfer ip to stats */
|
|
|
|
|
char _debug[512];
|
|
|
|
|
int off = snprintf(_debug, sizeof(_debug), "[%08d] scrp: ", (unsigned int)(g_now_seconds - ot_start_time) / 60);
|
|
|
|
@ -704,10 +704,8 @@ void stats_issue_event( ot_status_event event, PROTO_FLAG proto, uintptr_t event
|
|
|
|
|
off += snprintf(_debug + off, sizeof(_debug) - off, " - FULL SCRAPE\n");
|
|
|
|
|
(void)write(2, _debug, off);
|
|
|
|
|
ot_full_scrape_request_count++;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case EVENT_FULLSCRAPE_REQUEST_GZIP:
|
|
|
|
|
{
|
|
|
|
|
} break;
|
|
|
|
|
case EVENT_FULLSCRAPE_REQUEST_GZIP: {
|
|
|
|
|
ot_ip6 *ip = (ot_ip6 *)event_data; /* ugly hack to transfer ip to stats */
|
|
|
|
|
char _debug[512];
|
|
|
|
|
int off = snprintf(_debug, sizeof(_debug), "[%08d] scrp: ", (unsigned int)(g_now_seconds - ot_start_time) / 60);
|
|
|
|
@ -715,8 +713,7 @@ void stats_issue_event( ot_status_event event, PROTO_FLAG proto, uintptr_t event
|
|
|
|
|
off += snprintf(_debug + off, sizeof(_debug) - off, " - FULL SCRAPE\n");
|
|
|
|
|
(void)write(2, _debug, off);
|
|
|
|
|
ot_full_scrape_request_count++;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
} break;
|
|
|
|
|
case EVENT_FAILED:
|
|
|
|
|
ot_failed_request_counts[event_data]++;
|
|
|
|
|
break;
|
|
|
|
@ -767,9 +764,7 @@ static void * stats_worker( void * args ) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void stats_deliver( int64 sock, int tasktype ) {
|
|
|
|
|
mutex_workqueue_pushtask( sock, tasktype );
|
|
|
|
|
}
|
|
|
|
|
void stats_deliver(int64 sock, int tasktype) { mutex_workqueue_pushtask(sock, tasktype); }
|
|
|
|
|
|
|
|
|
|
static pthread_t thread_id;
|
|
|
|
|
void stats_init() {
|
|
|
|
|