Browse Source

Tidy up stats task.

dynamic-accesslists
erdgeist 16 years ago
parent
commit
80fd4dc738
  1. 24
      ot_http.c
  2. 35
      ot_mutex.h

24
ot_http.c

@ -214,6 +214,12 @@ static ssize_t http_handle_sync( const int64 client_socket, char *data ) { @@ -214,6 +214,12 @@ static ssize_t http_handle_sync( const int64 client_socket, char *data ) {
static ssize_t http_handle_stats( const int64 client_socket, char *data, char *d, size_t l ) {
char *c = data;
int mode = TASK_STATS_PEERS, scanon = 1, format = 0;
#ifdef WANT_RESTRICT_STATS
struct http_data *h = io_getcookie( client_socket );
if( !accesslist_isblessed( h->ip, OT_PERMISSION_MAY_STAT ) )
HTTPERROR_403_IP;
#endif
while( scanon ) {
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,8 +236,8 @@ static ssize_t http_handle_stats( const int64 client_socket, char *data, char *d
mode = TASK_STATS_PEERS;
else if( !byte_diff(data,4,"conn"))
mode = TASK_STATS_CONNS;
else if( !byte_diff(data,4,"top5"))
mode = TASK_STATS_TOP5;
else if( !byte_diff(data,4,"top10"))
mode = TASK_STATS_TOP10;
else if( !byte_diff(data,4,"scrp"))
mode = TASK_STATS_SCRAPE;
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,6 +262,10 @@ static ssize_t http_handle_stats( const int64 client_socket, char *data, char *d
mode = TASK_STATS_VERSION;
else if( !byte_diff(data,4,"busy"))
mode = TASK_STATS_BUSY_NETWORKS;
else if( !byte_diff(data,4,"dmem"))
mode = TASK_STATS_MEMORY;
else if( !byte_diff(data,4,"vdeb"))
mode = TASK_STATS_VECTOR_DEBUG;
else
HTTPERROR_400_PARAM;
break;
@ -304,7 +314,17 @@ static ssize_t http_handle_stats( const int64 client_socket, char *data, char *d @@ -304,7 +314,17 @@ static ssize_t http_handle_stats( const int64 client_socket, char *data, char *d
#endif
/* default format for now */
if( ( mode & TASK_CLASS_MASK ) == TASK_STATS ) {
tai6464 t;
/* Complex stats also include expensive memory debugging tools */
taia_uint( &t, 0 ); io_timeout( client_socket, t );
stats_deliver( client_socket, mode );
return -2;
}
/* Simple stats can be answerred immediately */
if( !( l = return_stats_for_tracker( static_outbuf + SUCCESS_HTTP_HEADER_LENGTH, mode, 0 ) ) ) HTTPERROR_500;
return l;
}

35
ot_mutex.h

@ -16,22 +16,25 @@ void mutex_bucket_unlock( int bucket ); @@ -16,22 +16,25 @@ void mutex_bucket_unlock( int bucket );
void mutex_bucket_unlock_by_hash( ot_hash *hash );
typedef enum {
TASK_STATS_CONNS = 0x0000,
TASK_STATS_PEERS = 0x0001,
TASK_STATS_TOP5 = 0x0002,
TASK_STATS_TCP = 0x0003,
TASK_STATS_UDP = 0x0004,
TASK_STATS_SCRAPE = 0x0005,
TASK_STATS_FULLSCRAPE = 0x0006,
TASK_STATS_TPB = 0x0007,
TASK_STATS_HTTPERRORS = 0x0008,
TASK_STATS_TORRENTS = 0x0009,
TASK_STATS_STARTSTOP = 0x000a,
TASK_STATS_TORADDREM = 0x000b,
TASK_STATS_VERSION = 0x000c,
TASK_STATS_BUSY_NETWORKS = 0x000d,
TASK_STATS_SLASH24S = 0x0100,
TASK_STATS_CONNS = 0x0001,
TASK_STATS_TCP = 0x0002,
TASK_STATS_UDP = 0x0003,
TASK_STATS_SCRAPE = 0x0004,
TASK_STATS_FULLSCRAPE = 0x0005,
TASK_STATS_TPB = 0x0006,
TASK_STATS_HTTPERRORS = 0x0007,
TASK_STATS_STARTSTOP = 0x0008,
TASK_STATS_TORADDREM = 0x0009,
TASK_STATS_VERSION = 0x000a,
TASK_STATS_BUSY_NETWORKS = 0x000b,
TASK_STATS_VECTOR_DEBUG = 0x000c,
TASK_STATS = 0x0100, /* Mask */
TASK_STATS_TORRENTS = 0x0101,
TASK_STATS_PEERS = 0x0102,
TASK_STATS_SLASH24S = 0x0103,
TASK_STATS_TOP10 = 0x0104,
TASK_STATS_MEMORY = 0x0105,
TASK_FULLSCRAPE = 0x0200, /* Default mode */
TASK_FULLSCRAPE_TPB_BINARY = 0x0201,

Loading…
Cancel
Save