[tor-commits] [metrics-web/master] Add webstats-tm graph very similar to webstats-tb.
karsten at torproject.org
karsten at torproject.org
Sun Jan 29 16:03:42 UTC 2017
commit d755f4113d7f201e60c9fc4dc70f49bad614da73
Author: Karsten Loesing <karsten.loesing at gmx.net>
Date: Fri Jan 27 19:54:16 2017 +0100
Add webstats-tm graph very similar to webstats-tb.
---
modules/webstats/src/main/resources/write-RData.R | 7 ++++++
website/etc/categories.json | 3 ++-
website/etc/metrics.json | 14 +++++++++++
website/etc/web.xml | 4 ++++
website/rserve/graphs.R | 29 +++++++++++++++++++++++
5 files changed, 56 insertions(+), 1 deletion(-)
diff --git a/modules/webstats/src/main/resources/write-RData.R b/modules/webstats/src/main/resources/write-RData.R
index 2cb8917..96cc840 100644
--- a/modules/webstats/src/main/resources/write-RData.R
+++ b/modules/webstats/src/main/resources/write-RData.R
@@ -7,3 +7,10 @@ data <- aggregate(list(count = d$count),
FUN = sum)
save(data, file = "RData/webstats-tb.RData")
+d <- read.csv("stats/webstats.csv", stringsAsFactors = FALSE)
+d <- d[d$request_type %in% c('tmid', 'tmup'), ]
+data <- aggregate(list(count = d$count),
+ by = list(log_date = as.Date(d$log_date), request_type = d$request_type),
+ FUN = sum)
+save(data, file = "RData/webstats-tm.RData")
+
diff --git a/website/etc/categories.json b/website/etc/categories.json
index 6825634..64b5c1a 100644
--- a/website/etc/categories.json
+++ b/website/etc/categories.json
@@ -80,7 +80,8 @@
"summary": "How many Tor applications, like Tor Browser, have been downloaded or updated.",
"description": "The following application statistics are based on the analysis of requests to <code>torproject.org</code> web servers.",
"metrics": [
- "webstats-tb"
+ "webstats-tb",
+ "webstats-tm"
]
}
]
diff --git a/website/etc/metrics.json b/website/etc/metrics.json
index 12ef62c..2601318 100644
--- a/website/etc/metrics.json
+++ b/website/etc/metrics.json
@@ -416,5 +416,19 @@
"data": [
"webstats"
]
+ },
+ {
+ "id": "webstats-tm",
+ "title": "Tor Messenger downloads and updates",
+ "type": "Graph",
+ "description": "<p>This graph shows absolute numbers of requests to Tor's web servers by request type. It is based on data from <a href=\"https://webstats.torproject.org/\" target=\"_blank\"><code>webstats.torproject.org</code></a> which collects logs from <code>torproject.org</code> web servers and provides them as a stripped-down version of Apache's \"combined\" log format without IP addresses, log times, HTTP parameters, referers, and user agent strings. <em>Initial downloads</em> are requests made by the user to download a Tor Messenger executable from the Tor website. <em>Update pings</em> are requests made by Tor Messenger to check whether a newer version is available.</p>",
+ "function": "plot_webstats_tm",
+ "parameters": [
+ "start",
+ "end"
+ ],
+ "data": [
+ "webstats"
+ ]
}
]
diff --git a/website/etc/web.xml b/website/etc/web.xml
index 916984c..adfc370 100644
--- a/website/etc/web.xml
+++ b/website/etc/web.xml
@@ -47,6 +47,7 @@
<url-pattern>/hidserv-rend-relayed-cells.html</url-pattern>
<url-pattern>/hidserv-frac-reporting.html</url-pattern>
<url-pattern>/webstats-tb.html</url-pattern>
+ <url-pattern>/webstats-tm.html</url-pattern>
</servlet-mapping>
<servlet>
@@ -181,6 +182,9 @@
<url-pattern>/webstats-tb.png</url-pattern>
<url-pattern>/webstats-tb.pdf</url-pattern>
<url-pattern>/webstats-tb.svg</url-pattern>
+ <url-pattern>/webstats-tm.png</url-pattern>
+ <url-pattern>/webstats-tm.pdf</url-pattern>
+ <url-pattern>/webstats-tm.svg</url-pattern>
</servlet-mapping>
<servlet>
diff --git a/website/rserve/graphs.R b/website/rserve/graphs.R
index fc6cfb6..e854aff 100644
--- a/website/rserve/graphs.R
+++ b/website/rserve/graphs.R
@@ -1126,3 +1126,32 @@ plot_webstats_tb <- function(start, end, path) {
ggsave(filename = path, width = 8, height = 5, dpi = 72)
}
+plot_webstats_tm <- function(start, end, path) {
+ end <- min(end, as.character(Sys.Date() - 2))
+ load("/srv/metrics.torproject.org/metrics/shared/RData/webstats-tm.RData")
+ d <- data
+ d <- d[d$log_date >= start & d$log_date <= end, ]
+ date_breaks <- date_breaks(as.numeric(max(d$log_date) - min(d$log_date)))
+ d$request_type <- factor(d$request_type)
+ levels(d$request_type) <- list(
+ 'Initial downloads' = 'tmid',
+ 'Update pings' = 'tmup')
+ formatter <- function(x, ...) {
+ format(x, ..., scientific = FALSE, big.mark = ' ') }
+ ggplot(d, aes(x = log_date, y = count)) +
+ geom_point() +
+ geom_line() +
+ expand_limits(y = 0) +
+ facet_grid(request_type ~ ., scales = "free_y") +
+ scale_x_date(name = paste("\nThe Tor Project - ",
+ "https://metrics.torproject.org/", sep = ""),
+ labels = date_format(date_breaks$format),
+ breaks = date_breaks$major,
+ minor_breaks = date_breaks$minor) +
+ scale_y_continuous(name = 'Requests per day\n', labels = formatter) +
+ theme(strip.text.y = element_text(angle = 0, hjust = 0, size = rel(1.5)),
+ strip.background = element_rect(fill = NA)) +
+ ggtitle("Tor Messenger downloads and updates\n")
+ ggsave(filename = path, width = 8, height = 5, dpi = 72)
+}
+
More information about the tor-commits
mailing list