From 05978c6c182999f0ff43e1a5643b0a61e2a5f401 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoffer=20M=C3=BCller=20Madsen?= Date: Fri, 13 Oct 2017 18:51:34 +0200 Subject: [PATCH] updates, I think --- bandwidth.rb | 2 ++ config.rb | 1 + dcav-index.erb | 1 + pieplot.py | 18 +++++++++++------- plot.rb | 2 +- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/bandwidth.rb b/bandwidth.rb index c935281..944f3ac 100644 --- a/bandwidth.rb +++ b/bandwidth.rb @@ -14,6 +14,8 @@ log.split("\n").each do |line| request = parsed['%r'].split(" ")[1] bytes = parsed['%b'].to_i status = parsed['%>s'] + + next if request == nil user = request[1] diff --git a/config.rb b/config.rb index 3a7cd1c..073397d 100644 --- a/config.rb +++ b/config.rb @@ -1,5 +1,6 @@ RES_BASE = "https://strawberry.thedevcave.net/~christoffermadsen/" USERNAMES = ["christoffermadsen","jmaa","jacob","alexander"] +NAMES_SHO = {"c" => "christoffermadsen", "j" => "jmaa", "h" => "jacob", "a" => "alexander"} SHOT_DIR = "/var/shots/" ERB_FILE = "dcav-index.erb" HTML_FILE = "/var/shots/html/index.html" diff --git a/dcav-index.erb b/dcav-index.erb index ddbf207..c262b61 100644 --- a/dcav-index.erb +++ b/dcav-index.erb @@ -35,6 +35,7 @@ %> <% end %> +
Bandwidth logged since 2017-05-23

Charts

/>
diff --git a/pieplot.py b/pieplot.py index 1761786..1884c5b 100644 --- a/pieplot.py +++ b/pieplot.py @@ -1,17 +1,21 @@ +import json import matplotlib as mpl mpl.use('svg') import matplotlib.pyplot as plt users = ['alexander','christoffermadsen','jmaa','jacob'] -numbers = {} -for user in users: - number = open("log/" + user + ".log", "r").read().split("\n")[-2].split(" ")[1] - numbers[user] = number +shot_counts = {} +shot_bandwidth = json.loads(open("log/bandwidth.dat", "r").read()) -values = list(numbers.values()) -labels = list(numbers.keys()) +for user in users: + shot_counts[user] = open("log/" + user + ".log", "r").read().split("\n")[-2].split(" ")[1] fig1, ax1 = plt.subplots() -ax1.pie(values,labels=labels,autopct="%1.1f%%", shadow=True, startangle=90) +ax1.pie(list(shot_counts.values()),labels=list(shot_counts.keys()),autopct="%1.1f%%", shadow=True, startangle=90) ax1.axis('equal') plt.savefig("/home/christoffermadsen/public_html/img/dcavpie.svg", format="svg") + +#fig2, ax2 = plt.subplots() +#plt.figure(fig2.number) +#plt.bar(list(shot_bandwidth.keys()), list(shot_bandwidth.values())) +#plt.savefig("/home/christoffermadsen/public_html/img/dcavbandwidth.svg", format="svg") diff --git a/plot.rb b/plot.rb index 84b4345..bc51811 100644 --- a/plot.rb +++ b/plot.rb @@ -38,7 +38,7 @@ set xlabel "Time" set xdata time set timefmt "%s" set format x "%m/%d" -set xtics 60*60*24*7*2 +set xtics 60*60*24*7*4 set xrange [1485275000:] set mxtics 2 set grid ytics mytics xtics mxtics