From c7ed890222939ff9d9a3b575eb83f216ccfebe9e Mon Sep 17 00:00:00 2001 From: erdgeist <> Date: Tue, 17 Mar 2009 23:57:20 +0000 Subject: Fix white spaces Introduce loading tracker states with -l Alter tracker state to a human readable form --- ot_stats.c | 60 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 30 insertions(+), 30 deletions(-) (limited to 'ot_stats.c') diff --git a/ot_stats.c b/ot_stats.c index e1bce7c..6116c41 100644 --- a/ot_stats.c +++ b/ot_stats.c @@ -1,6 +1,6 @@ /* This software was written by Dirk Engling It is considered beerware. Prost. Skol. Cheers or whatever. - + $id$ */ /* System */ @@ -84,10 +84,10 @@ static int stat_increase_network_count( stats_network_node **node, int depth, ui return -1; memset( *node, 0, sizeof( stats_network_node ) ); } - + if( depth < STATS_NETWORK_NODE_MAXDEPTH ) return stat_increase_network_count( &(*node)->children[ foo ], depth+1, ip ); - + (*node)->counters[ foo ]++; return 0; } @@ -122,9 +122,9 @@ static int stats_shift_down_network_count( stats_network_node **node, int depth, static void stats_get_highscore_networks( stats_network_node *node, int depth, ot_ip6 node_value, int *scores, ot_ip6 *networks, int network_count ) { uint8_t *_node_value = (uint8_t*)node_value; int i; - + if( !node ) return; - + if( depth < STATS_NETWORK_NODE_MAXDEPTH ) { for( i=0; ichildren[i] ) { @@ -139,7 +139,7 @@ static void stats_get_highscore_networks( stats_network_node *node, int depth, o _node_value[depth] = i; while( (jcounters[i]>scores[j] ) ) ++j; --j; - + memcpy( scores, scores + 1, j * sizeof( *scores ) ); memcpy( networks, networks + 1, j * sizeof( *networks ) ); scores[ j ] = node->counters[ i ]; @@ -158,7 +158,7 @@ static size_t stats_return_busy_networks( char * reply ) { memset( networks, 0, sizeof( *networks ) * 256 ); stats_get_highscore_networks( stats_network_counters_root, 0, node_value, scores, networks, 256 ); - + for( i=255; i>=0; --i) { r += sprintf( r, "%08i: ", scores[i] ); r += fmt_ip6c( r, networks[i] ); @@ -195,10 +195,10 @@ size_t stats_top10_txt( char * reply ) { ot_record top10s[10], top10c[10]; char *r = reply, hex_out[42]; int idx, bucket; - + byte_zero( top10s, sizeof( top10s ) ); byte_zero( top10c, sizeof( top10c ) ); - + for( bucket=0; bucketsize; ++j ) { @@ -220,7 +220,7 @@ size_t stats_top10_txt( char * reply ) { if( !g_opentracker_running ) return 0; } - + r += sprintf( r, "Top 10 torrents by peers:\n" ); for( idx=0; idx<10; ++idx ) if( top10c[idx].torrent ) @@ -229,7 +229,7 @@ size_t stats_top10_txt( char * reply ) { for( idx=0; idx<10; ++idx ) if( top10s[idx].torrent ) r += sprintf( r, "\t%zd\t%s\n", top10s[idx].val, to_hex( hex_out, top10s[idx].torrent->hash) ); - + return r - reply; } @@ -237,23 +237,23 @@ size_t stats_top10_txt( char * reply ) { malloc blocks */ static size_t stats_slash24s_txt( char * reply, size_t amount, uint32_t thresh ) { - + #define NUM_TOPBITS 12 #define NUM_LOWBITS (24-NUM_TOPBITS) #define NUM_BUFS (1<= thresh ) { uint32_t ip = slash24s[ 2*i +1 ]; r += sprintf( r, "% 10ld %d.%d.%d.0/24\n", (long)slash24s[ 2*i ], (int)(ip >> 16), (int)(255 & ( ip >> 8 )), (int)(ip & 255) ); } - + return r - reply; - + for( i=0; i < NUM_BUFS; ++i ) free( counts[i] ); - + return 0; } @@ -395,9 +395,9 @@ static size_t stats_fullscrapes_mrtg( char * reply ) { static size_t stats_peers_mrtg( char * reply ) { torrent_stats stats = {0,0,0}; - + 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, @@ -408,7 +408,7 @@ static size_t stats_peers_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, @@ -426,7 +426,7 @@ static size_t stats_httperrors_txt ( char * reply ) { static size_t stats_return_renew_bucket( char * reply ) { char *r = reply; int i; - + for( i=0; i