12 dbpassword= "password"
14 plot_advbw_cdf <- function(datetime, path, xlimit, dpi) {
15 drv <- dbDriver("PostgreSQL")
16 con <- dbConnect(drv, user = dbuser, password = dbpassword, dbname = db)
17 q <- paste("SELECT LEAST(descriptor.bandwidthavg, ",
18 "descriptor.bandwidthburst, ",
19 "descriptor.bandwidthobserved) AS advbw ",
21 "RIGHT JOIN descriptor ",
22 "ON statusentry.descriptor = descriptor.descriptor ",
23 "WHERE statusentry.validafter = '", datetime, "' ",
24 "ORDER BY 1", sep = "")
25 rs <- dbSendQuery(con, q)
26 u <- fetch(rs, n = -1)
29 ggplot(u, aes(x = sort(advbw / 1024),
30 y = (1:length(advbw)) / length(advbw))) +
32 scale_x_continuous(name = "\nAdvertised bandwidth in KiB/s",
33 limit = c(0, xlimit)) +
34 scale_y_continuous(formatter = "percent",
35 name = "Fraction of relays with that bandwidth or less\n") +
36 opts(title = paste(datetime, "\n", sep = ""))
37 ggsave(filename = path, width = 8, height = 5, dpi = as.numeric(dpi))
39 plot_advbw_cdf('2011-02-03 12:00:00', 'advbw-cdf-2011-02-03-12-00-00.png',
41 plot_advbw_cdf('2011-03-03 12:00:00', 'advbw-cdf-2011-03-03-12-00-00.png',
43 plot_advbw_cdf('2011-04-03 12:00:00', 'advbw-cdf-2011-04-03-12-00-00.png',
45 plot_advbw_cdf('2011-05-03 12:00:00', 'advbw-cdf-2011-05-03-12-00-00.png',
47 plot_advbw_cdf('2011-06-03 12:00:00', 'advbw-cdf-2011-06-03-12-00-00.png',
49 plot_advbw_cdf('2011-07-03 12:00:00', 'advbw-cdf-2011-07-03-12-00-00.png',
51 plot_advbw_cdf('2011-08-03 12:00:00', 'advbw-cdf-2011-08-03-12-00-00.png',
53 plot_advbw_cdf('2011-09-03 12:00:00', 'advbw-cdf-2011-09-03-12-00-00.png',
55 plot_advbw_cdf('2011-10-03 12:00:00', 'advbw-cdf-2011-10-03-12-00-00.png',
57 plot_advbw_cdf('2011-11-03 12:00:00', 'advbw-cdf-2011-11-03-12-00-00.png',
59 plot_advbw_cdf('2011-12-03 12:00:00', 'advbw-cdf-2011-12-03-12-00-00.png',
61 plot_advbw_cdf('2012-01-03 12:00:00', 'advbw-cdf-2012-01-03-12-00-00.png',