summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordenis <>2007-12-08 18:47:16 +0000
committerdenis <>2007-12-08 18:47:16 +0000
commit19cc9ba882afa61df2aefbe8be062dc666142538 (patch)
tree9de8f6ac7d6e24ee322276039cc347c48be012b1
parentbee364a6f33694b4d58f29f0de5ad630d392a031 (diff)
add mrtgstyle stats for number of torrents
-rw-r--r--ot_http.c4
-rw-r--r--ot_mutex.h1
-rw-r--r--ot_stats.c21
3 files changed, 25 insertions, 1 deletions
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
236 else if( !byte_diff(data,4,"top5")) 236 else if( !byte_diff(data,4,"top5"))
237 mode = TASK_STATS_TOP5; 237 mode = TASK_STATS_TOP5;
238 else if( !byte_diff(data,4,"scrp")) 238 else if( !byte_diff(data,4,"scrp"))
239 mode = TASK_STATS_SCRAPE; 239 mode = TASK_STATS_SCRAPE;
240 else if( !byte_diff(data,4,"torr"))
241 mode = TASK_STATS_TORRENTS;
240 else if( !byte_diff(data,4,"fscr")) 242 else if( !byte_diff(data,4,"fscr"))
241 mode = TASK_STATS_FULLSCRAPE; 243 mode = TASK_STATS_FULLSCRAPE;
242 else if( !byte_diff(data,4,"tcp4")) 244 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 {
23 TASK_STATS_FULLSCRAPE = 0x0006, 23 TASK_STATS_FULLSCRAPE = 0x0006,
24 TASK_STATS_TPB = 0x0007, 24 TASK_STATS_TPB = 0x0007,
25 TASK_STATS_HTTPERRORS = 0x0008, 25 TASK_STATS_HTTPERRORS = 0x0008,
26 TASK_STATS_TORRENTS = 0x0009,
26 27
27 TASK_STATS_SLASH24S = 0x0100, 28 TASK_STATS_SLASH24S = 0x0100,
28 29
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 ) {
264 ); 264 );
265} 265}
266 266
267static size_t stats_torrents_mrtg( char * reply )
268{
269 size_t torrent_count = 0;
270 int bucket;
271
272 for( bucket=0; bucket<OT_BUCKET_COUNT; ++bucket )
273 {
274 ot_vector *torrents_list = mutex_bucket_lock( bucket );
275 torrent_count += torrents_list->size;
276 mutex_bucket_unlock( bucket );
277 }
278
279 return sprintf( reply, "%zd\n%zd\nopentracker serving %zd torrents\nopentracker",
280 torrent_count,
281 (size_t)0,
282 torrent_count
283 );
284}
285
267static size_t stats_httperrors_txt ( char * reply ) { 286static size_t stats_httperrors_txt ( char * reply ) {
268 return sprintf( reply, "302 RED %llu\n400 ... %llu\n400 PAR %llu\n400 COM %llu\n403 IP %llu\n404 INV %llu\n500 SRV %llu\n", 287 return sprintf( reply, "302 RED %llu\n400 ... %llu\n400 PAR %llu\n400 COM %llu\n403 IP %llu\n404 INV %llu\n500 SRV %llu\n",
269 ot_failed_request_counts[0], ot_failed_request_counts[1], ot_failed_request_counts[2], 288 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 ) {
284 return stats_tcpconnections_mrtg( reply ); 303 return stats_tcpconnections_mrtg( reply );
285 case TASK_STATS_PEERS: 304 case TASK_STATS_PEERS:
286 return stats_peers_mrtg( reply ); 305 return stats_peers_mrtg( reply );
306 case TASK_STATS_TORRENTS:
307 return stats_torrents_mrtg( reply );
287 case TASK_STATS_SLASH24S: 308 case TASK_STATS_SLASH24S:
288 return stats_slash24s_txt( reply, 25, 16 ); 309 return stats_slash24s_txt( reply, 25, 16 );
289 case TASK_STATS_TOP5: 310 case TASK_STATS_TOP5: