diff --git a/plot.rb b/plot.rb index 857c8a5..a871d45 100644 --- a/plot.rb +++ b/plot.rb @@ -1,30 +1,51 @@ +# coding: utf-8 users = ["christoffermadsen","jmaa","jacob","alexander"] +colors = {} +users.each do |user| + colors[user] = "%06x" % (rand * 0xffffff) +end log_dir = "./log/" -plotstring = %Q[set terminal 'svg' size 1000,400 -set output "/home/christoffermadsen/public_html/img/screenshot_count.svg" -set title "Screenshot count" +plotstring = %Q[set terminal 'svg' size 800,400 set key bottom outside set style line 1 lt 1 lw 2 pt 7 ps 0.4 +set xlabel "Time" set xdata time set timefmt "%s" set format x "%m/%d" -set yrange [0:500] -set xlabel "Time" +set xtics 172800 +set mxtics 2 +set grid ytics mytics xtics mxtics + +set title "Screenshot count" +set output "/home/christoffermadsen/public_html/img/screenshot_count.svg" set ylabel "Count" +set yrange [0:] set ytics 100 set mytics 2 -set grid ytics mytics xtics -set grid -set xtics 432000 + +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 plot ] users.each do |user| colour = "%06x" % (rand * 0xffffff) - plotstring += %Q["log/#{user}.log" using 1:2 with lines ls 1 lc rgb '##{colour}' t "#{user}", \\\n] + plotstring += %Q["log/#{user}.log" using 1:($3/10**6) with lines ls 1 lc rgb '##{colors[user]}' t "#{user}", \\\n] end + output = File.open("plotscript","w") output << plotstring output.close diff --git a/update.rb b/update.rb index b5eb890..07290a1 100644 --- a/update.rb +++ b/update.rb @@ -3,13 +3,12 @@ shot_dir = "/var/shots/" log_dir = "./log/" users.each do |user| size = `du -B1 #{shot_dir}#{user}/ | awk {'print $1'} | head -n 1` - size.delete! "\n" count = `ls -1 #{shot_dir}#{user}/ | wc -l | head -n 1` - count.delete! "\n" - + + [size,count].each do |x| + x.delete! "\n" + end output = File.open("#{log_dir}/#{user}.log","a") output << "#{Time.now.to_i} #{count} #{size}\n" output.close - - puts "#{user} has size #{size} with #{count} screenshots" end