commit 7de39e7d138ac25851bdf1e74b4e83ffb7f85f39 Author: Karsten Loesing karsten.loesing@gmx.net Date: Wed Sep 7 08:27:57 2011 +0200
Add new dirreq-stats.csv to help diagnose #3338. --- rserve/csv.R | 21 +++++++++++++++++++++ src/org/torproject/ernie/web/CsvServlet.java | 1 + 2 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/rserve/csv.R b/rserve/csv.R index 17a59c2..5693413 100644 --- a/rserve/csv.R +++ b/rserve/csv.R @@ -305,3 +305,24 @@ export_relays_monthly_snapshots <- function(path) { quote = FALSE, row.names = FALSE) }
+export_dirreq_stats <- function(path) { + drv <- dbDriver("PostgreSQL") + con <- dbConnect(drv, user = dbuser, password = dbpassword, dbname = db) + q <- paste("SELECT date, r, bwp, brp, bwn, brn, bwr, brr ", + "FROM user_stats ", + "WHERE date < (SELECT MAX(date) FROM user_stats) - 1 ", + "AND country = 'zy' ORDER BY date", sep = "") + rs <- dbSendQuery(con, q) + u <- fetch(rs, n = -1) + dbDisconnect(con) + dbUnloadDriver(drv) + u <- data.frame(date = u$date, + requests = u$r, + fraction = (u$bwr * u$brn / u$bwn - u$brr) / + (u$bwp * u$brn / u$bwn - u$brp), + users = u$r * (u$bwp * u$brn / u$bwn - u$brp) / + (u$bwr * u$brn / u$bwn - u$brr) / 10) + write.csv(format(u, trim = TRUE, scientific = FALSE), path, + quote = FALSE, row.names = FALSE) +} + diff --git a/src/org/torproject/ernie/web/CsvServlet.java b/src/org/torproject/ernie/web/CsvServlet.java index 0140fa9..99dc63c 100644 --- a/src/org/torproject/ernie/web/CsvServlet.java +++ b/src/org/torproject/ernie/web/CsvServlet.java @@ -35,6 +35,7 @@ public class CsvServlet extends HttpServlet { this.availableCsvFiles.add("connbidirect"); this.availableCsvFiles.add("current-platform-strings"); this.availableCsvFiles.add("direct-users"); + this.availableCsvFiles.add("dirreq-stats"); this.availableCsvFiles.add("dirbytes"); this.availableCsvFiles.add("gettor"); this.availableCsvFiles.add("monthly-users-average");