added support for drawing the size chart
This commit is contained in:
parent
7b43085f84
commit
465c2735ee
39
plot.rb
39
plot.rb
|
@ -1,30 +1,51 @@
|
||||||
|
# coding: utf-8
|
||||||
users = ["christoffermadsen","jmaa","jacob","alexander"]
|
users = ["christoffermadsen","jmaa","jacob","alexander"]
|
||||||
|
colors = {}
|
||||||
|
users.each do |user|
|
||||||
|
colors[user] = "%06x" % (rand * 0xffffff)
|
||||||
|
end
|
||||||
log_dir = "./log/"
|
log_dir = "./log/"
|
||||||
plotstring = %Q[set terminal 'svg' size 1000,400
|
plotstring = %Q[set terminal 'svg' size 800,400
|
||||||
set output "/home/christoffermadsen/public_html/img/screenshot_count.svg"
|
|
||||||
set title "Screenshot count"
|
|
||||||
set key bottom outside
|
set key bottom outside
|
||||||
|
|
||||||
set style line 1 lt 1 lw 2 pt 7 ps 0.4
|
set style line 1 lt 1 lw 2 pt 7 ps 0.4
|
||||||
|
|
||||||
|
set xlabel "Time"
|
||||||
set xdata time
|
set xdata time
|
||||||
set timefmt "%s"
|
set timefmt "%s"
|
||||||
set format x "%m/%d"
|
set format x "%m/%d"
|
||||||
set yrange [0:500]
|
set xtics 172800
|
||||||
set xlabel "Time"
|
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 ylabel "Count"
|
||||||
|
set yrange [0:]
|
||||||
set ytics 100
|
set ytics 100
|
||||||
set mytics 2
|
set mytics 2
|
||||||
set grid ytics mytics xtics
|
|
||||||
set grid
|
plot ]
|
||||||
set xtics 432000
|
|
||||||
|
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 ]
|
plot ]
|
||||||
|
|
||||||
users.each do |user|
|
users.each do |user|
|
||||||
colour = "%06x" % (rand * 0xffffff)
|
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
|
end
|
||||||
|
|
||||||
output = File.open("plotscript","w")
|
output = File.open("plotscript","w")
|
||||||
output << plotstring
|
output << plotstring
|
||||||
output.close
|
output.close
|
||||||
|
|
|
@ -3,13 +3,12 @@ shot_dir = "/var/shots/"
|
||||||
log_dir = "./log/"
|
log_dir = "./log/"
|
||||||
users.each do |user|
|
users.each do |user|
|
||||||
size = `du -B1 #{shot_dir}#{user}/ | awk {'print $1'} | head -n 1`
|
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 = `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 = File.open("#{log_dir}/#{user}.log","a")
|
||||||
output << "#{Time.now.to_i} #{count} #{size}\n"
|
output << "#{Time.now.to_i} #{count} #{size}\n"
|
||||||
output.close
|
output.close
|
||||||
|
|
||||||
puts "#{user} has size #{size} with #{count} screenshots"
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user