diff options
Diffstat (limited to 'ot_stats.c')
-rw-r--r-- | ot_stats.c | 22 |
1 files changed, 21 insertions, 1 deletions
@@ -47,6 +47,7 @@ static unsigned long long ot_full_scrape_request_count = 0; | |||
47 | static unsigned long long ot_full_scrape_size = 0; | 47 | static unsigned long long ot_full_scrape_size = 0; |
48 | static unsigned long long ot_failed_request_counts[CODE_HTTPERROR_COUNT]; | 48 | static unsigned long long ot_failed_request_counts[CODE_HTTPERROR_COUNT]; |
49 | static unsigned long long ot_renewed[OT_PEER_TIMEOUT]; | 49 | static unsigned long long ot_renewed[OT_PEER_TIMEOUT]; |
50 | static unsigned long long ot_overall_sync_count; | ||
50 | 51 | ||
51 | static time_t ot_start_time; | 52 | static time_t ot_start_time; |
52 | 53 | ||
@@ -465,6 +466,20 @@ static size_t stats_return_renew_bucket( char * reply ) { | |||
465 | return r - reply; | 466 | return r - reply; |
466 | } | 467 | } |
467 | 468 | ||
469 | static size_t stats_return_sync_mrtg( char * reply ) | ||
470 | { | ||
471 | ot_time t = time( NULL ) - ot_start_time; | ||
472 | return sprintf( reply, | ||
473 | "%llu\n%llu\n%i seconds (%i hours)\nopentracker connections, %lu conns/s :: %lu success/s.", | ||
474 | ot_overall_sync_count, | ||
475 | 0, | ||
476 | (int)t, | ||
477 | (int)(t / 3600), | ||
478 | events_per_time( ot_overall_tcp_connections+ot_overall_udp_connections, t ), | ||
479 | events_per_time( ot_overall_tcp_successfulannounces+ot_overall_udp_successfulannounces+ot_overall_udp_connects, t ) | ||
480 | ); | ||
481 | } | ||
482 | |||
468 | extern const char | 483 | extern const char |
469 | *g_version_opentracker_c, *g_version_accesslist_c, *g_version_clean_c, *g_version_fullscrape_c, *g_version_http_c, | 484 | *g_version_opentracker_c, *g_version_accesslist_c, *g_version_clean_c, *g_version_fullscrape_c, *g_version_http_c, |
470 | *g_version_iovec_c, *g_version_mutex_c, *g_version_stats_c, *g_version_udp_c, *g_version_vector_c, | 485 | *g_version_iovec_c, *g_version_mutex_c, *g_version_stats_c, *g_version_udp_c, *g_version_vector_c, |
@@ -500,6 +515,8 @@ size_t return_stats_for_tracker( char *reply, int mode, int format ) { | |||
500 | return stats_return_tracker_version( reply ); | 515 | return stats_return_tracker_version( reply ); |
501 | case TASK_STATS_RENEW: | 516 | case TASK_STATS_RENEW: |
502 | return stats_return_renew_bucket( reply ); | 517 | return stats_return_renew_bucket( reply ); |
518 | case TASK_STATS_SYNCS: | ||
519 | return stats_return_sync_mrtg( reply ); | ||
503 | #ifdef WANT_LOG_NETWORKS | 520 | #ifdef WANT_LOG_NETWORKS |
504 | case TASK_STATS_BUSY_NETWORKS: | 521 | case TASK_STATS_BUSY_NETWORKS: |
505 | return stats_return_busy_networks( reply ); | 522 | return stats_return_busy_networks( reply ); |
@@ -566,9 +583,12 @@ void stats_issue_event( ot_status_event event, PROTO_FLAG proto, uint32_t event_ | |||
566 | case EVENT_FAILED: | 583 | case EVENT_FAILED: |
567 | ot_failed_request_counts[event_data]++; | 584 | ot_failed_request_counts[event_data]++; |
568 | break; | 585 | break; |
569 | case EVENT_RENEW: | 586 | case EVENT_RENEW: |
570 | ot_renewed[event_data]++; | 587 | ot_renewed[event_data]++; |
571 | break; | 588 | break; |
589 | case EVENT_SYNC: | ||
590 | ot_overall_sync_count+=event_data; | ||
591 | break; | ||
572 | default: | 592 | default: |
573 | break; | 593 | break; |
574 | } | 594 | } |