[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [metrics-web/master] Add HSDir to relay flags graph.



commit aec90f18676bd9d53389692791f3240ef1b336aa
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date:   Tue Feb 5 12:20:05 2013 +0100

    Add HSDir to relay flags graph.
---
 db/tordir.sql                                      |   35 ++++++++++++++++++--
 rserve/csv.R                                       |    3 +-
 rserve/graphs.R                                    |    6 ++--
 .../ernie/web/graphs/GraphParameterChecker.java    |    4 +-
 web/WEB-INF/network.jsp                            |    3 +-
 5 files changed, 41 insertions(+), 10 deletions(-)

diff --git a/db/tordir.sql b/db/tordir.sql
index 571a324..e62732d 100644
--- a/db/tordir.sql
+++ b/db/tordir.sql
@@ -154,6 +154,15 @@ CREATE TABLE network_size (
     avg_guard INTEGER NOT NULL,
     avg_fast INTEGER NOT NULL,
     avg_stable INTEGER NOT NULL,
+    avg_authority INTEGER NOT NULL,
+    avg_badexit INTEGER NOT NULL,
+    avg_baddirectory INTEGER NOT NULL,
+    avg_hsdir INTEGER NOT NULL,
+    avg_named INTEGER NOT NULL,
+    avg_unnamed INTEGER NOT NULL,
+    avg_valid INTEGER NOT NULL,
+    avg_v2dir INTEGER NOT NULL,
+    avg_v3dir INTEGER NOT NULL,
     CONSTRAINT network_size_pkey PRIMARY KEY(date)
 );
 
@@ -398,20 +407,40 @@ CREATE OR REPLACE FUNCTION refresh_network_size() RETURNS INTEGER AS $$
 
     EXECUTE '
         INSERT INTO network_size
-        (date, avg_running, avg_exit, avg_guard, avg_fast, avg_stable)
+        (date, avg_running, avg_exit, avg_guard, avg_fast, avg_stable,
+        avg_authority, avg_badexit, avg_baddirectory, avg_hsdir,
+        avg_named, avg_unnamed, avg_valid, avg_v2dir, avg_v3dir)
         SELECT date,
             isrunning / count AS avg_running,
             isexit / count AS avg_exit,
             isguard / count AS avg_guard,
             isfast / count AS avg_fast,
-            isstable / count AS avg_stable
+            isstable / count AS avg_stable,
+            isauthority / count as avg_authority,
+            isbadexit / count as avg_badexit,
+            isbaddirectory / count as avg_baddirectory,
+            ishsdir / count as avg_hsdir,
+            isnamed / count as avg_named,
+            isunnamed / count as avg_unnamed,
+            isvalid / count as avg_valid,
+            isv2dir / count as avg_v2dir,
+            isv3dir / count as avg_v3dir
         FROM (
             SELECT DATE(validafter) AS date,
                 COUNT(*) AS isrunning,
                 COUNT(NULLIF(isexit, FALSE)) AS isexit,
                 COUNT(NULLIF(isguard, FALSE)) AS isguard,
                 COUNT(NULLIF(isfast, FALSE)) AS isfast,
-                COUNT(NULLIF(isstable, FALSE)) AS isstable
+                COUNT(NULLIF(isstable, FALSE)) AS isstable,
+                COUNT(NULLIF(isauthority, FALSE)) AS isauthority,
+                COUNT(NULLIF(isbadexit, FALSE)) AS isbadexit,
+                COUNT(NULLIF(isbaddirectory, FALSE)) AS isbaddirectory,
+                COUNT(NULLIF(ishsdir, FALSE)) AS ishsdir,
+                COUNT(NULLIF(isnamed, FALSE)) AS isnamed,
+                COUNT(NULLIF(isunnamed, FALSE)) AS isunnamed,
+                COUNT(NULLIF(isvalid, FALSE)) AS isvalid,
+                COUNT(NULLIF(isv2dir, FALSE)) AS isv2dir,
+                COUNT(NULLIF(isv3dir, FALSE)) AS isv3dir
             FROM statusentry
             WHERE isrunning = TRUE
               AND validafter >= ''' || min_date || '''
diff --git a/rserve/csv.R b/rserve/csv.R
index f8c21b1..9fdfbbd 100644
--- a/rserve/csv.R
+++ b/rserve/csv.R
@@ -126,7 +126,8 @@ export_relayflags <- function(path) {
   drv <- dbDriver("PostgreSQL")
   con <- dbConnect(drv, user = dbuser, password = dbpassword, dbname = db)
   q <- paste("SELECT date, avg_running AS running, avg_exit AS exit,",
-      "avg_guard AS guard, avg_fast AS fast, avg_stable AS stable",
+      "avg_guard AS guard, avg_fast AS fast, avg_stable AS stable,",
+      "avg_hsdir AS hsdir",
       "FROM network_size WHERE date < current_date - 1 ORDER BY date")
   rs <- dbSendQuery(con, q)
   relayflags <- fetch(rs, n = -1)
diff --git a/rserve/graphs.R b/rserve/graphs.R
index 2a59396..72bbc1e 100644
--- a/rserve/graphs.R
+++ b/rserve/graphs.R
@@ -606,7 +606,7 @@ plot_relayflags <- function(start, end, flags, path) {
   networksize <- rbind(data.frame(
     date = as.Date(end) + 1,
     variable = paste("avg_", c("running", "exit", "guard", "fast",
-      "stable"), sep = ""),
+      "stable", "hsdir"), sep = ""),
     value = NA), networksize)
   dates <- seq(from = as.Date(start, "%Y-%m-%d"),
       to = as.Date(end, "%Y-%m-%d"), by="1 day")
@@ -615,7 +615,7 @@ plot_relayflags <- function(start, end, flags, path) {
     networksize <- rbind(data.frame(
       date = as.Date(rep(missing, 5), origin = "1970-01-01"),
       variable = paste("avg_", c("running", "exit", "guard", "fast",
-        "stable"), sep = ""),
+        "stable", "hsdir"), sep = ""),
       value = rep(NA, length(missing) * 5)), networksize)
   date_breaks <- date_breaks(
     as.numeric(max(as.Date(end, "%Y-%m-%d")) -
@@ -629,7 +629,7 @@ plot_relayflags <- function(start, end, flags, path) {
     scale_y_continuous(name = "", limits = c(0, max(networksize$value,
         na.rm = TRUE))) +
     scale_colour_manual(name = "Relay flags", values = c("#E69F00",
-        "#56B4E9", "#009E73", "#000000", "#0072B2"),
+        "#56B4E9", "#009E73", "#EE6A50", "#000000", "#0072B2"),
         breaks = paste("avg_", tolower(flags), sep = ""),
         labels = flags) +
     opts(title = "Number of relays with relay flags assigned\n")
diff --git a/src/org/torproject/ernie/web/graphs/GraphParameterChecker.java b/src/org/torproject/ernie/web/graphs/GraphParameterChecker.java
index a47538e..8300be5 100644
--- a/src/org/torproject/ernie/web/graphs/GraphParameterChecker.java
+++ b/src/org/torproject/ernie/web/graphs/GraphParameterChecker.java
@@ -49,7 +49,7 @@ public class GraphParameterChecker {
 
     this.knownParameterValues = new HashMap<String, String>();
     this.knownParameterValues.put("flag",
-        "Running,Exit,Guard,Fast,Stable");
+        "Running,Exit,Guard,Fast,Stable,HSDir");
     StringBuilder sb = new StringBuilder("all");
     for (String[] country : Countries.getInstance().getCountryList()) {
       sb.append("," + country[0]);
@@ -142,7 +142,7 @@ public class GraphParameterChecker {
           }
         }
       } else {
-        flagParameters = this.knownParameterValues.get("flag").split(",");
+        flagParameters = "Running,Exit,Guard,Fast,Stable".split(",");
       }
       recognizedGraphParameters.put("flag", flagParameters);
     }
diff --git a/web/WEB-INF/network.jsp b/web/WEB-INF/network.jsp
index a43c46e..0b92c1a 100644
--- a/web/WEB-INF/network.jsp
+++ b/web/WEB-INF/network.jsp
@@ -89,7 +89,7 @@ country.</p>
 
 <a name="relayflags"></a>
 <h3><a href="#relayflags" class="anchor">Relays with Exit, Fast, Guard,
-and Stable flags</a></h3>
+Stable, and HSDir flags</a></h3>
 <br>
 <p>The directory authorities assign certain flags to relays that clients
 use for their path selection decisions. The following graph shows the
@@ -113,6 +113,7 @@ average number of relays with these flags assigned.</p>
       <input type="checkbox" name="flag" value="Fast"<c:if test="${fn:length(relayflags_flag) == 0 or fn:contains(fn:join(relayflags_flag, ','), 'Fast')}"> checked</c:if>> Fast
       <input type="checkbox" name="flag" value="Guard"<c:if test="${fn:length(relayflags_flag) == 0 or fn:contains(fn:join(relayflags_flag, ','), 'Guard')}"> checked</c:if>> Guard
       <input type="checkbox" name="flag" value="Stable"<c:if test="${fn:length(relayflags_flag) == 0 or fn:contains(fn:join(relayflags_flag, ','), 'Stable')}"> checked</c:if>> Stable
+      <input type="checkbox" name="flag" value="HSDir"<c:if test="${fn:length(relayflags_flag) > 0 and fn:contains(fn:join(relayflags_flag, ','), 'HSDir')}"> checked</c:if>> HSDir
     </p><p>
     <input class="submit" type="submit" value="Update graph">
     </p>

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits