centralised configuration to config.rb
This commit is contained in:
parent
e1b5259ba6
commit
beb2e8a428
6
config.rb
Normal file
6
config.rb
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
RES_BASE = "https://strawberry.thedevcave.net/~christoffermadsen/"
|
||||||
|
USERNAMES = ["christoffermadsen","jmaa","jacob","alexander"]
|
||||||
|
SHOT_DIR = "/var/shots/"
|
||||||
|
ERB_FILE = "dcav-index.erb"
|
||||||
|
HTML_FILE = "/var/shots/html/index.html"
|
||||||
|
LOG_DIR = "./log/"
|
11
gen_index.rb
11
gen_index.rb
|
@ -1,11 +1,12 @@
|
||||||
require 'erb'
|
require 'erb'
|
||||||
require 'filesize'
|
require 'filesize'
|
||||||
|
|
||||||
RES_BASE = "https://strawberry.thedevcave.net/~christoffermadsen/"
|
load 'config.rb'
|
||||||
usernames = ["christoffermadsen","jmaa","jacob","alexander"]
|
|
||||||
shot_dir = "/var/shots/"
|
usernames = USERNAMES
|
||||||
erb_file = "dcav-index.erb"
|
shot_dir = SHOT_DIR
|
||||||
html_file = "/var/shots/html/index.html"
|
erb_file = ERB_FILE
|
||||||
|
html_file = HTML_FILE
|
||||||
|
|
||||||
class User
|
class User
|
||||||
attr_accessor :name, :count, :size, :avgsize
|
attr_accessor :name, :count, :size, :avgsize
|
||||||
|
|
10
plot.rb
10
plot.rb
|
@ -1,11 +1,15 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
users = ["christoffermadsen","jmaa","jacob","alexander"]
|
load 'config.rb'
|
||||||
colors = {}
|
|
||||||
|
users = USERNAMES
|
||||||
|
log_dir = LOG_DIR
|
||||||
|
|
||||||
|
colors = {}
|
||||||
|
|
||||||
users.each do |user|
|
users.each do |user|
|
||||||
colors[user] = "%06x" % (rand * 0xffffff)
|
colors[user] = "%06x" % (rand * 0xffffff)
|
||||||
end
|
end
|
||||||
log_dir = "./log/"
|
|
||||||
plotstring = %Q[set terminal 'svg' size 800,400 fname 'Verdana, Helvetica, Arial, sans-serif' \
|
plotstring = %Q[set terminal 'svg' size 800,400 fname 'Verdana, Helvetica, Arial, sans-serif' \
|
||||||
fsize '14' rounded dashed
|
fsize '14' rounded dashed
|
||||||
set key bottom center outside horizontal
|
set key bottom center outside horizontal
|
||||||
|
|
17
update.rb
17
update.rb
|
@ -1,15 +1,18 @@
|
||||||
users = ["christoffermadsen","jmaa","alexander","jacob"]
|
load 'config.rb'
|
||||||
shot_dir = "/var/shots/"
|
|
||||||
log_dir = "./log/"
|
users = USERNAMES
|
||||||
|
shot_dir = SHOT_DIR
|
||||||
|
log_dir = LOG_DIR
|
||||||
|
|
||||||
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`
|
||||||
count = `ls -1 #{shot_dir}#{user}/ | wc -l | head -n 1`
|
count = `ls -1 #{shot_dir}#{user}/ | wc -l | head -n 1`
|
||||||
|
|
||||||
[size,count].each do |x|
|
[size,count].each do |x|
|
||||||
x.delete! "\n"
|
x.delete! "\n"
|
||||||
end
|
end
|
||||||
|
|
||||||
output = File.open("#{log_dir}/#{user}.log","a")
|
File.open("#{log_dir}/#{user}.log","a") do |f|
|
||||||
output << "#{Time.now.to_i} #{count} #{size}\n"
|
f << "#{Time.now.to_i} #{count} #{size}\n"
|
||||||
output.close
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user