mirror of
git://erdgeist.org/opentracker
synced 2025-01-14 08:50:10 +00:00
Add stats about when peers renew their announces.
This commit is contained in:
parent
daaee855b2
commit
bb1c5d2805
@ -28,6 +28,7 @@ typedef enum {
|
|||||||
TASK_STATS_VERSION = 0x000a,
|
TASK_STATS_VERSION = 0x000a,
|
||||||
TASK_STATS_BUSY_NETWORKS = 0x000b,
|
TASK_STATS_BUSY_NETWORKS = 0x000b,
|
||||||
TASK_STATS_VECTOR_DEBUG = 0x000c,
|
TASK_STATS_VECTOR_DEBUG = 0x000c,
|
||||||
|
TASK_STATS_RENEW = 0x000d,
|
||||||
|
|
||||||
TASK_STATS = 0x0100, /* Mask */
|
TASK_STATS = 0x0100, /* Mask */
|
||||||
TASK_STATS_TORRENTS = 0x0101,
|
TASK_STATS_TORRENTS = 0x0101,
|
||||||
|
15
ot_stats.c
15
ot_stats.c
@ -46,6 +46,7 @@ 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_request_count = 0;
|
||||||
static unsigned long long ot_full_scrape_size = 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_failed_request_counts[CODE_HTTPERROR_COUNT];
|
||||||
|
static unsigned long long ot_renewed[OT_POOLS_COUNT];
|
||||||
|
|
||||||
static time_t ot_start_time;
|
static time_t ot_start_time;
|
||||||
|
|
||||||
@ -492,6 +493,15 @@ static size_t stats_httperrors_txt ( char * reply ) {
|
|||||||
ot_failed_request_counts[6] );
|
ot_failed_request_counts[6] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static size_t stats_return_renew_bucket( char * reply ) {
|
||||||
|
char *r = reply;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for( i=0; i<OT_BUCKET_COUNT; ++i )
|
||||||
|
r+=sprintf(r,"%02i %llu\n", i, ot_renewed[i] );
|
||||||
|
return r - reply;
|
||||||
|
}
|
||||||
|
|
||||||
extern const char
|
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_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_sync_c, *g_version_udp_c, *g_version_vector_c,
|
*g_version_iovec_c, *g_version_mutex_c, *g_version_stats_c, *g_version_sync_c, *g_version_udp_c, *g_version_vector_c,
|
||||||
@ -525,6 +535,8 @@ size_t return_stats_for_tracker( char *reply, int mode, int format ) {
|
|||||||
return stats_httperrors_txt( reply );
|
return stats_httperrors_txt( reply );
|
||||||
case TASK_STATS_VERSION:
|
case TASK_STATS_VERSION:
|
||||||
return stats_return_tracker_version( reply );
|
return stats_return_tracker_version( reply );
|
||||||
|
case TASK_STATS_RENEW:
|
||||||
|
return stats_return_renew_bucket( reply );
|
||||||
#ifdef WANT_LOG_NETWORKS
|
#ifdef WANT_LOG_NETWORKS
|
||||||
case TASK_STATS_BUSY_NETWORKS:
|
case TASK_STATS_BUSY_NETWORKS:
|
||||||
return stats_return_busy_networks( reply );
|
return stats_return_busy_networks( reply );
|
||||||
@ -596,6 +608,9 @@ void stats_issue_event( ot_status_event event, PROTO_FLAG proto, uint32_t event_
|
|||||||
case EVENT_FAILED:
|
case EVENT_FAILED:
|
||||||
ot_failed_request_counts[event_data]++;
|
ot_failed_request_counts[event_data]++;
|
||||||
break;
|
break;
|
||||||
|
case EVENT_RENEW:
|
||||||
|
ot_renewed[event_data]++;
|
||||||
|
break;
|
||||||
case EVENT_SYNC_IN_REQUEST:
|
case EVENT_SYNC_IN_REQUEST:
|
||||||
case EVENT_SYNC_IN:
|
case EVENT_SYNC_IN:
|
||||||
case EVENT_SYNC_OUT_REQUEST:
|
case EVENT_SYNC_OUT_REQUEST:
|
||||||
|
@ -11,6 +11,7 @@ typedef enum {
|
|||||||
EVENT_READ,
|
EVENT_READ,
|
||||||
EVENT_CONNECT, /* UDP only */
|
EVENT_CONNECT, /* UDP only */
|
||||||
EVENT_ANNOUNCE,
|
EVENT_ANNOUNCE,
|
||||||
|
EVENT_RENEW,
|
||||||
EVENT_SCRAPE,
|
EVENT_SCRAPE,
|
||||||
EVENT_FULLSCRAPE_REQUEST,
|
EVENT_FULLSCRAPE_REQUEST,
|
||||||
EVENT_FULLSCRAPE_REQUEST_GZIP,
|
EVENT_FULLSCRAPE_REQUEST_GZIP,
|
||||||
|
@ -91,6 +91,8 @@ ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer WANT_SYNC_PARAM(
|
|||||||
return torrent;
|
return torrent;
|
||||||
}
|
}
|
||||||
base_pool = 1;
|
base_pool = 1;
|
||||||
|
if( torrent->peer_list->base < NOW )
|
||||||
|
torrent->peer_list->base = NOW;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -125,6 +127,7 @@ ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer WANT_SYNC_PARAM(
|
|||||||
case 1: default:
|
case 1: default:
|
||||||
torrent->peer_list->peer_count--;
|
torrent->peer_list->peer_count--;
|
||||||
mutex_bucket_unlock_by_hash( hash );
|
mutex_bucket_unlock_by_hash( hash );
|
||||||
|
stats_issue_event( EVENT_RENEW, 0, i );
|
||||||
return torrent;
|
return torrent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -142,6 +145,7 @@ ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer WANT_SYNC_PARAM(
|
|||||||
if( OT_FLAG( peer_dest ) & PEER_FLAG_COMPLETED )
|
if( OT_FLAG( peer_dest ) & PEER_FLAG_COMPLETED )
|
||||||
OT_FLAG( peer ) |= PEER_FLAG_COMPLETED;
|
OT_FLAG( peer ) |= PEER_FLAG_COMPLETED;
|
||||||
|
|
||||||
|
stats_issue_event( EVENT_RENEW, 0, base_pool );
|
||||||
memmove( peer_dest, peer, sizeof( ot_peer ) );
|
memmove( peer_dest, peer, sizeof( ot_peer ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user