From 19cc9ba882afa61df2aefbe8be062dc666142538 Mon Sep 17 00:00:00 2001 From: denis <> Date: Sat, 8 Dec 2007 18:47:16 +0000 Subject: add mrtgstyle stats for number of torrents --- ot_http.c | 4 +++- ot_mutex.h | 1 + ot_stats.c | 21 +++++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/ot_http.c b/ot_http.c index cb517bb..faf1aae 100644 --- a/ot_http.c +++ b/ot_http.c @@ -236,7 +236,9 @@ static ssize_t http_handle_stats( const int64 client_socket, char *data, char *d else if( !byte_diff(data,4,"top5")) mode = TASK_STATS_TOP5; else if( !byte_diff(data,4,"scrp")) - mode = TASK_STATS_SCRAPE; + mode = TASK_STATS_SCRAPE; + else if( !byte_diff(data,4,"torr")) + mode = TASK_STATS_TORRENTS; else if( !byte_diff(data,4,"fscr")) mode = TASK_STATS_FULLSCRAPE; else if( !byte_diff(data,4,"tcp4")) diff --git a/ot_mutex.h b/ot_mutex.h index 7f10c20..01ceefd 100644 --- a/ot_mutex.h +++ b/ot_mutex.h @@ -23,6 +23,7 @@ typedef enum { TASK_STATS_FULLSCRAPE = 0x0006, TASK_STATS_TPB = 0x0007, TASK_STATS_HTTPERRORS = 0x0008, + TASK_STATS_TORRENTS = 0x0009, TASK_STATS_SLASH24S = 0x0100, diff --git a/ot_stats.c b/ot_stats.c index 8adb2bf..77910f5 100644 --- a/ot_stats.c +++ b/ot_stats.c @@ -264,6 +264,25 @@ static size_t stats_peers_mrtg( char * reply ) { ); } +static size_t stats_torrents_mrtg( char * reply ) +{ + size_t torrent_count = 0; + int bucket; + + for( bucket=0; bucketsize; + mutex_bucket_unlock( bucket ); + } + + 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], @@ -284,6 +303,8 @@ size_t return_stats_for_tracker( char *reply, int mode, int format ) { return stats_tcpconnections_mrtg( reply ); case TASK_STATS_PEERS: return stats_peers_mrtg( reply ); + case TASK_STATS_TORRENTS: + return stats_torrents_mrtg( reply ); case TASK_STATS_SLASH24S: return stats_slash24s_txt( reply, 25, 16 ); case TASK_STATS_TOP5: -- cgit v1.2.3