summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ot_http.c4
-rw-r--r--ot_mutex.h2
-rw-r--r--ot_stats.c46
3 files changed, 52 insertions, 0 deletions
diff --git a/ot_http.c b/ot_http.c
index faf1aae..a377e84 100644
--- a/ot_http.c
+++ b/ot_http.c
@@ -251,6 +251,10 @@ static ssize_t http_handle_stats( const int64 client_socket, char *data, char *d
251 mode = TASK_STATS_TPB; 251 mode = TASK_STATS_TPB;
252 else if( !byte_diff(data,4,"herr")) 252 else if( !byte_diff(data,4,"herr"))
253 mode = TASK_STATS_HTTPERRORS; 253 mode = TASK_STATS_HTTPERRORS;
254 else if( !byte_diff(data,9,"startstop"))
255 mode = TASK_STATS_STARTSTOP;
256 else if( !byte_diff(data,10,"toraddrem"))
257 mode = TASK_STATS_TORADDREM;
254 else 258 else
255 HTTPERROR_400_PARAM; 259 HTTPERROR_400_PARAM;
256 break; 260 break;
diff --git a/ot_mutex.h b/ot_mutex.h
index 01ceefd..c098343 100644
--- a/ot_mutex.h
+++ b/ot_mutex.h
@@ -24,6 +24,8 @@ typedef enum {
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 TASK_STATS_TORRENTS = 0x0009,
27 TASK_STATS_STARTSTOP = 0x000a,
28 TASK_STATS_TORADDREM = 0x000b,
27 29
28 TASK_STATS_SLASH24S = 0x0100, 30 TASK_STATS_SLASH24S = 0x0100,
29 31
diff --git a/ot_stats.c b/ot_stats.c
index 77910f5..d2b02fa 100644
--- a/ot_stats.c
+++ b/ot_stats.c
@@ -264,6 +264,48 @@ static size_t stats_peers_mrtg( char * reply ) {
264 ); 264 );
265} 265}
266 266
267static size_t stats_startstop_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 handling %zd torrents\nopentracker",
280 (size_t)0,
281 (size_t)0,
282 torrent_count
283 );
284}
285
286static size_t stats_toraddrem_mrtg( char * reply )
287{
288 size_t peer_count = 0, j;
289 int bucket;
290
291 for( bucket=0; bucket<OT_BUCKET_COUNT; ++bucket )
292 {
293 ot_vector *torrents_list = mutex_bucket_lock( bucket );
294 for( j=0; j<torrents_list->size; ++j )
295 {
296 ot_peerlist *peer_list = ( ((ot_torrent*)(torrents_list->data))[j] ).peer_list;
297 peer_count += peer_list->peer_count;
298 }
299 mutex_bucket_unlock( bucket );
300 }
301
302 return sprintf( reply, "%zd\n%zd\nopentracker handling %zd peers\nopentracker",
303 (size_t)0,
304 (size_t)0,
305 peer_count
306 );
307}
308
267static size_t stats_torrents_mrtg( char * reply ) 309static size_t stats_torrents_mrtg( char * reply )
268{ 310{
269 size_t torrent_count = 0; 311 size_t torrent_count = 0;
@@ -305,6 +347,10 @@ size_t return_stats_for_tracker( char *reply, int mode, int format ) {
305 return stats_peers_mrtg( reply ); 347 return stats_peers_mrtg( reply );
306 case TASK_STATS_TORRENTS: 348 case TASK_STATS_TORRENTS:
307 return stats_torrents_mrtg( reply ); 349 return stats_torrents_mrtg( reply );
350 case TASK_STATS_TORADDREM:
351 return stats_toraddrem_mrtg( reply );
352 case TASK_STATS_STARTSTOP:
353 return stats_startstop_mrtg( reply );
308 case TASK_STATS_SLASH24S: 354 case TASK_STATS_SLASH24S:
309 return stats_slash24s_txt( reply, 25, 16 ); 355 return stats_slash24s_txt( reply, 25, 16 );
310 case TASK_STATS_TOP5: 356 case TASK_STATS_TOP5: