commit 6b5f75996ad0d9ac5151da48f9693d478dd682de Author: Karsten Loesing karsten.loesing@gmx.net Date: Wed Dec 5 21:32:55 2018 +0100
Tweak Advertised and consumed bandwidth by relay flag graph.
This graph now contains everything that's contained in the Total relay bandwidth and the Consumed bandwidth by Exit/Guard flag combination graph.
Removing those graphs will be done in a separate commit.
Part of #28353. --- src/main/R/rserver/graphs.R | 40 ++++++++++++++------------------ src/main/resources/web/json/metrics.json | 4 ++-- 2 files changed, 20 insertions(+), 24 deletions(-)
diff --git a/src/main/R/rserver/graphs.R b/src/main/R/rserver/graphs.R index 1f7309b..cb40d52 100644 --- a/src/main/R/rserver/graphs.R +++ b/src/main/R/rserver/graphs.R @@ -788,41 +788,37 @@ write_connbidirect <- function(start_p = NULL, end_p = NULL, path_p) { prepare_bandwidth_flags <- function(start_p, end_p) { advbw <- read.csv(paste(stats_dir, "advbw.csv", sep = ""), colClasses = c("date" = "Date")) %>% - transmute(date, isguard, isexit, variable = "advbw", - value = advbw * 8 / 1e9) + transmute(date, have_guard_flag = isguard, have_exit_flag = isexit, + variable = "advbw", value = advbw * 8 / 1e9) bwhist <- read.csv(paste(stats_dir, "bandwidth.csv", sep = ""), colClasses = c("date" = "Date")) %>% - transmute(date, isguard, isexit, variable = "bwhist", - value = (bwread + bwwrite) * 8 / 2e9) + transmute(date, have_guard_flag = isguard, have_exit_flag = isexit, + variable = "bwhist", value = (bwread + bwwrite) * 8 / 2e9) rbind(advbw, bwhist) %>% filter(if (!is.null(start_p)) date >= as.Date(start_p) else TRUE) %>% filter(if (!is.null(end_p)) date <= as.Date(end_p) else TRUE) %>% - group_by(date, variable) %>% - summarize(exit = sum(value[isexit == "t"]), - guard = sum(value[isguard == "t"])) %>% - gather(flag, value, -date, -variable) %>% - unite(variable, flag, variable) %>% - mutate(variable = factor(variable, - levels = c("guard_advbw", "guard_bwhist", "exit_advbw", "exit_bwhist"))) + filter(have_exit_flag != "") %>% + filter(have_guard_flag != "") }
plot_bandwidth_flags <- function(start_p, end_p, path_p) { prepare_bandwidth_flags(start_p, end_p) %>% - complete(date = full_seq(date, period = 1), - variable = unique(variable)) %>% - ggplot(aes(x = date, y = value, colour = variable)) + - geom_line() + + unite(flags, have_guard_flag, have_exit_flag) %>% + mutate(flags = factor(flags, levels = c("f_t", "t_t", "t_f", "f_f"), + labels = c("Exit only", "Guard and Exit", "Guard only", + "Neither Guard nor Exit"))) %>% + mutate(variable = ifelse(variable == "advbw", + "Advertised bandwidth", "Consumed bandwidth")) %>% + ggplot(aes(x = date, y = value, fill = flags)) + + geom_area() + scale_x_date(name = "", breaks = custom_breaks, labels = custom_labels, minor_breaks = custom_minor_breaks) + scale_y_continuous(name = "", labels = unit_format(unit = "Gbit/s"), limits = c(0, NA)) + - scale_colour_manual(name = "", - breaks = c("guard_advbw", "guard_bwhist", "exit_advbw", "exit_bwhist"), - labels = c("Guard, advertised bandwidth", "Guard, bandwidth history", - "Exit, advertised bandwidth", "Exit, bandwidth history"), - values = c("#E69F00", "#D6C827", "#009E73", "#00C34F")) + - ggtitle(paste("Advertised bandwidth and bandwidth history by", - "relay flags")) + + scale_fill_manual(name = "", + values = c("#03B3FF", "#39FF02", "#FFFF00", "#AAAA99")) + + facet_grid(variable ~ .) + + ggtitle("Advertised and consumed bandwidth by relay flags") + labs(caption = copyright_notice) + theme(legend.position = "top") ggsave(filename = path_p, width = 8, height = 5, dpi = 150) diff --git a/src/main/resources/web/json/metrics.json b/src/main/resources/web/json/metrics.json index b351814..5173ae4 100644 --- a/src/main/resources/web/json/metrics.json +++ b/src/main/resources/web/json/metrics.json @@ -90,9 +90,9 @@ }, { "id": "bandwidth-flags", - "title": "Advertised and consumed bandwidth by relay flag", + "title": "Advertised and consumed bandwidth by relay flags", "type": "Graph", - "description": "<p>This graph shows <a href="glossary.html#advertised-bandwidth">advertised</a> and <a href="glossary.html#bandwidth-history">consumed bandwidth</a> of relays with either "Exit" or "Guard" <a href="glossary.html#relay-flag">flags</a> assigned by the directory authorities. These sets are not distinct, because a relay that has both the "Exit" and "Guard" flags assigned will be included in both sets.</p>", + "description": "<p>This graph shows <a href="glossary.html#advertised-bandwidth">advertised</a> and <a href="glossary.html#bandwidth-history">consumed bandwidth</a> of relays with "Exit" and/or "Guard" <a href="glossary.html#relay-flag">flags</a> assigned by the directory authorities.</p>", "function": "bandwidth_flags", "parameters": [ "start",
tor-commits@lists.torproject.org