summaryrefslogtreecommitdiff
path: root/ot_http.c
diff options
context:
space:
mode:
authorerdgeist <>2008-10-24 00:03:18 +0000
committererdgeist <>2008-10-24 00:03:18 +0000
commit80fd4dc738883519a7dc278259a0e56697b077b8 (patch)
treed4647961963bb5caf88a98e5e5f2108464a19b9e /ot_http.c
parente89a8aaf58dc18c51d9d249c89e0abb171b033b9 (diff)
Tidy up stats task.
Diffstat (limited to 'ot_http.c')
-rw-r--r--ot_http.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/ot_http.c b/ot_http.c
index 5b84b7f..362b2ab 100644
--- a/ot_http.c
+++ b/ot_http.c
@@ -214,6 +214,12 @@ static ssize_t http_handle_sync( const int64 client_socket, char *data ) {
214static ssize_t http_handle_stats( const int64 client_socket, char *data, char *d, size_t l ) { 214static ssize_t http_handle_stats( const int64 client_socket, char *data, char *d, size_t l ) {
215 char *c = data; 215 char *c = data;
216 int mode = TASK_STATS_PEERS, scanon = 1, format = 0; 216 int mode = TASK_STATS_PEERS, scanon = 1, format = 0;
217#ifdef WANT_RESTRICT_STATS
218 struct http_data *h = io_getcookie( client_socket );
219
220 if( !accesslist_isblessed( h->ip, OT_PERMISSION_MAY_STAT ) )
221 HTTPERROR_403_IP;
222#endif
217 223
218 while( scanon ) { 224 while( scanon ) {
219 switch( scan_urlencoded_query( &c, data = c, SCAN_SEARCHPATH_PARAM ) ) { 225 switch( scan_urlencoded_query( &c, data = c, SCAN_SEARCHPATH_PARAM ) ) {
@@ -230,8 +236,8 @@ static ssize_t http_handle_stats( const int64 client_socket, char *data, char *d
230 mode = TASK_STATS_PEERS; 236 mode = TASK_STATS_PEERS;
231 else if( !byte_diff(data,4,"conn")) 237 else if( !byte_diff(data,4,"conn"))
232 mode = TASK_STATS_CONNS; 238 mode = TASK_STATS_CONNS;
233 else if( !byte_diff(data,4,"top5")) 239 else if( !byte_diff(data,4,"top10"))
234 mode = TASK_STATS_TOP5; 240 mode = TASK_STATS_TOP10;
235 else if( !byte_diff(data,4,"scrp")) 241 else if( !byte_diff(data,4,"scrp"))
236 mode = TASK_STATS_SCRAPE; 242 mode = TASK_STATS_SCRAPE;
237 else if( !byte_diff(data,4,"torr")) 243 else if( !byte_diff(data,4,"torr"))
@@ -256,6 +262,10 @@ static ssize_t http_handle_stats( const int64 client_socket, char *data, char *d
256 mode = TASK_STATS_VERSION; 262 mode = TASK_STATS_VERSION;
257 else if( !byte_diff(data,4,"busy")) 263 else if( !byte_diff(data,4,"busy"))
258 mode = TASK_STATS_BUSY_NETWORKS; 264 mode = TASK_STATS_BUSY_NETWORKS;
265 else if( !byte_diff(data,4,"dmem"))
266 mode = TASK_STATS_MEMORY;
267 else if( !byte_diff(data,4,"vdeb"))
268 mode = TASK_STATS_VECTOR_DEBUG;
259 else 269 else
260 HTTPERROR_400_PARAM; 270 HTTPERROR_400_PARAM;
261 break; 271 break;
@@ -304,7 +314,17 @@ static ssize_t http_handle_stats( const int64 client_socket, char *data, char *d
304#endif 314#endif
305 315
306 /* default format for now */ 316 /* default format for now */
317 if( ( mode & TASK_CLASS_MASK ) == TASK_STATS ) {
318 tai6464 t;
319 /* Complex stats also include expensive memory debugging tools */
320 taia_uint( &t, 0 ); io_timeout( client_socket, t );
321 stats_deliver( client_socket, mode );
322 return -2;
323 }
324
325 /* Simple stats can be answerred immediately */
307 if( !( l = return_stats_for_tracker( static_outbuf + SUCCESS_HTTP_HEADER_LENGTH, mode, 0 ) ) ) HTTPERROR_500; 326 if( !( l = return_stats_for_tracker( static_outbuf + SUCCESS_HTTP_HEADER_LENGTH, mode, 0 ) ) ) HTTPERROR_500;
327
308 return l; 328 return l;
309} 329}
310 330