浏览代码

Write bidirectional connection stats in single line.

There's no need to have a separate line conn-stats-end for the end date
and interval length with only a single line conn-bi-direct following.
Karsten Loesing 15 年之前
父节点
当前提交
8db10c6d2f
共有 5 个文件被更改,包括 14 次插入27 次删除
  1. 8 18
      doc/spec/dir-spec.txt
  2. 1 1
      doc/tor.1.txt
  3. 1 2
      src/or/rephist.c
  4. 1 1
      src/or/router.c
  5. 3 5
      src/test/test.c

+ 8 - 18
doc/spec/dir-spec.txt

@@ -848,27 +848,17 @@
         Mean number of circuits that are included in any of the deciles,
         Mean number of circuits that are included in any of the deciles,
         rounded up to the next integer.
         rounded up to the next integer.
 
 
-    "conn-stats-end" YYYY-MM-DD HH:MM:SS (NSEC s) NL
-        [At most once]
-
-        YYYY-MM-DD HH:MM:SS defines the end of the included connection
-        statistics measurement interval of length NSEC seconds (86400
-        seconds by default).
-
-        A "conn-stats-end" line, as well as any other "conn-*" line,
-        is first added after the relay has been running for at least 24
-        hours.
-
-    "conn-bi-direct" BELOW,READ,WRITE,BOTH NL
+    "conn-bi-direct" YYYY-MM-DD HH:MM:SS (NSEC s) BELOW,READ,WRITE,BOTH NL
         [At most once]
         [At most once]
 
 
         Number of connections, split into 10-second intervals, that are
         Number of connections, split into 10-second intervals, that are
-        used uni-directionally or bi-directionally.  Every 10 seconds,
-        we determine for every connection whether we read and wrote less
-        than a threshold of 20 KiB (BELOW), read at least 10 times more
-        than we wrote (READ), wrote at least 10 times more than we read
-        (WRITE), or read and wrote more than the threshold, but not 10
-        times more in either direction (BOTH).  After classifying a
+        used uni-directionally or bi-directionally as observed in the NSEC
+        seconds (usually 86400 seconds) before YYYY-MM-DD HH:MM:SS.  Every
+        10 seconds, we determine for every connection whether we read and
+        wrote less than a threshold of 20 KiB (BELOW), read at least 10
+        times more than we wrote (READ), wrote at least 10 times more than
+        we read (WRITE), or read and wrote more than the threshold, but
+        not 10 times more in either direction (BOTH).  After classifying a
         connection, read and write counters are reset for the next
         connection, read and write counters are reset for the next
         10-second interval.
         10-second interval.
 
 

+ 1 - 1
doc/tor.1.txt

@@ -1027,7 +1027,7 @@ is non-zero):
     When this option is enabled, Tor writes statistics on the number of relayed
     When this option is enabled, Tor writes statistics on the number of relayed
     bytes and opened stream per exit port to disk every 24 hours. (Default: 0)
     bytes and opened stream per exit port to disk every 24 hours. (Default: 0)
 
 
-**ConnDirectionStats** **0**|**1**::
+**ConnDirectionStatistics** **0**|**1**::
     When this option is enabled, Tor writes statistics on the bidirectional use
     When this option is enabled, Tor writes statistics on the bidirectional use
     of connections to disk every 24 hours. (Default: 0)
     of connections to disk every 24 hours. (Default: 0)
 
 

+ 1 - 2
src/or/rephist.c

@@ -2592,8 +2592,7 @@ rep_hist_format_conn_stats(time_t now)
     return NULL; /* Not initialized. */
     return NULL; /* Not initialized. */
 
 
   format_iso_time(written, now);
   format_iso_time(written, now);
-  tor_asprintf(&result, "conn-stats-end %s (%d s)\n"
-               "conn-bi-direct %d,%d,%d,%d\n",
+  tor_asprintf(&result, "conn-bi-direct %s (%d s) %d,%d,%d,%d\n",
                written,
                written,
                (unsigned) (now - start_of_conn_stats_interval),
                (unsigned) (now - start_of_conn_stats_interval),
                below_threshold,
                below_threshold,

+ 1 - 1
src/or/router.c

@@ -2053,7 +2053,7 @@ extrainfo_dump_to_string(char **s_out, extrainfo_t *extrainfo,
     }
     }
     if (options->ConnDirectionStatistics &&
     if (options->ConnDirectionStatistics &&
         load_stats_file("stats"PATH_SEPARATOR"conn-stats",
         load_stats_file("stats"PATH_SEPARATOR"conn-stats",
-                        "conn-stats-end", now, &contents) > 0) {
+                        "conn-bi-direct", now, &contents) > 0) {
       size_t pos = strlen(s);
       size_t pos = strlen(s);
       if (strlcpy(s + pos, contents, maxlen - strlen(s)) !=
       if (strlcpy(s + pos, contents, maxlen - strlen(s)) !=
           strlen(contents)) {
           strlen(contents)) {

+ 3 - 5
src/test/test.c

@@ -1175,8 +1175,7 @@ test_stats(void)
   rep_hist_note_or_conn_bytes(2, 400000, 30000, now + 10);
   rep_hist_note_or_conn_bytes(2, 400000, 30000, now + 10);
   rep_hist_note_or_conn_bytes(2, 400000, 30000, now + 15);
   rep_hist_note_or_conn_bytes(2, 400000, 30000, now + 15);
   s = rep_hist_format_conn_stats(now + 86400);
   s = rep_hist_format_conn_stats(now + 86400);
-  test_streq("conn-stats-end 2010-08-12 13:27:30 (86400 s)\n"
-             "conn-bi-direct 0,0,1,0\n", s);
+  test_streq("conn-bi-direct 2010-08-12 13:27:30 (86400 s) 0,0,1,0\n", s);
   tor_free(s);
   tor_free(s);
 
 
   /* Stop collecting stats, add some bytes, and ensure we don't generate
   /* Stop collecting stats, add some bytes, and ensure we don't generate
@@ -1187,7 +1186,7 @@ test_stats(void)
   test_assert(!s);
   test_assert(!s);
 
 
   /* Re-start stats, add some bytes, reset stats, and see what history we
   /* Re-start stats, add some bytes, reset stats, and see what history we
-   * get when observing no streams or bytes at all. */
+   * get when observing no bytes at all. */
   rep_hist_conn_stats_init(now);
   rep_hist_conn_stats_init(now);
   rep_hist_note_or_conn_bytes(1, 30000, 400000, now);
   rep_hist_note_or_conn_bytes(1, 30000, 400000, now);
   rep_hist_note_or_conn_bytes(1, 30000, 400000, now + 5);
   rep_hist_note_or_conn_bytes(1, 30000, 400000, now + 5);
@@ -1195,8 +1194,7 @@ test_stats(void)
   rep_hist_note_or_conn_bytes(2, 400000, 30000, now + 15);
   rep_hist_note_or_conn_bytes(2, 400000, 30000, now + 15);
   rep_hist_reset_conn_stats(now);
   rep_hist_reset_conn_stats(now);
   s = rep_hist_format_conn_stats(now + 86400);
   s = rep_hist_format_conn_stats(now + 86400);
-  test_streq("conn-stats-end 2010-08-12 13:27:30 (86400 s)\n"
-             "conn-bi-direct 0,0,0,0\n", s);
+  test_streq("conn-bi-direct 2010-08-12 13:27:30 (86400 s) 0,0,0,0\n", s);
 
 
  done:
  done:
   tor_free(s);
   tor_free(s);