summaryrefslogtreecommitdiff
path: root/opentracker.c
diff options
context:
space:
mode:
Diffstat (limited to 'opentracker.c')
-rw-r--r--opentracker.c36
1 files changed, 30 insertions, 6 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;