diff options
| author | erdgeist <> | 2009-03-04 15:33:44 +0000 |
|---|---|---|
| committer | erdgeist <> | 2009-03-04 15:33:44 +0000 |
| commit | 255ac58971d6ceef844b53ec32149b537285596a (patch) | |
| tree | f77d78c852d5356d57b60e4f405a0a543550fea5 | |
| parent | 9297967f8523f1ac22bbac1823529b970a07cf56 (diff) | |
Add a everything stats page. So you won't have to remember what all those switches were.
Remove the prepared Add/Remove-Torrent count until we implement it.
Remove the start/stop count until we implement it.
| -rw-r--r-- | ot_http.c | 2 | ||||
| -rw-r--r-- | ot_mutex.h | 11 | ||||
| -rw-r--r-- | ot_stats.c | 83 |
3 files changed, 37 insertions, 59 deletions
| @@ -165,7 +165,7 @@ static const ot_keywords keywords_mode[] = | |||
| 165 | { "busy", TASK_STATS_BUSY_NETWORKS }, { "torr", TASK_STATS_TORRENTS }, { "fscr", TASK_STATS_FULLSCRAPE }, | 165 | { "busy", TASK_STATS_BUSY_NETWORKS }, { "torr", TASK_STATS_TORRENTS }, { "fscr", TASK_STATS_FULLSCRAPE }, |
| 166 | { "s24s", TASK_STATS_SLASH24S }, { "tpbs", TASK_STATS_TPB }, { "herr", TASK_STATS_HTTPERRORS }, | 166 | { "s24s", TASK_STATS_SLASH24S }, { "tpbs", TASK_STATS_TPB }, { "herr", TASK_STATS_HTTPERRORS }, |
| 167 | { "top10", TASK_STATS_TOP10 }, { "renew", TASK_STATS_RENEW }, { "syncs", TASK_STATS_SYNCS }, { "version", TASK_STATS_VERSION }, | 167 | { "top10", TASK_STATS_TOP10 }, { "renew", TASK_STATS_RENEW }, { "syncs", TASK_STATS_SYNCS }, { "version", TASK_STATS_VERSION }, |
| 168 | { "startstop", TASK_STATS_STARTSTOP }, { "toraddrem", TASK_STATS_TORADDREM }, { NULL, -3 } }; | 168 | { "everything", TASK_STATS_EVERYTHING }, { NULL, -3 } }; |
| 169 | static const ot_keywords keywords_format[] = | 169 | static const ot_keywords keywords_format[] = |
| 170 | { { "bin", TASK_FULLSCRAPE_TPB_BINARY }, { "ben", TASK_FULLSCRAPE }, { "url", TASK_FULLSCRAPE_TPB_URLENCODED }, | 170 | { { "bin", TASK_FULLSCRAPE_TPB_BINARY }, { "ben", TASK_FULLSCRAPE }, { "url", TASK_FULLSCRAPE_TPB_URLENCODED }, |
| 171 | { "txt", TASK_FULLSCRAPE_TPB_ASCII }, { NULL, -3 } }; | 171 | { "txt", TASK_FULLSCRAPE_TPB_ASCII }, { NULL, -3 } }; |
| @@ -27,18 +27,17 @@ typedef enum { | |||
| 27 | TASK_STATS_FULLSCRAPE = 0x0005, | 27 | TASK_STATS_FULLSCRAPE = 0x0005, |
| 28 | TASK_STATS_TPB = 0x0006, | 28 | TASK_STATS_TPB = 0x0006, |
| 29 | TASK_STATS_HTTPERRORS = 0x0007, | 29 | TASK_STATS_HTTPERRORS = 0x0007, |
| 30 | TASK_STATS_STARTSTOP = 0x0008, | 30 | TASK_STATS_VERSION = 0x0008, |
| 31 | TASK_STATS_TORADDREM = 0x0009, | 31 | TASK_STATS_BUSY_NETWORKS = 0x0009, |
| 32 | TASK_STATS_VERSION = 0x000a, | 32 | TASK_STATS_RENEW = 0x000a, |
| 33 | TASK_STATS_BUSY_NETWORKS = 0x000b, | 33 | TASK_STATS_SYNCS = 0x000b, |
| 34 | TASK_STATS_RENEW = 0x000c, | ||
| 35 | TASK_STATS_SYNCS = 0x000d, | ||
| 36 | 34 | ||
| 37 | TASK_STATS = 0x0100, /* Mask */ | 35 | TASK_STATS = 0x0100, /* Mask */ |
| 38 | TASK_STATS_TORRENTS = 0x0101, | 36 | TASK_STATS_TORRENTS = 0x0101, |
| 39 | TASK_STATS_PEERS = 0x0102, | 37 | TASK_STATS_PEERS = 0x0102, |
| 40 | TASK_STATS_SLASH24S = 0x0103, | 38 | TASK_STATS_SLASH24S = 0x0103, |
| 41 | TASK_STATS_TOP10 = 0x0104, | 39 | TASK_STATS_TOP10 = 0x0104, |
| 40 | TASK_STATS_EVERYTHING = 0x0105, | ||
| 42 | 41 | ||
| 43 | TASK_FULLSCRAPE = 0x0200, /* Default mode */ | 42 | TASK_FULLSCRAPE = 0x0200, /* Default mode */ |
| 44 | TASK_FULLSCRAPE_TPB_BINARY = 0x0201, | 43 | TASK_FULLSCRAPE_TPB_BINARY = 0x0201, |
| @@ -48,6 +48,7 @@ static unsigned long long ot_full_scrape_count = 0; | |||
| 48 | static unsigned long long ot_full_scrape_request_count = 0; | 48 | static unsigned long long ot_full_scrape_request_count = 0; |
| 49 | static unsigned long long ot_full_scrape_size = 0; | 49 | static unsigned long long ot_full_scrape_size = 0; |
| 50 | static unsigned long long ot_failed_request_counts[CODE_HTTPERROR_COUNT]; | 50 | static unsigned long long ot_failed_request_counts[CODE_HTTPERROR_COUNT]; |
| 51 | static char * ot_failed_request_names[] = { "302 Redirect", "400 Parse Error", "400 Invalid Parameter", "400 Invalid Parameter (compact=0)", "403 Access Denied", "404 Not found", "500 Internal Server Error" }; | ||
| 51 | static unsigned long long ot_renewed[OT_PEER_TIMEOUT]; | 52 | static unsigned long long ot_renewed[OT_PEER_TIMEOUT]; |
| 52 | static unsigned long long ot_overall_sync_count; | 53 | static unsigned long long ot_overall_sync_count; |
| 53 | static unsigned long long ot_overall_stall_count; | 54 | static unsigned long long ot_overall_stall_count; |
| @@ -314,14 +315,6 @@ static size_t stats_slash24s_txt( char * reply, size_t amount, uint32_t thresh ) | |||
| 314 | return 0; | 315 | return 0; |
| 315 | } | 316 | } |
| 316 | 317 | ||
| 317 | /* | ||
| 318 | struct { | ||
| 319 | size_t size | ||
| 320 | size_t space | ||
| 321 | size_t count | ||
| 322 | } | ||
| 323 | */ | ||
| 324 | |||
| 325 | static unsigned long events_per_time( unsigned long long events, time_t t ) { | 318 | static unsigned long events_per_time( unsigned long long events, time_t t ) { |
| 326 | return events / ( (unsigned int)t ? (unsigned int)t : 1 ); | 319 | return events / ( (unsigned int)t ? (unsigned int)t : 1 ); |
| 327 | } | 320 | } |
| @@ -402,42 +395,6 @@ static size_t stats_peers_mrtg( char * reply ) { | |||
| 402 | ); | 395 | ); |
| 403 | } | 396 | } |
| 404 | 397 | ||
| 405 | static size_t stats_startstop_mrtg( char * reply ) | ||
| 406 | { | ||
| 407 | size_t torrent_count = mutex_get_torrent_count(); | ||
| 408 | |||
| 409 | return sprintf( reply, "%zd\n%zd\nopentracker handling %zd torrents\nopentracker", | ||
| 410 | (size_t)0, | ||
| 411 | (size_t)0, | ||
| 412 | torrent_count | ||
| 413 | ); | ||
| 414 | } | ||
| 415 | |||
| 416 | static size_t stats_toraddrem_mrtg( char * reply ) | ||
| 417 | { | ||
| 418 | size_t peer_count = 0, j; | ||
| 419 | int bucket; | ||
| 420 | |||
| 421 | for( bucket=0; bucket<OT_BUCKET_COUNT; ++bucket ) | ||
| 422 | { | ||
| 423 | ot_vector *torrents_list = mutex_bucket_lock( bucket ); | ||
| 424 | for( j=0; j<torrents_list->size; ++j ) | ||
| 425 | { | ||
| 426 | ot_peerlist *peer_list = ( ((ot_torrent*)(torrents_list->data))[j] ).peer_list; | ||
| 427 | peer_count += peer_list->peer_count; | ||
| 428 | } | ||
| 429 | mutex_bucket_unlock( bucket, 0 ); | ||
| 430 | if( !g_opentracker_running ) | ||
| 431 | return 0; | ||
| 432 | } | ||
| 433 | |||
| 434 | return sprintf( reply, "%zd\n%zd\nopentracker handling %zd peers\nopentracker", | ||
| 435 | (size_t)0, | ||
| 436 | (size_t)0, | ||
| 437 | peer_count | ||
| 438 | ); | ||
| 439 | } | ||
| 440 | |||
| 441 | static size_t stats_torrents_mrtg( char * reply ) | 398 | static size_t stats_torrents_mrtg( char * reply ) |
| 442 | { | 399 | { |
| 443 | size_t torrent_count = mutex_get_torrent_count(); | 400 | size_t torrent_count = mutex_get_torrent_count(); |
| @@ -479,13 +436,38 @@ static size_t stats_return_sync_mrtg( char * reply ) { | |||
| 479 | } | 436 | } |
| 480 | 437 | ||
| 481 | static size_t stats_return_everything( char * reply ) { | 438 | static size_t stats_return_everything( char * reply ) { |
| 439 | torrent_stats stats = {0,0,0}; | ||
| 440 | int i; | ||
| 482 | char * r = reply; | 441 | char * r = reply; |
| 442 | |||
| 443 | iterate_all_torrents( torrent_statter, (uintptr_t)&stats ); | ||
| 444 | |||
| 445 | r += sprintf( r, "<version>\n" ); r += stats_return_tracker_version( r ); r += sprintf( r, "</version>\n" ); | ||
| 483 | r += sprintf( r, "<stats>\n" ); | 446 | r += sprintf( r, "<stats>\n" ); |
| 484 | r += sprintf( r, " <uptime>%llu</uptime>\n", (unsigned long long)(time( NULL ) - ot_start_time) ); | 447 | r += sprintf( r, " <uptime>%llu</uptime>\n", (unsigned long long)(time( NULL ) - ot_start_time) ); |
| 485 | r += sprintf( r, " <torrents>%zd</torrents>\n", mutex_get_torrent_count() ); | 448 | r += sprintf( r, " <torrents>\n" ); |
| 486 | /* r += sprintf( r, " <peers>%llu</peers>\n", ); */ | 449 | r += sprintf( r, " <count_mutex>%zd</count_mutex>\n", mutex_get_torrent_count() ); |
| 487 | 450 | r += sprintf( r, " <count_iterator>%llu</count_iterator>\n", stats.torrent_count ); | |
| 488 | r += sprintf( reply, "</stats>" ); | 451 | r += sprintf( r, " </torrents>\n" ); |
| 452 | r += sprintf( r, " <peers>\n <count>%llu</count>\n </peers>\n", stats.peer_count ); | ||
| 453 | r += sprintf( r, " <seeds>\n <count>%llu</count>\n </seeds>\n", stats.seed_count ); | ||
| 454 | r += sprintf( r, " <connections>\n" ); | ||
| 455 | r += sprintf( r, " <tcp>\n <accept>%llu</accept>\n <announce>%llu</announce>\n <scrape>%llu</scrape>\n </tcp>\n", ot_overall_tcp_connections, ot_overall_tcp_successfulannounces, ot_overall_udp_successfulscrapes ); | ||
| 456 | r += sprintf( r, " <udp>\n <overall>%llu</overall>\n <connect>%llu</connect>\n <announce>%llu</announce>\n <scrape>%llu</scrape>\n </tcp>\n", ot_overall_udp_connections, ot_overall_udp_connects, ot_overall_udp_successfulannounces, ot_overall_udp_successfulscrapes ); | ||
| 457 | r += sprintf( r, " <livesync>\n <count>%llu</count>\n </livesync>\n", ot_overall_sync_count ); | ||
| 458 | r += sprintf( r, " </connections>\n" ); | ||
| 459 | r += sprintf( r, " <debug>\n" ); | ||
| 460 | r += sprintf( r, " <renew>\n" ); | ||
| 461 | for( i=0; i<OT_PEER_TIMEOUT; ++i ) | ||
| 462 | r += sprintf( r, " <count interval=\"%02i\">%llu</count>\n", i, ot_renewed[i] ); | ||
| 463 | r += sprintf( r, " </renew>\n" ); | ||
| 464 | r += sprintf( r, " <http_error>\n" ); | ||
| 465 | for( i=0; i<CODE_HTTPERROR_COUNT; ++i ) | ||
| 466 | r += sprintf( r, " <count code=\"%s\">%llu</count>\n", ot_failed_request_names[i], ot_failed_request_counts[i] ); | ||
| 467 | r += sprintf( r, " </http_error>\n" ); | ||
| 468 | r += sprintf( r, " <mutex_stall>\n <count>%llu</count>\n </mutex_stall>\n", ot_overall_stall_count ); | ||
| 469 | r += sprintf( r, " </debug>\n" ); | ||
| 470 | r += sprintf( r, "</stats>" ); | ||
| 489 | return r - reply; | 471 | return r - reply; |
| 490 | } | 472 | } |
| 491 | 473 | ||
| @@ -512,10 +494,6 @@ size_t return_stats_for_tracker( char *reply, int mode, int format ) { | |||
| 512 | return stats_udpconnections_mrtg( reply ); | 494 | return stats_udpconnections_mrtg( reply ); |
| 513 | case TASK_STATS_TCP: | 495 | case TASK_STATS_TCP: |
| 514 | return stats_tcpconnections_mrtg( reply ); | 496 | return stats_tcpconnections_mrtg( reply ); |
| 515 | case TASK_STATS_TORADDREM: | ||
| 516 | return stats_toraddrem_mrtg( reply ); | ||
| 517 | case TASK_STATS_STARTSTOP: | ||
| 518 | return stats_startstop_mrtg( reply ); | ||
| 519 | case TASK_STATS_FULLSCRAPE: | 497 | case TASK_STATS_FULLSCRAPE: |
| 520 | return stats_fullscrapes_mrtg( reply ); | 498 | return stats_fullscrapes_mrtg( reply ); |
| 521 | case TASK_STATS_HTTPERRORS: | 499 | case TASK_STATS_HTTPERRORS: |
| @@ -548,6 +526,7 @@ static void stats_make( int *iovec_entries, struct iovec **iovector, ot_tasktype | |||
| 548 | case TASK_STATS_PEERS: r += stats_peers_mrtg( r ); break; | 526 | case TASK_STATS_PEERS: r += stats_peers_mrtg( r ); break; |
| 549 | case TASK_STATS_SLASH24S: r += stats_slash24s_txt( r, 25, 16 ); break; | 527 | case TASK_STATS_SLASH24S: r += stats_slash24s_txt( r, 25, 16 ); break; |
| 550 | case TASK_STATS_TOP10: r += stats_top10_txt( r ); break; | 528 | case TASK_STATS_TOP10: r += stats_top10_txt( r ); break; |
| 529 | case TASK_STATS_EVERYTHING: r += stats_return_everything( r ); break; | ||
| 551 | default: | 530 | default: |
| 552 | iovec_free(iovec_entries, iovector); | 531 | iovec_free(iovec_entries, iovector); |
| 553 | return; | 532 | return; |
