From 255ac58971d6ceef844b53ec32149b537285596a Mon Sep 17 00:00:00 2001 From: erdgeist <> Date: Wed, 4 Mar 2009 15:33:44 +0000 Subject: Add a everything stats page. So you won't have to remember what all those switches were. Remove the prepared Add/Remove-Torrent count until we implement it. Remove the start/stop count until we implement it. --- ot_http.c | 2 +- ot_mutex.h | 11 ++++----- ot_stats.c | 83 +++++++++++++++++++++++--------------------------------------- 3 files changed, 37 insertions(+), 59 deletions(-) diff --git a/ot_http.c b/ot_http.c index de57dad..c184c0e 100644 --- a/ot_http.c +++ b/ot_http.c @@ -165,7 +165,7 @@ static const ot_keywords keywords_mode[] = { "busy", TASK_STATS_BUSY_NETWORKS }, { "torr", TASK_STATS_TORRENTS }, { "fscr", TASK_STATS_FULLSCRAPE }, { "s24s", TASK_STATS_SLASH24S }, { "tpbs", TASK_STATS_TPB }, { "herr", TASK_STATS_HTTPERRORS }, { "top10", TASK_STATS_TOP10 }, { "renew", TASK_STATS_RENEW }, { "syncs", TASK_STATS_SYNCS }, { "version", TASK_STATS_VERSION }, - { "startstop", TASK_STATS_STARTSTOP }, { "toraddrem", TASK_STATS_TORADDREM }, { NULL, -3 } }; + { "everything", TASK_STATS_EVERYTHING }, { NULL, -3 } }; static const ot_keywords keywords_format[] = { { "bin", TASK_FULLSCRAPE_TPB_BINARY }, { "ben", TASK_FULLSCRAPE }, { "url", TASK_FULLSCRAPE_TPB_URLENCODED }, { "txt", TASK_FULLSCRAPE_TPB_ASCII }, { NULL, -3 } }; diff --git a/ot_mutex.h b/ot_mutex.h index 85653ce..5bde9e4 100644 --- a/ot_mutex.h +++ b/ot_mutex.h @@ -27,18 +27,17 @@ typedef enum { TASK_STATS_FULLSCRAPE = 0x0005, TASK_STATS_TPB = 0x0006, TASK_STATS_HTTPERRORS = 0x0007, - TASK_STATS_STARTSTOP = 0x0008, - TASK_STATS_TORADDREM = 0x0009, - TASK_STATS_VERSION = 0x000a, - TASK_STATS_BUSY_NETWORKS = 0x000b, - TASK_STATS_RENEW = 0x000c, - TASK_STATS_SYNCS = 0x000d, + TASK_STATS_VERSION = 0x0008, + TASK_STATS_BUSY_NETWORKS = 0x0009, + TASK_STATS_RENEW = 0x000a, + TASK_STATS_SYNCS = 0x000b, TASK_STATS = 0x0100, /* Mask */ TASK_STATS_TORRENTS = 0x0101, TASK_STATS_PEERS = 0x0102, TASK_STATS_SLASH24S = 0x0103, TASK_STATS_TOP10 = 0x0104, + TASK_STATS_EVERYTHING = 0x0105, TASK_FULLSCRAPE = 0x0200, /* Default mode */ TASK_FULLSCRAPE_TPB_BINARY = 0x0201, diff --git a/ot_stats.c b/ot_stats.c index 518dbb5..9ce985f 100644 --- a/ot_stats.c +++ b/ot_stats.c @@ -48,6 +48,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_size = 0; 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)", "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; @@ -314,14 +315,6 @@ static size_t stats_slash24s_txt( char * reply, size_t amount, uint32_t thresh ) return 0; } -/* - struct { - size_t size - size_t space - size_t count - } - */ - static unsigned long events_per_time( unsigned long long events, time_t t ) { return events / ( (unsigned int)t ? (unsigned int)t : 1 ); } @@ -402,42 +395,6 @@ static size_t stats_peers_mrtg( char * reply ) { ); } -static size_t stats_startstop_mrtg( char * reply ) -{ - size_t torrent_count = mutex_get_torrent_count(); - - return sprintf( reply, "%zd\n%zd\nopentracker handling %zd torrents\nopentracker", - (size_t)0, - (size_t)0, - torrent_count - ); -} - -static size_t stats_toraddrem_mrtg( char * reply ) -{ - size_t peer_count = 0, j; - int bucket; - - for( bucket=0; bucketsize; ++j ) - { - ot_peerlist *peer_list = ( ((ot_torrent*)(torrents_list->data))[j] ).peer_list; - peer_count += peer_list->peer_count; - } - mutex_bucket_unlock( bucket, 0 ); - if( !g_opentracker_running ) - return 0; - } - - return sprintf( reply, "%zd\n%zd\nopentracker handling %zd peers\nopentracker", - (size_t)0, - (size_t)0, - peer_count - ); -} - static size_t stats_torrents_mrtg( char * reply ) { size_t torrent_count = mutex_get_torrent_count(); @@ -479,13 +436,38 @@ static size_t stats_return_sync_mrtg( char * reply ) { } static size_t stats_return_everything( char * reply ) { + torrent_stats stats = {0,0,0}; + int i; char * r = reply; + + iterate_all_torrents( torrent_statter, (uintptr_t)&stats ); + + r += sprintf( r, "\n" ); r += stats_return_tracker_version( r ); r += sprintf( r, "\n" ); r += sprintf( r, "\n" ); r += sprintf( r, " %llu\n", (unsigned long long)(time( NULL ) - ot_start_time) ); - r += sprintf( r, " %zd\n", mutex_get_torrent_count() ); - /* r += sprintf( r, " %llu\n", ); */ - - r += sprintf( reply, "" ); + r += sprintf( r, " \n" ); + r += sprintf( r, " %zd\n", mutex_get_torrent_count() ); + r += sprintf( r, " %llu\n", stats.torrent_count ); + r += sprintf( r, " \n" ); + r += sprintf( r, " \n %llu\n \n", stats.peer_count ); + r += sprintf( r, " \n %llu\n \n", stats.seed_count ); + r += sprintf( r, " \n" ); + r += sprintf( r, " \n %llu\n %llu\n %llu\n \n", ot_overall_tcp_connections, ot_overall_tcp_successfulannounces, ot_overall_udp_successfulscrapes ); + r += sprintf( r, " \n %llu\n %llu\n %llu\n %llu\n \n", ot_overall_udp_connections, ot_overall_udp_connects, ot_overall_udp_successfulannounces, ot_overall_udp_successfulscrapes ); + r += sprintf( r, " \n %llu\n \n", ot_overall_sync_count ); + r += sprintf( r, " \n" ); + r += sprintf( r, " \n" ); + r += sprintf( r, " \n" ); + for( i=0; i%llu\n", i, ot_renewed[i] ); + r += sprintf( r, " \n" ); + r += sprintf( r, " \n" ); + for( i=0; i%llu\n", ot_failed_request_names[i], ot_failed_request_counts[i] ); + r += sprintf( r, " \n" ); + r += sprintf( r, " \n %llu\n \n", ot_overall_stall_count ); + r += sprintf( r, " \n" ); + r += sprintf( r, "" ); return r - reply; } @@ -512,10 +494,6 @@ size_t return_stats_for_tracker( char *reply, int mode, int format ) { return stats_udpconnections_mrtg( reply ); case TASK_STATS_TCP: return stats_tcpconnections_mrtg( reply ); - case TASK_STATS_TORADDREM: - return stats_toraddrem_mrtg( reply ); - case TASK_STATS_STARTSTOP: - return stats_startstop_mrtg( reply ); case TASK_STATS_FULLSCRAPE: return stats_fullscrapes_mrtg( reply ); case TASK_STATS_HTTPERRORS: @@ -548,6 +526,7 @@ static void stats_make( int *iovec_entries, struct iovec **iovector, ot_tasktype case TASK_STATS_PEERS: r += stats_peers_mrtg( r ); break; case TASK_STATS_SLASH24S: r += stats_slash24s_txt( r, 25, 16 ); break; case TASK_STATS_TOP10: r += stats_top10_txt( r ); break; + case TASK_STATS_EVERYTHING: r += stats_return_everything( r ); break; default: iovec_free(iovec_entries, iovector); return; -- cgit v1.2.3