summaryrefslogtreecommitdiff
path: root/src/ot_stats.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ot_stats.c')
-rw-r--r--src/ot_stats.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/ot_stats.c b/src/ot_stats.c
index 2d6335b..7b5b1b9 100644
--- a/src/ot_stats.c
+++ b/src/ot_stats.c
@@ -373,7 +373,7 @@ void stats_top_txt(char **reply, const char *reply_end, size_t amount) {
373static unsigned long events_per_time(unsigned long long events, time_t t) { return events / ((unsigned int)t ? (unsigned int)t : 1); } 373static unsigned long events_per_time(unsigned long long events, time_t t) { return events / ((unsigned int)t ? (unsigned int)t : 1); }
374 374
375static void stats_connections_mrtg(char **reply, const char *reply_end) { 375static void stats_connections_mrtg(char **reply, const char *reply_end) {
376 ot_time t = time(NULL) - ot_start_time; 376 ot_time t = time_since_seconds(ot_start_time);
377 unsigned long long total[OT_COUNTER_COUNT]; 377 unsigned long long total[OT_COUNTER_COUNT];
378 378
379 counters_total(total); 379 counters_total(total);
@@ -386,7 +386,7 @@ static void stats_connections_mrtg(char **reply, const char *reply_end) {
386} 386}
387 387
388static void stats_udpconnections_mrtg(char **reply, const char *reply_end) { 388static void stats_udpconnections_mrtg(char **reply, const char *reply_end) {
389 ot_time t = time(NULL) - ot_start_time; 389 ot_time t = time_since_seconds(ot_start_time);
390 unsigned long long total[OT_COUNTER_COUNT]; 390 unsigned long long total[OT_COUNTER_COUNT];
391 391
392 counters_total(total); 392 counters_total(total);
@@ -398,7 +398,7 @@ static void stats_udpconnections_mrtg(char **reply, const char *reply_end) {
398} 398}
399 399
400static void stats_tcpconnections_mrtg(char **reply, const char *reply_end) { 400static void stats_tcpconnections_mrtg(char **reply, const char *reply_end) {
401 time_t t = time(NULL) - ot_start_time; 401 time_t t = time_since_seconds(ot_start_time);
402 unsigned long long total[OT_COUNTER_COUNT]; 402 unsigned long long total[OT_COUNTER_COUNT];
403 403
404 counters_total(total); 404 counters_total(total);
@@ -409,7 +409,7 @@ static void stats_tcpconnections_mrtg(char **reply, const char *reply_end) {
409} 409}
410 410
411static void stats_scrape_mrtg(char **reply, const char *reply_end) { 411static void stats_scrape_mrtg(char **reply, const char *reply_end) {
412 time_t t = time(NULL) - ot_start_time; 412 time_t t = time_since_seconds(ot_start_time);
413 unsigned long long total[OT_COUNTER_COUNT]; 413 unsigned long long total[OT_COUNTER_COUNT];
414 414
415 counters_total(total); 415 counters_total(total);
@@ -420,7 +420,7 @@ static void stats_scrape_mrtg(char **reply, const char *reply_end) {
420} 420}
421 421
422static void stats_fullscrapes_mrtg(char **reply, const char *reply_end) { 422static void stats_fullscrapes_mrtg(char **reply, const char *reply_end) {
423 ot_time t = time(NULL) - ot_start_time; 423 ot_time t = time_since_seconds(ot_start_time);
424 unsigned long long total[OT_COUNTER_COUNT]; 424 unsigned long long total[OT_COUNTER_COUNT];
425 425
426 counters_total(total); 426 counters_total(total);
@@ -468,7 +468,7 @@ static void stats_return_renew_bucket(char **reply, const char *reply_end) {
468} 468}
469 469
470static void stats_return_sync_mrtg(char **reply, const char *reply_end) { 470static void stats_return_sync_mrtg(char **reply, const char *reply_end) {
471 ot_time t = time(NULL) - ot_start_time; 471 ot_time t = time_since_seconds(ot_start_time);
472 unsigned long long total[OT_COUNTER_COUNT]; 472 unsigned long long total[OT_COUNTER_COUNT];
473 473
474 counters_total(total); 474 counters_total(total);
@@ -479,7 +479,7 @@ static void stats_return_sync_mrtg(char **reply, const char *reply_end) {
479} 479}
480 480
481static void stats_return_completed_mrtg(char **reply, const char *reply_end) { 481static void stats_return_completed_mrtg(char **reply, const char *reply_end) {
482 ot_time t = time(NULL) - ot_start_time; 482 ot_time t = time_since_seconds(ot_start_time);
483 unsigned long long total[OT_COUNTER_COUNT]; 483 unsigned long long total[OT_COUNTER_COUNT];
484 484
485 counters_total(total); 485 counters_total(total);
@@ -510,7 +510,7 @@ static void stats_return_everything(char **reply, const char *reply_end) {
510 510
511 fmt_append(reply, reply_end, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); 511 fmt_append(reply, reply_end, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
512 fmt_append(reply, reply_end, "<stats>\n"); 512 fmt_append(reply, reply_end, "<stats>\n");
513 fmt_append(reply, reply_end, " <uptime>%llu</uptime>\n", (unsigned long long)(time(NULL) - ot_start_time)); 513 fmt_append(reply, reply_end, " <uptime>%llu</uptime>\n", (unsigned long long)time_since_seconds(ot_start_time));
514 fmt_append(reply, reply_end, " <torrents>\n"); 514 fmt_append(reply, reply_end, " <torrents>\n");
515 fmt_append(reply, reply_end, " <count_mutex>%zd</count_mutex>\n", mutex_get_torrent_count()); 515 fmt_append(reply, reply_end, " <count_mutex>%zd</count_mutex>\n", mutex_get_torrent_count());
516 fmt_append(reply, reply_end, " <count_iterator>%llu</count_iterator>\n", stats.torrent_count); 516 fmt_append(reply, reply_end, " <count_iterator>%llu</count_iterator>\n", stats.torrent_count);
@@ -785,7 +785,7 @@ void stats_issue_event(struct ot_workstruct *ws, ot_status_event event, PROTO_FL
785 case EVENT_FULLSCRAPE_REQUEST: { 785 case EVENT_FULLSCRAPE_REQUEST: {
786 ot_ip6 *ip = (ot_ip6 *)event_data; /* ugly hack to transfer ip to stats */ 786 ot_ip6 *ip = (ot_ip6 *)event_data; /* ugly hack to transfer ip to stats */
787 char _debug[512]; 787 char _debug[512];
788 int off = snprintf(_debug, sizeof(_debug), "[%08d] scrp: ", (unsigned int)(time_now_seconds() - ot_start_time) / 60); 788 int off = snprintf(_debug, sizeof(_debug), "[%08d] scrp: ", (unsigned int)time_since_seconds(ot_start_time) / 60);
789 off += ip_format(_debug + off, *ip); 789 off += ip_format(_debug + off, *ip);
790 off += snprintf(_debug + off, sizeof(_debug) - off, " - FULL SCRAPE\n"); 790 off += snprintf(_debug + off, sizeof(_debug) - off, " - FULL SCRAPE\n");
791 (void)write(2, _debug, off); 791 (void)write(2, _debug, off);
@@ -794,7 +794,7 @@ void stats_issue_event(struct ot_workstruct *ws, ot_status_event event, PROTO_FL
794 case EVENT_FULLSCRAPE_REQUEST_GZIP: { 794 case EVENT_FULLSCRAPE_REQUEST_GZIP: {
795 ot_ip6 *ip = (ot_ip6 *)event_data; /* ugly hack to transfer ip to stats */ 795 ot_ip6 *ip = (ot_ip6 *)event_data; /* ugly hack to transfer ip to stats */
796 char _debug[512]; 796 char _debug[512];
797 int off = snprintf(_debug, sizeof(_debug), "[%08d] scrp: ", (unsigned int)(time_now_seconds() - ot_start_time) / 60); 797 int off = snprintf(_debug, sizeof(_debug), "[%08d] scrp: ", (unsigned int)time_since_seconds(ot_start_time) / 60);
798 off += ip_format(_debug + off, *ip); 798 off += ip_format(_debug + off, *ip);
799 off += snprintf(_debug + off, sizeof(_debug) - off, " - FULL SCRAPE\n"); 799 off += snprintf(_debug + off, sizeof(_debug) - off, " - FULL SCRAPE\n");
800 (void)write(2, _debug, off); 800 (void)write(2, _debug, off);
@@ -804,7 +804,8 @@ void stats_issue_event(struct ot_workstruct *ws, ot_status_event event, PROTO_FL
804 COUNT(OT_COUNTER_FAILED + event_data, 1); 804 COUNT(OT_COUNTER_FAILED + event_data, 1);
805 break; 805 break;
806 case EVENT_RENEW: 806 case EVENT_RENEW:
807 COUNT(OT_COUNTER_RENEWED + event_data, 1); 807 if (event_data < OT_PEER_TIMEOUT)
808 COUNT(OT_COUNTER_RENEWED + event_data, 1);
808 break; 809 break;
809 case EVENT_SYNC: 810 case EVENT_SYNC:
810 COUNT(OT_COUNTER_SYNCS, event_data); 811 COUNT(OT_COUNTER_SYNCS, event_data);