2017-01-24 19:32:52 +00:00
|
|
|
# coding: utf-8
|
2017-05-09 11:40:42 +00:00
|
|
|
load 'config.rb'
|
|
|
|
|
|
|
|
users = USERNAMES
|
|
|
|
log_dir = LOG_DIR
|
|
|
|
|
|
|
|
colors = {}
|
2017-01-26 15:08:01 +00:00
|
|
|
|
2017-05-11 07:16:03 +00:00
|
|
|
def rand_color
|
|
|
|
"%06x" % (rand * 0xffffff)
|
|
|
|
end
|
|
|
|
|
|
|
|
def color_dist (c1, c2)
|
|
|
|
(c1[0..1].hex - c2[0..1].hex).abs +
|
|
|
|
(c1[2..3].hex - c2[2..3].hex).abs +
|
|
|
|
(c1[4..5].hex - c2[4..5].hex).abs
|
|
|
|
end
|
|
|
|
|
2017-01-24 19:32:52 +00:00
|
|
|
users.each do |user|
|
2017-05-11 07:16:03 +00:00
|
|
|
tentative_color = rand_color
|
|
|
|
while (colors.detect {|k,v| color_dist(v,tentative_color) < 200}) do
|
|
|
|
tentative_color = rand_color
|
|
|
|
end
|
|
|
|
|
|
|
|
colors[user] = tentative_color
|
2017-01-24 19:32:52 +00:00
|
|
|
end
|
2017-05-09 11:40:42 +00:00
|
|
|
|
2017-01-26 15:08:01 +00:00
|
|
|
plotstring = %Q[set terminal 'svg' size 800,400 fname 'Verdana, Helvetica, Arial, sans-serif' \
|
|
|
|
fsize '14' rounded dashed
|
2017-05-08 22:02:43 +00:00
|
|
|
set key bottom center outside horizontal
|
2017-01-24 16:37:27 +00:00
|
|
|
|
|
|
|
set style line 1 lt 1 lw 2 pt 7 ps 0.4
|
|
|
|
|
2017-01-24 19:32:52 +00:00
|
|
|
set xlabel "Time"
|
2017-01-24 16:09:09 +00:00
|
|
|
set xdata time
|
|
|
|
set timefmt "%s"
|
|
|
|
set format x "%m/%d"
|
2017-05-08 22:02:43 +00:00
|
|
|
set xtics 60*60*24*7*2
|
2017-01-26 15:08:01 +00:00
|
|
|
set xrange [1485275000:]
|
2017-01-24 19:32:52 +00:00
|
|
|
set mxtics 2
|
|
|
|
set grid ytics mytics xtics mxtics
|
|
|
|
|
|
|
|
set title "Screenshot count"
|
|
|
|
set output "/home/christoffermadsen/public_html/img/screenshot_count.svg"
|
2017-01-24 16:37:27 +00:00
|
|
|
set ylabel "Count"
|
2017-01-24 19:32:52 +00:00
|
|
|
set yrange [0:]
|
2017-01-24 16:37:27 +00:00
|
|
|
set ytics 100
|
|
|
|
set mytics 2
|
2017-01-24 19:32:52 +00:00
|
|
|
|
|
|
|
plot ]
|
|
|
|
|
|
|
|
users.each do |user|
|
|
|
|
plotstring += %Q["log/#{user}.log" using 1:2 with lines ls 1 lc rgb '##{colors[user]}' t "#{user}", \\\n]
|
|
|
|
end
|
|
|
|
|
|
|
|
plotstring += %Q[
|
|
|
|
set title "Screenshot size"
|
|
|
|
set output "/home/christoffermadsen/public_html/img/screenshot_size.svg"
|
|
|
|
set ylabel "Size (MB)"
|
|
|
|
set yrange [0:100]
|
|
|
|
set ytics 10
|
|
|
|
set mytics 1
|
2017-01-24 16:37:27 +00:00
|
|
|
|
2017-01-24 16:09:09 +00:00
|
|
|
plot ]
|
|
|
|
|
|
|
|
users.each do |user|
|
2017-01-24 16:37:27 +00:00
|
|
|
colour = "%06x" % (rand * 0xffffff)
|
2017-01-24 19:32:52 +00:00
|
|
|
plotstring += %Q["log/#{user}.log" using 1:($3/10**6) with lines ls 1 lc rgb '##{colors[user]}' t "#{user}", \\\n]
|
2017-01-24 16:09:09 +00:00
|
|
|
end
|
2017-01-24 19:32:52 +00:00
|
|
|
|
2017-01-24 16:09:09 +00:00
|
|
|
output = File.open("plotscript","w")
|
|
|
|
output << plotstring
|
|
|
|
output.close
|
2017-01-26 15:08:01 +00:00
|
|
|
|
|
|
|
`gnuplot plotscript`
|