diff options
Diffstat (limited to 'ot_stats.c')
| -rw-r--r-- | ot_stats.c | 46 |
1 files changed, 46 insertions, 0 deletions
| @@ -264,6 +264,48 @@ static size_t stats_peers_mrtg( char * reply ) { | |||
| 264 | ); | 264 | ); |
| 265 | } | 265 | } |
| 266 | 266 | ||
| 267 | static 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 | |||
| 286 | static 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 | |||
| 267 | static size_t stats_torrents_mrtg( char * reply ) | 309 | static 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: |
