diff options
| author | denis <> | 2007-03-15 23:14:14 +0000 |
|---|---|---|
| committer | denis <> | 2007-03-15 23:14:14 +0000 |
| commit | 5bb381e20a94f2cf0885a5ed4c91b1b5d9c76574 (patch) | |
| tree | 6e6998b0d48bdb0554864ec73ce0c13760d51e62 | |
| parent | 50fe661aa782481bf07ffff680ef6f585cc77fa1 (diff) | |
new modes for udp4 and tcp4 stats
| -rw-r--r-- | opentracker.c | 36 | ||||
| -rw-r--r-- | trackerlogic.h | 2 |
2 files changed, 31 insertions, 7 deletions
diff --git a/opentracker.c b/opentracker.c index dcbecaf..29af881 100644 --- a/opentracker.c +++ b/opentracker.c | |||
| @@ -246,18 +246,42 @@ static void httpresponse( const int64 s, char *data ) { | |||
| 246 | mode = STATS_TOP5; | 246 | mode = STATS_TOP5; |
| 247 | else if( !byte_diff(data,4,"dmem")) | 247 | else if( !byte_diff(data,4,"dmem")) |
| 248 | mode = STATS_DMEM; | 248 | mode = STATS_DMEM; |
| 249 | else if( !byte_diff(data,4,"tcp4")) | ||
| 250 | mode = STATS_TCP; | ||
| 251 | else if( !byte_diff(data,4,"udp4")) | ||
| 252 | mode = STATS_UDP; | ||
| 249 | else | 253 | else |
| 250 | HTTPERROR_400_PARAM; | 254 | HTTPERROR_400_PARAM; |
| 251 | } | 255 | } |
| 252 | } | 256 | } |
| 253 | 257 | ||
| 254 | if( mode == STATS_DMEM ) { | 258 | switch( mode) |
| 255 | if( !( reply_size = return_memstat_for_tracker( &reply ) ) ) HTTPERROR_500; | 259 | { |
| 256 | return sendmallocdata( s, reply, reply_size ); | 260 | case STATS_DMEM: |
| 257 | } | 261 | if( !( reply_size = return_memstat_for_tracker( &reply ) ) ) HTTPERROR_500; |
| 262 | return sendmallocdata( s, reply, reply_size ); | ||
| 263 | |||
| 264 | case STATS_UDP: | ||
| 265 | t = time( NULL ) - ot_start_time; | ||
| 266 | reply_size = sprintf( static_outbuf + SUCCESS_HTTP_HEADER_LENGTH, | ||
| 267 | "%i\n%i\n%i seconds (%i hours)\nopentracker udp stats.", | ||
| 268 | ot_overall_connections, ot_overall_udp_successfulannounces, (int)t, (int)(t / 3600) ); | ||
| 269 | break; | ||
| 258 | 270 | ||
| 259 | /* Enough for http header + whole scrape string */ | 271 | case STATS_TCP: |
| 260 | if( !( reply_size = return_stats_for_tracker( SUCCESS_HTTP_HEADER_LENGTH + static_outbuf, mode ) ) ) HTTPERROR_500; | 272 | t = time( NULL ) - ot_start_time; |
| 273 | reply_size = sprintf( static_outbuf + SUCCESS_HTTP_HEADER_LENGTH, | ||
| 274 | "%i\n%i\n%i seconds (%i hours)\nopentracker tcp stats.", | ||
| 275 | ot_overall_connections, ot_overall_tcp_successfulannounces, (int)t, (int)(t / 3600) ); | ||
| 276 | break; | ||
| 277 | |||
| 278 | default: | ||
| 279 | case STATS_MRTG: | ||
| 280 | /* Enough for http header + whole scrape string */ | ||
| 281 | if( !( reply_size = return_stats_for_tracker( SUCCESS_HTTP_HEADER_LENGTH + static_outbuf, mode ) ) ) HTTPERROR_500; | ||
| 282 | break; | ||
| 283 | } | ||
| 284 | |||
| 261 | break; | 285 | break; |
| 262 | case 6: /* scrape ? */ | 286 | case 6: /* scrape ? */ |
| 263 | if( byte_diff( data, 6, "scrape") ) HTTPERROR_404; | 287 | if( byte_diff( data, 6, "scrape") ) HTTPERROR_404; |
diff --git a/trackerlogic.h b/trackerlogic.h index 360dacb..59d256e 100644 --- a/trackerlogic.h +++ b/trackerlogic.h | |||
| @@ -91,7 +91,7 @@ extern int g_closedtracker; | |||
| 91 | extern int g_check_blacklist; | 91 | extern int g_check_blacklist; |
| 92 | #endif | 92 | #endif |
| 93 | 93 | ||
| 94 | enum { STATS_MRTG, STATS_TOP5, STATS_DMEM }; | 94 | enum { STATS_MRTG, STATS_TOP5, STATS_DMEM, STATS_TCP, STATS_UDP }; |
| 95 | 95 | ||
| 96 | ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer ); | 96 | ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer ); |
| 97 | size_t return_peers_for_torrent( ot_torrent *torrent, size_t amount, char *reply, int is_tcp ); | 97 | size_t return_peers_for_torrent( ot_torrent *torrent, size_t amount, char *reply, int is_tcp ); |
