summaryrefslogtreecommitdiff
path: root/ot_stats.c
diff options
context:
space:
mode:
Diffstat (limited to 'ot_stats.c')
-rw-r--r--ot_stats.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/ot_stats.c b/ot_stats.c
index 2428adf..f31324c 100644
--- a/ot_stats.c
+++ b/ot_stats.c
@@ -47,6 +47,7 @@ static unsigned long long ot_full_scrape_request_count = 0;
47static unsigned long long ot_full_scrape_size = 0; 47static unsigned long long ot_full_scrape_size = 0;
48static unsigned long long ot_failed_request_counts[CODE_HTTPERROR_COUNT]; 48static unsigned long long ot_failed_request_counts[CODE_HTTPERROR_COUNT];
49static unsigned long long ot_renewed[OT_PEER_TIMEOUT]; 49static unsigned long long ot_renewed[OT_PEER_TIMEOUT];
50static unsigned long long ot_overall_sync_count;
50 51
51static time_t ot_start_time; 52static 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
469static 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
468extern const char 483extern 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 }