diff options
| author | erdgeist <> | 2009-08-26 21:23:26 +0000 |
|---|---|---|
| committer | erdgeist <> | 2009-08-26 21:23:26 +0000 |
| commit | 6073127ad0712bf925fd80982b68b072541824db (patch) | |
| tree | d778c5c95b4ad568342b8aecb4f29a0137967090 /ot_stats.c | |
| parent | 20955311d12966b49b3cdf62217d7508af9a4e9a (diff) | |
Add some subnet debugging features
Diffstat (limited to 'ot_stats.c')
| -rw-r--r-- | ot_stats.c | 37 |
1 files changed, 37 insertions, 0 deletions
| @@ -26,6 +26,7 @@ | |||
| 26 | #include "ot_mutex.h" | 26 | #include "ot_mutex.h" |
| 27 | #include "ot_iovec.h" | 27 | #include "ot_iovec.h" |
| 28 | #include "ot_stats.h" | 28 | #include "ot_stats.h" |
| 29 | #include "ot_accesslist.h" | ||
| 29 | 30 | ||
| 30 | #ifndef NO_FULLSCRAPE_LOGGING | 31 | #ifndef NO_FULLSCRAPE_LOGGING |
| 31 | #define LOG_TO_STDERR( ... ) fprintf( stderr, __VA_ARGS__ ) | 32 | #define LOG_TO_STDERR( ... ) fprintf( stderr, __VA_ARGS__ ) |
| @@ -477,6 +478,38 @@ static size_t stats_return_completed_mrtg( char * reply ) { | |||
| 477 | ); | 478 | ); |
| 478 | } | 479 | } |
| 479 | 480 | ||
| 481 | #ifdef WANT_FULLLOG_NETWORKS | ||
| 482 | static void stats_return_fulllog( int *iovec_entries, struct iovec **iovector, char *r ) { | ||
| 483 | ot_log *loglist = g_logchain_first, *llnext; | ||
| 484 | char * re = r + OT_STATS_TMPSIZE; | ||
| 485 | |||
| 486 | g_logchain_first = g_logchain_last = 0; | ||
| 487 | |||
| 488 | while( loglist ) { | ||
| 489 | if( r + ( loglist->size + 64 ) >= re ) { | ||
| 490 | r = iovec_fix_increase_or_free( iovec_entries, iovector, r, 32 * OT_STATS_TMPSIZE ); | ||
| 491 | if( !r ) return; | ||
| 492 | re = r + 32 * OT_STATS_TMPSIZE; | ||
| 493 | } | ||
| 494 | r += sprintf( r, "%08ld: ", loglist->time ); | ||
| 495 | r += fmt_ip6c( r, loglist->ip ); | ||
| 496 | *r++ = '\n'; | ||
| 497 | memcpy( r, loglist->data, loglist->size ); | ||
| 498 | r += loglist->size; | ||
| 499 | *r++ = '\n'; | ||
| 500 | *r++ = '*'; | ||
| 501 | *r++ = '\n'; | ||
| 502 | *r++ = '\n'; | ||
| 503 | |||
| 504 | llnext = loglist->next; | ||
| 505 | free( loglist->data ); | ||
| 506 | free( loglist ); | ||
| 507 | loglist = llnext; | ||
| 508 | } | ||
| 509 | iovec_fixlast( iovec_entries, iovector, r ); | ||
| 510 | } | ||
| 511 | #endif | ||
| 512 | |||
| 480 | static size_t stats_return_everything( char * reply ) { | 513 | static size_t stats_return_everything( char * reply ) { |
| 481 | torrent_stats stats = {0,0,0}; | 514 | torrent_stats stats = {0,0,0}; |
| 482 | int i; | 515 | int i; |
| @@ -570,6 +603,10 @@ static void stats_make( int *iovec_entries, struct iovec **iovector, ot_tasktype | |||
| 570 | case TASK_STATS_SLASH24S: r += stats_slash24s_txt( r, 128 ); break; | 603 | case TASK_STATS_SLASH24S: r += stats_slash24s_txt( r, 128 ); break; |
| 571 | case TASK_STATS_TOP10: r += stats_top10_txt( r ); break; | 604 | case TASK_STATS_TOP10: r += stats_top10_txt( r ); break; |
| 572 | case TASK_STATS_EVERYTHING: r += stats_return_everything( r ); break; | 605 | case TASK_STATS_EVERYTHING: r += stats_return_everything( r ); break; |
| 606 | #ifdef WANT_FULLLOG_NETWORKS | ||
| 607 | case TASK_STATS_FULLLOG: stats_return_fulllog( iovec_entries, iovector, r ); | ||
| 608 | return; | ||
| 609 | #endif | ||
| 573 | default: | 610 | default: |
| 574 | iovec_free(iovec_entries, iovector); | 611 | iovec_free(iovec_entries, iovector); |
| 575 | return; | 612 | return; |
