[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [metrics-tasks/master] Add graphs of relay lifetime/uptime distributions (#9424).
commit 25ab9bb269c35bb21f08f0f8a2664f73fa11a0dd
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date: Fri Aug 9 15:01:54 2013 +0200
Add graphs of relay lifetime/uptime distributions (#9424).
---
task-9424/.gitignore | 5 +++++
task-9424/README | 6 ++++++
task-9424/parse.sh | 22 ++++++++++++++++++++++
task-9424/plot.R | 23 +++++++++++++++++++++++
4 files changed, 56 insertions(+)
diff --git a/task-9424/.gitignore b/task-9424/.gitignore
new file mode 100644
index 0000000..78e9dfa
--- /dev/null
+++ b/task-9424/.gitignore
@@ -0,0 +1,5 @@
+data.json
+input.csv
+Rplots.pdf
+*.png
+
diff --git a/task-9424/README b/task-9424/README
new file mode 100644
index 0000000..283e1b6
--- /dev/null
+++ b/task-9424/README
@@ -0,0 +1,6 @@
+Howto: Make graphs of relay lifetime and uptime distributions
+=============================================================
+
+./parse.sh > input.csv
+R --slave -f plot.R
+
diff --git a/task-9424/parse.sh b/task-9424/parse.sh
new file mode 100755
index 0000000..1e25f3e
--- /dev/null
+++ b/task-9424/parse.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+SAVEIFS=$IFS
+IFS=$(echo -en "\n\b")
+
+# get latest consensus info
+curl -s -o data.json "https://onionoo.torproject.org/details?running=true&type=relay"
+
+# find relays_published date and time
+relays_published=`grep "relays_published" data.json | cut -d "\"" -f4`
+
+# first seen (for lifetime)
+for first_seen in `grep first_seen data.json | cut -d "\"" -f4`
+do
+ echo $relays_published,"first_seen",$first_seen
+done
+
+# last restarted (for uptime)
+for last_restarted in `grep last_restarted data.json | cut -d "\"" -f4`
+do
+ echo $relays_published,"last_restarted",$last_restarted
+done
+IFS=$SAVEIFS
diff --git a/task-9424/plot.R b/task-9424/plot.R
new file mode 100644
index 0000000..42c09ba
--- /dev/null
+++ b/task-9424/plot.R
@@ -0,0 +1,23 @@
+require(ggplot2)
+library(scales)
+
+plot_graph <- function(indata, xaxis, outfile) {
+ indata <- data.frame(
+ x = sort(as.numeric(
+ as.POSIXct(indata$V1) - as.POSIXct(indata$V3))) / 86400,
+ y = (1:length(indata$V2)) / length(indata$V2))
+ indata <- indata[indata$y <= 0.9, ]
+ ggplot(indata) +
+ geom_line(aes(x = x, y = y)) +
+ scale_x_continuous(name = paste("\n", xaxis, sep = "")) +
+ scale_y_continuous(name = "Fraction of relays\n", limit = c(0, 1),
+ labels = percent)
+ ggsave(outfile, width = 8, height = 5, dpi = 100)
+}
+
+i <- read.csv("input.csv", stringsAsFactors = FALSE, header = FALSE)
+plot_graph(i[i$V2 == "first_seen", ], "Lifetime in days",
+ "first_seen.png")
+plot_graph(i[i$V2 == "last_restarted", ], "Uptime in days",
+ "last_restarted.png")
+
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits