Skip to content

Instantly share code, notes, and snippets.

@KTamas
Created October 8, 2012 13:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KTamas/3852397 to your computer and use it in GitHub Desktop.
Save KTamas/3852397 to your computer and use it in GitHub Desktop.
Rukkola bookmarklet stats
#!/usr/bin/env ruby
require 'gchart'
accesslog = "/opt/nginx/logs/access.log"
count = 30
data = {}
count.times do |c|
day = `date -d "-#{c+1} day" '+%d/%b/%Y'`.gsub("\n", '')
data[day] = `cat #{accesslog} |grep 'csak_happolhatoak' | grep 'rukkola.hu' | grep '#{day}' | awk '{print $1}' | sort | uniq| wc -l`.to_i
end
xlabels = data.keys.map {|x| x[0...4]}
ymax = (data.values.max + 20) / 10 * 10
ylabels = []
(ymax/10+1).times {|x| ylabels.push(x*10)}
puts Gchart.bar(
:title => "Last 30 days",
:data => data.values,
:size => '900x300',
:axis_with_labels => 'x,y',
:max_value => ymax,
:axis_labels => [xlabels.join('|'), ylabels.join('|')],
# :custom => "chm=N*f0*,000000,-1,11",
# :format => 'image_tag'
:format => 'file',
:filename => '/web/ktamas.com/bla.png'
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment