Created
October 8, 2012 13:02
-
-
Save KTamas/3852397 to your computer and use it in GitHub Desktop.
Rukkola bookmarklet stats
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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